NDEVR
API Documentation
SerialConnectionDialog.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: NDEVR
28File: SerialConnectionDialog
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "NDEVRSerialPort/Headers/DLLInfo.h"
34#include "HardwareWidgets/Headers/ConnectionDialog.h"
35#include "Base/Headers/String.h"
36#include <QSerialPort>
37#include <QWidget>
38namespace Ui
39{
40 class SerialSetupUI;
41}
42
43class QIntValidator;
44
45namespace NDEVR
46{
47 class Connection;
51 class NDEVR_SERIAL_PORT_API SerialConnectionDialog : public ConnectionDialog
52 {
53 Q_OBJECT
54 public:
58 struct Settings
59 {
60 QString name;
61 qint32 baudRate;
63 QSerialPort::DataBits dataBits;
65 QSerialPort::Parity parity;
66 QString stringParity;
67 QSerialPort::StopBits stopBits;
69 QSerialPort::FlowControl flowControl;
71 };
72
77 explicit SerialConnectionDialog(QWidget *parent = nullptr);
79
89 QSerialPort* createSerialPort() const;
90
94 virtual void clear() override;
99 virtual ConnectionInfo connectionInfo() const override;
104 virtual void setConnectionInfo(const ConnectionInfo& connection) override;
110 virtual bool handlesConnection(const ConnectionInfo& connection) override;
111 //private slots:
116 void showPortInfo(int idx);
120 void apply();
124 void cancel();
135
136 private:
140 void fillPortsParameters();
144 void fillPortsInfo();
148 void updateSettings();
149
150 private:
151 Ui::SerialSetupUI *ui = nullptr;
152 Settings m_current_settings;
153 QIntValidator *m_intValidator = nullptr;
154 };
155
159 {
160 public:
166 virtual bool handlesType(const StringView& connection) const override;
171 virtual TranslatedString title() const override;
176 virtual StringView icon() const override;
181 virtual ConnectionDialog* createConnectionDialog() const override;
182 };
183}
Used to, given a Connection, generate an appropriate ConnectionDialog to allow adjustment of paramete...
A virtual dialog that provides an interface that allows the user to adjust certain parameters for a C...
ConnectionDialog(QWidget *parent=nullptr)
Constructs a ConnectionDialog.
A standard interface for all types of connections that allow transmitting and receiving of data betwe...
Definition Connection.h:316
virtual void clear() override
Clears all dialog fields and resets to defaults.
void checkCustomDevicePathPolicy(int idx)
Handles custom device path entry when the user selects the custom option.
void apply()
Applies the current dialog settings and closes the dialog.
virtual void setConnectionInfo(const ConnectionInfo &connection) override
Populates the dialog fields from the given connection information.
virtual bool handlesConnection(const ConnectionInfo &connection) override
Checks whether this dialog can handle the given connection type.
QSerialPort * createSerialPort() const
Creates and configures a new QSerialPort based on the current dialog settings.
virtual ConnectionInfo connectionInfo() const override
Returns connection information derived from the current dialog settings.
void showPortInfo(int idx)
Displays detailed port information for the selected port index.
SerialConnectionDialog(QWidget *parent=nullptr)
Constructs a SerialConnectionDialog.
void checkCustomBaudRatePolicy(int idx)
Handles custom baud rate entry when the user selects the custom option.
Settings settings() const
Returns the current serial port settings configured in the dialog.
void cancel()
Cancels changes and closes the dialog.
A ConnectionDialogFactory which enables the creation of a SerialConnectionDialog.
virtual ConnectionDialog * createConnectionDialog() const override
Creates a new SerialConnectionDialog instance.
virtual StringView icon() const override
Returns the icon name associated with serial port connections.
virtual TranslatedString title() const override
Returns the display title for this connection dialog type.
virtual bool handlesType(const StringView &connection) const override
Checks whether this factory handles the given connection type string.
The core String View class for the NDEVR API.
Definition StringView.h:58
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.
A structure designed to store information about a specific Connection.
Definition Connection.h:90
Stores the current serial port configuration parameters.
QSerialPort::FlowControl flowControl
The flow control mode.
QString stringBaudRate
The baud rate as a display string.
QString stringParity
The parity setting as a display string.
QString stringStopBits
The stop bits setting as a display string.
QSerialPort::Parity parity
The parity checking mode.
QString stringFlowControl
The flow control setting as a display string.
QSerialPort::StopBits stopBits
The number of stop bits per frame.
qint32 baudRate
The baud rate as a numeric value.
QString name
The serial port device name.
QString stringDataBits
The data bits setting as a display string.
QSerialPort::DataBits dataBits
The number of data bits per frame.