summaryrefslogtreecommitdiffstats
path: root/examples/serialbus/can
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2021-07-20 16:00:37 +0200
committerAndre Hartmann <aha_1980@gmx.de>2021-07-27 13:49:27 +0200
commitfbd1d435fe7f3079ad585ebc454fadb8448146ac (patch)
tree3ba78c2ccf0a7868d41d31c67e847d920c9f63a1 /examples/serialbus/can
parent45614a4b3070d66afaed65849b706d8976e7e928 (diff)
CAN Example: Add CanBusDeviceInfo dialog
As example for the new function QCanBusDevice::deviceInfo(). Therefore, extract the group box containing the information from the connect dialog and re-use it for the new CAN device information dialog. Change-Id: I1fd5f9b630a24c819c1fd77a4e2c05542dc15378 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples/serialbus/can')
-rw-r--r--examples/serialbus/can/CMakeLists.txt2
-rw-r--r--examples/serialbus/can/can.pro9
-rw-r--r--examples/serialbus/can/canbusdeviceinfobox.cpp104
-rw-r--r--examples/serialbus/can/canbusdeviceinfobox.h80
-rw-r--r--examples/serialbus/can/canbusdeviceinfobox.ui86
-rw-r--r--examples/serialbus/can/canbusdeviceinfodialog.cpp69
-rw-r--r--examples/serialbus/can/canbusdeviceinfodialog.h78
-rw-r--r--examples/serialbus/can/canbusdeviceinfodialog.ui66
-rw-r--r--examples/serialbus/can/connectdialog.cpp29
-rw-r--r--examples/serialbus/can/connectdialog.ui241
-rw-r--r--examples/serialbus/can/mainwindow.cpp9
-rw-r--r--examples/serialbus/can/mainwindow.ui6
12 files changed, 619 insertions, 160 deletions
diff --git a/examples/serialbus/can/CMakeLists.txt b/examples/serialbus/can/CMakeLists.txt
index e9f15f0..174866f 100644
--- a/examples/serialbus/can/CMakeLists.txt
+++ b/examples/serialbus/can/CMakeLists.txt
@@ -20,6 +20,8 @@ find_package(Qt6 COMPONENTS Widgets)
qt_add_executable(can
bitratebox.cpp bitratebox.h
+ canbusdeviceinfobox.h canbusdeviceinfobox.cpp canbusdeviceinfobox.ui
+ canbusdeviceinfodialog.h canbusdeviceinfodialog.cpp canbusdeviceinfodialog.ui
connectdialog.cpp connectdialog.h connectdialog.ui
main.cpp
mainwindow.cpp mainwindow.h mainwindow.ui
diff --git a/examples/serialbus/can/can.pro b/examples/serialbus/can/can.pro
index 06a75f3..fa0df66 100644
--- a/examples/serialbus/can/can.pro
+++ b/examples/serialbus/can/can.pro
@@ -6,6 +6,8 @@ TEMPLATE = app
SOURCES += \
bitratebox.cpp \
+ canbusdeviceinfobox.cpp \
+ canbusdeviceinfodialog.cpp \
connectdialog.cpp \
main.cpp \
mainwindow.cpp \
@@ -15,6 +17,8 @@ SOURCES += \
HEADERS += \
bitratebox.h \
+ canbusdeviceinfobox.h \
+ canbusdeviceinfodialog.h \
common.h \
connectdialog.h \
mainwindow.h \
@@ -22,8 +26,11 @@ HEADERS += \
receivedframesview.h \
sendframebox.h
-FORMS += mainwindow.ui \
+FORMS += \
+ canbusdeviceinfobox.ui \
+ canbusdeviceinfodialog.ui \
connectdialog.ui \
+ mainwindow.ui \
sendframebox.ui
RESOURCES += can.qrc
diff --git a/examples/serialbus/can/canbusdeviceinfobox.cpp b/examples/serialbus/can/canbusdeviceinfobox.cpp
new file mode 100644
index 0000000..9ef5fd1
--- /dev/null
+++ b/examples/serialbus/can/canbusdeviceinfobox.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 Andre Hartmann <aha_1980@gmx.de>
+** 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 "canbusdeviceinfobox.h"
+#include "ui_canbusdeviceinfobox.h"
+
+#include <QCanBusDeviceInfo>
+
+CanBusDeviceInfoBox::CanBusDeviceInfoBox(QWidget *parent) :
+ QGroupBox(parent),
+ m_ui(new Ui::CanBusDeviceInfoBox)
+{
+ m_ui->setupUi(this);
+
+ auto setReadOnlyAndCompact = [](QCheckBox *box) {
+ box->setAttribute(Qt::WA_TransparentForMouseEvents);
+ box->setFocusPolicy(Qt::NoFocus);
+ box->setStyleSheet("margin-top:0; margin-bottom:0;");
+ };
+ setReadOnlyAndCompact(m_ui->isVirtual);
+ setReadOnlyAndCompact(m_ui->isFlexibleDataRateCapable);
+}
+
+CanBusDeviceInfoBox::~CanBusDeviceInfoBox()
+{
+ delete m_ui;
+}
+
+void CanBusDeviceInfoBox::clear()
+{
+ m_ui->pluginLabel->clear();
+ m_ui->nameLabel->clear();
+ m_ui->descriptionLabel->clear();
+ m_ui->serialNumberLabel->clear();
+ m_ui->aliasLabel->clear();
+ m_ui->channelLabel->clear();
+ m_ui->isVirtual->setChecked(false);
+ m_ui->isFlexibleDataRateCapable->setChecked(false);
+}
+
+void CanBusDeviceInfoBox::setDeviceInfo(const QCanBusDeviceInfo &info)
+{
+ m_ui->pluginLabel->setText(tr("Plugin: %1").arg(info.plugin()));
+ m_ui->nameLabel->setText(tr("Name: %1").arg(info.name()));
+ m_ui->descriptionLabel->setText(info.description());
+ QString serialNumber = info.serialNumber();
+ if (serialNumber.isEmpty())
+ serialNumber = tr("n/a");
+ m_ui->serialNumberLabel->setText(tr("Serial: %1").arg(serialNumber));
+ QString alias = info.alias();
+ if (alias.isEmpty())
+ alias = tr("n/a");
+ m_ui->aliasLabel->setText(tr("Alias: %1").arg(alias));
+ m_ui->channelLabel->setText(tr("Channel: %1").arg(info.channel()));
+ m_ui->isVirtual->setChecked(info.isVirtual());
+ m_ui->isFlexibleDataRateCapable->setChecked(info.hasFlexibleDataRate());
+}
diff --git a/examples/serialbus/can/canbusdeviceinfobox.h b/examples/serialbus/can/canbusdeviceinfobox.h
new file mode 100644
index 0000000..eded61a
--- /dev/null
+++ b/examples/serialbus/can/canbusdeviceinfobox.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 Andre Hartmann <aha_1980@gmx.de>
+** 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$
+**
+****************************************************************************/
+
+#ifndef CANBUSDEVICEINFOBOX_H
+#define CANBUSDEVICEINFOBOX_H
+
+#include <QGroupBox>
+
+QT_BEGIN_NAMESPACE
+
+class QCanBusDeviceInfo;
+
+namespace Ui {
+class CanBusDeviceInfoBox;
+}
+
+QT_END_NAMESPACE
+
+class CanBusDeviceInfoBox : public QGroupBox
+{
+ Q_OBJECT
+
+public:
+ explicit CanBusDeviceInfoBox(QWidget *parent = nullptr);
+ ~CanBusDeviceInfoBox();
+ void clear();
+ void setDeviceInfo(const QCanBusDeviceInfo &info);
+
+private:
+ Ui::CanBusDeviceInfoBox *m_ui = nullptr;
+};
+
+#endif // CANBUSDEVICEINFOBOX_H
diff --git a/examples/serialbus/can/canbusdeviceinfobox.ui b/examples/serialbus/can/canbusdeviceinfobox.ui
new file mode 100644
index 0000000..d4dd84f
--- /dev/null
+++ b/examples/serialbus/can/canbusdeviceinfobox.ui
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CanBusDeviceInfoBox</class>
+ <widget class="QGroupBox" name="CanBusDeviceInfoBox">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>319</width>
+ <height>217</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>CAN Interface Properties</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="pluginLabel">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="nameLabel">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="descriptionLabel">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="serialNumberLabel">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="aliasLabel">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="channelLabel">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="isFlexibleDataRateCapable">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Flexible Data Rate</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="isVirtual">
+ <property name="text">
+ <string>Virtual</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/serialbus/can/canbusdeviceinfodialog.cpp b/examples/serialbus/can/canbusdeviceinfodialog.cpp
new file mode 100644
index 0000000..5a324f2
--- /dev/null
+++ b/examples/serialbus/can/canbusdeviceinfodialog.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 Andre Hartmann <aha_1980@gmx.de>
+** 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 "canbusdeviceinfodialog.h"
+#include "ui_canbusdeviceinfodialog.h"
+
+#include <QCanBusDeviceInfo>
+
+CanBusDeviceInfoDialog::CanBusDeviceInfoDialog(const QCanBusDeviceInfo &info, QWidget *parent) :
+ QDialog(parent),
+ m_ui(new Ui::CanBusDeviceInfoDialog)
+{
+ m_ui->setupUi(this);
+ m_ui->deviceInfoBox->setDeviceInfo(info);
+
+ connect(m_ui->okButton, &QPushButton::pressed, this, &QDialog::close);
+}
+
+CanBusDeviceInfoDialog::~CanBusDeviceInfoDialog()
+{
+ delete m_ui;
+}
diff --git a/examples/serialbus/can/canbusdeviceinfodialog.h b/examples/serialbus/can/canbusdeviceinfodialog.h
new file mode 100644
index 0000000..8b28c00
--- /dev/null
+++ b/examples/serialbus/can/canbusdeviceinfodialog.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 Andre Hartmann <aha_1980@gmx.de>
+** 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$
+**
+****************************************************************************/
+
+#ifndef CANBUSDEVICEINFODIALOG_H
+#define CANBUSDEVICEINFODIALOG_H
+
+#include <QDialog>
+
+QT_BEGIN_NAMESPACE
+
+class QCanBusDeviceInfo;
+
+namespace Ui {
+class CanBusDeviceInfoDialog;
+}
+
+QT_END_NAMESPACE
+
+class CanBusDeviceInfoDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit CanBusDeviceInfoDialog(const QCanBusDeviceInfo &info, QWidget *parent = nullptr);
+ ~CanBusDeviceInfoDialog();
+
+private:
+ Ui::CanBusDeviceInfoDialog *m_ui = nullptr;
+};
+
+#endif // CANBUSDEVICEINFODIALOG_H
diff --git a/examples/serialbus/can/canbusdeviceinfodialog.ui b/examples/serialbus/can/canbusdeviceinfodialog.ui
new file mode 100644
index 0000000..6328a06
--- /dev/null
+++ b/examples/serialbus/can/canbusdeviceinfodialog.ui
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CanBusDeviceInfoDialog</class>
+ <widget class="QDialog" name="CanBusDeviceInfoDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>237</width>
+ <height>225</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>CAN Interface Properties</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="CanBusDeviceInfoBox" name="deviceInfoBox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="title">
+ <string>CAN Interface Properties</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton">
+ <property name="text">
+ <string>Ok</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>CanBusDeviceInfoBox</class>
+ <extends>QGroupBox</extends>
+ <header location="global">canbusdeviceinfobox.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/serialbus/can/connectdialog.cpp b/examples/serialbus/can/connectdialog.cpp
index 802c25a..4f3836c 100644
--- a/examples/serialbus/can/connectdialog.cpp
+++ b/examples/serialbus/can/connectdialog.cpp
@@ -114,26 +114,15 @@ void ConnectDialog::pluginChanged(const QString &plugin)
void ConnectDialog::interfaceChanged(const QString &interface)
{
- m_ui->isVirtual->setChecked(false);
- m_ui->isFlexibleDataRateCapable->setChecked(false);
-
- for (const QCanBusDeviceInfo &info : qAsConst(m_interfaces)) {
- if (info.name() == interface) {
- m_ui->descriptionLabel->setText(info.description());
- QString serialNumber = info.serialNumber();
- if (serialNumber.isEmpty())
- serialNumber = tr("n/a");
- m_ui->serialNumberLabel->setText(tr("Serial: %1").arg(serialNumber));
- QString alias = info.alias();
- if (alias.isEmpty())
- alias = tr("n/a");
- m_ui->aliasLabel->setText(tr("Alias: %1").arg(alias));
- m_ui->channelLabel->setText(tr("Channel: %1").arg(info.channel()));
- m_ui->isVirtual->setChecked(info.isVirtual());
- m_ui->isFlexibleDataRateCapable->setChecked(info.hasFlexibleDataRate());
- break;
- }
- }
+ const auto deviceInfo = std::find_if(m_interfaces.constBegin(), m_interfaces.constEnd(),
+ [interface](const QCanBusDeviceInfo &info) {
+ return interface == info.name();
+ });
+
+ if (deviceInfo == m_interfaces.constEnd())
+ m_ui->deviceInfoBox->clear();
+ else
+ m_ui->deviceInfoBox->setDeviceInfo(*deviceInfo);
}
void ConnectDialog::ok()
diff --git a/examples/serialbus/can/connectdialog.ui b/examples/serialbus/can/connectdialog.ui
index 54c3550..0ae3430 100644
--- a/examples/serialbus/can/connectdialog.ui
+++ b/examples/serialbus/can/connectdialog.ui
@@ -28,6 +28,75 @@
</layout>
</widget>
</item>
+ <item row="4" column="0" colspan="2">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>GUI Settings</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QCheckBox" name="ringBufferBox">
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use ring buffer in table view model&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="text">
+ <string>Use ring buffer</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="ringBufferLimitBox">
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Limit of ring buffer in table view model&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="minimum">
+ <number>10</number>
+ </property>
+ <property name="maximum">
+ <number>10000000</number>
+ </property>
+ <property name="singleStep">
+ <number>10</number>
+ </property>
+ <property name="stepType">
+ <enum>QAbstractSpinBox::AdaptiveDecimalStepType</enum>
+ </property>
+ <property name="value">
+ <number>1000</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="autoscrollBox">
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Scroll to bottom table view on each portion of received frames&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="text">
+ <string>Autoscroll</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QCheckBox" name="useConfigurationBox">
+ <property name="text">
+ <string>Custom configuration</string>
+ </property>
+ </widget>
+ </item>
<item row="0" column="1" rowspan="4">
<widget class="QGroupBox" name="configurationBox">
<property name="enabled">
@@ -121,145 +190,6 @@
</layout>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QGroupBox" name="specifyInterfaceNameBox">
- <property name="title">
- <string>Specify CAN interface name</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0">
- <widget class="QComboBox" name="interfaceListBox">
- <property name="editable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QGroupBox" name="interfacePropertiesBox">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="title">
- <string>CAN interface properties</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="descriptionLabel">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="serialNumberLabel">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="aliasLabel">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="channelLabel">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="isFlexibleDataRateCapable">
- <property name="text">
- <string>Flexible Data Rate</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="isVirtual">
- <property name="text">
- <string>Virtual</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QCheckBox" name="useConfigurationBox">
- <property name="text">
- <string>Custom configuration</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0" colspan="2">
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>GUI Settings</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QCheckBox" name="ringBufferBox">
- <property name="toolTip">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use ring buffer in table view model&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- <property name="text">
- <string>Use ring buffer</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSpinBox" name="ringBufferLimitBox">
- <property name="toolTip">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Limit of ring buffer in table view model&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- <property name="minimum">
- <number>10</number>
- </property>
- <property name="maximum">
- <number>10000000</number>
- </property>
- <property name="singleStep">
- <number>10</number>
- </property>
- <property name="stepType">
- <enum>QAbstractSpinBox::AdaptiveDecimalStepType</enum>
- </property>
- <property name="value">
- <number>1000</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QCheckBox" name="autoscrollBox">
- <property name="toolTip">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Scroll to bottom table view on each portion of received frames&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- <property name="text">
- <string>Autoscroll</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@@ -300,6 +230,33 @@
</item>
</layout>
</item>
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="specifyInterfaceNameBox">
+ <property name="title">
+ <string>Specify CAN interface name</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="QComboBox" name="interfaceListBox">
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="CanBusDeviceInfoBox" name="deviceInfoBox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="title">
+ <string>CAN Interface Properties</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout"/>
+ </widget>
+ </item>
</layout>
</item>
</layout>
@@ -310,6 +267,12 @@
<extends>QComboBox</extends>
<header>bitratebox.h</header>
</customwidget>
+ <customwidget>
+ <class>CanBusDeviceInfoBox</class>
+ <extends>QGroupBox</extends>
+ <header location="global">canbusdeviceinfobox.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>
diff --git a/examples/serialbus/can/mainwindow.cpp b/examples/serialbus/can/mainwindow.cpp
index 298d80a..d4e1f6f 100644
--- a/examples/serialbus/can/mainwindow.cpp
+++ b/examples/serialbus/can/mainwindow.cpp
@@ -50,6 +50,7 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
+#include "canbusdeviceinfodialog.h"
#include "connectdialog.h"
#include "receivedframesmodel.h"
@@ -101,6 +102,7 @@ MainWindow::~MainWindow()
void MainWindow::initActionsConnections()
{
m_ui->actionDisconnect->setEnabled(false);
+ m_ui->actionDeviceInformation->setEnabled(false);
m_ui->sendFrameBox->setEnabled(false);
connect(m_ui->sendFrameBox, &SendFrameBox::sendFrame, this, &MainWindow::sendFrame);
@@ -119,6 +121,11 @@ void MainWindow::initActionsConnections()
connect(m_ui->actionPluginDocumentation, &QAction::triggered, this, []() {
QDesktopServices::openUrl(QUrl("http://doc.qt.io/qt-5/qtcanbus-backends.html#can-bus-plugins"));
});
+ connect(m_ui->actionDeviceInformation, &QAction::triggered, this, [this]() {
+ auto info = m_canDevice->deviceInfo();
+ CanBusDeviceInfoDialog dialog(info, this);
+ dialog.exec();
+ });
}
void MainWindow::processErrors(QCanBusDevice::CanBusError error) const
@@ -175,6 +182,7 @@ void MainWindow::connectDevice()
} else {
m_ui->actionConnect->setEnabled(false);
m_ui->actionDisconnect->setEnabled(true);
+ m_ui->actionDeviceInformation->setEnabled(true);
m_ui->sendFrameBox->setEnabled(true);
@@ -243,6 +251,7 @@ void MainWindow::disconnectDevice()
m_ui->actionConnect->setEnabled(true);
m_ui->actionDisconnect->setEnabled(false);
+ m_ui->actionDeviceInformation->setEnabled(false);
m_ui->sendFrameBox->setEnabled(false);
diff --git a/examples/serialbus/can/mainwindow.ui b/examples/serialbus/can/mainwindow.ui
index b67490d..61c7760 100644
--- a/examples/serialbus/can/mainwindow.ui
+++ b/examples/serialbus/can/mainwindow.ui
@@ -92,6 +92,7 @@
</property>
<addaction name="actionConnect"/>
<addaction name="actionDisconnect"/>
+ <addaction name="actionDeviceInformation"/>
<addaction name="separator"/>
<addaction name="actionResetController"/>
<addaction name="separator"/>
@@ -179,6 +180,11 @@
<string>Reset CAN Controller</string>
</property>
</action>
+ <action name="actionDeviceInformation">
+ <property name="text">
+ <string>Device &amp;Information...</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>