diff options
author | Karsten Heimrich <karsten.heimrich@qt.io> | 2021-02-24 14:26:24 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@qt.io> | 2021-03-02 11:44:29 +0100 |
commit | 10e4ff602f5ab415bf057ac779f35f0e60b849b2 (patch) | |
tree | 27af336d03b116c6d5b31e0ddc9a624f0cde348f /examples/serialbus/modbus/client/settingsdialog.cpp | |
parent | 7ba42fb04403bb6b30ffceb0b429ae831a053ead (diff) |
Reword example and documentations from master/slave to client/server
Task-number: QTBUG-91213
Task-number: QTBUG-91212
Task-number: QTBUG-91211
Change-Id: I2b585d73b5fa3194459709fa57d44a8f42dceeed
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples/serialbus/modbus/client/settingsdialog.cpp')
-rw-r--r-- | examples/serialbus/modbus/client/settingsdialog.cpp | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/examples/serialbus/modbus/client/settingsdialog.cpp b/examples/serialbus/modbus/client/settingsdialog.cpp new file mode 100644 index 0000000..0a5eb43 --- /dev/null +++ b/examples/serialbus/modbus/client/settingsdialog.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the QtSerialBus module. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "settingsdialog.h" +#include "ui_settingsdialog.h" + +SettingsDialog::SettingsDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::SettingsDialog) +{ + ui->setupUi(this); + + ui->parityCombo->setCurrentIndex(1); +#if QT_CONFIG(modbus_serialport) + ui->baudCombo->setCurrentText(QString::number(m_settings.baud)); + ui->dataBitsCombo->setCurrentText(QString::number(m_settings.dataBits)); + ui->stopBitsCombo->setCurrentText(QString::number(m_settings.stopBits)); +#endif + ui->timeoutSpinner->setValue(m_settings.responseTime); + ui->retriesSpinner->setValue(m_settings.numberOfRetries); + + connect(ui->applyButton, &QPushButton::clicked, [this]() { +#if QT_CONFIG(modbus_serialport) + m_settings.parity = ui->parityCombo->currentIndex(); + if (m_settings.parity > 0) + m_settings.parity++; + m_settings.baud = ui->baudCombo->currentText().toInt(); + m_settings.dataBits = ui->dataBitsCombo->currentText().toInt(); + m_settings.stopBits = ui->stopBitsCombo->currentText().toInt(); +#endif + m_settings.responseTime = ui->timeoutSpinner->value(); + m_settings.numberOfRetries = ui->retriesSpinner->value(); + + hide(); + }); +} + +SettingsDialog::~SettingsDialog() +{ + delete ui; +} + +SettingsDialog::Settings SettingsDialog::settings() const +{ + return m_settings; +} |