From c8667971dea7c38862bd3bf190269072e8c2fe6d Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Tue, 29 Mar 2016 17:03:46 +0200 Subject: CAN-Example: Add hint to ConnectDialog interface edit It was really hard to figure out what to put in the interface edit without deeper knowledge of the backends. Now the interface edit a placeholder with the first possible name every time a new backend is selected. This is thought as a temporary fix, the proper solution would be to get the possible interfaces from the backends itself. Change-Id: I74b5c072d64f7ee98d3fa65e059e6b00c510b308 Reviewed-by: Alex Blasche Reviewed-by: Denis Shienkov --- examples/serialbus/can/connectdialog.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'examples/serialbus/can/connectdialog.cpp') diff --git a/examples/serialbus/can/connectdialog.cpp b/examples/serialbus/can/connectdialog.cpp index 7495832..1c3ba43 100644 --- a/examples/serialbus/can/connectdialog.cpp +++ b/examples/serialbus/can/connectdialog.cpp @@ -71,7 +71,8 @@ ConnectDialog::ConnectDialog(QWidget *parent) : connect(m_ui->speedBox, static_cast(&QComboBox::currentIndexChanged), this, &ConnectDialog::checkCustomSpeedPolicy); - + connect(m_ui->backendListBox, &QComboBox::currentTextChanged, + this, &ConnectDialog::backendChanged); m_ui->rawFilterEdit->hide(); m_ui->rawFilterLabel->hide(); @@ -102,6 +103,18 @@ void ConnectDialog::checkCustomSpeedPolicy(int idx) } } +void ConnectDialog::backendChanged(const QString &backend) +{ + if (backend == QStringLiteral("generic")) + m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("can0")); + else if (backend == QStringLiteral("peakcan")) + m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("usbbus1")); + else if (backend == QStringLiteral("socketcan")) + m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("can0")); + else if (backend == QStringLiteral("tinycan")) + m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("channela")); +} + void ConnectDialog::ok() { updateSettings(); -- cgit v1.2.3