From 0a594429730b179af75dec1a19b5fa9951e83302 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 15 Mar 2020 18:06:58 +0100 Subject: [PATCH] Gui: fix Qt warning: QMetaObject::connectSlotsByName: No matching signal for on_findGroup_changed(QString) do not auto-collapse when search string is empty set red-ish background if no matching group was found --- src/Gui/DlgParameter.ui | 7 +++++++ src/Gui/DlgParameterImp.cpp | 20 +++++++++++++++----- src/Gui/DlgParameterImp.h | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Gui/DlgParameter.ui b/src/Gui/DlgParameter.ui index 1bdbb1f7d3..9ed452ec29 100644 --- a/src/Gui/DlgParameter.ui +++ b/src/Gui/DlgParameter.ui @@ -46,6 +46,13 @@ + + + + Quick search + + + diff --git a/src/Gui/DlgParameterImp.cpp b/src/Gui/DlgParameterImp.cpp index 8c6dd81193..22a002946f 100644 --- a/src/Gui/DlgParameterImp.cpp +++ b/src/Gui/DlgParameterImp.cpp @@ -118,9 +118,6 @@ DlgParameterImp::DlgParameterImp( QWidget* parent, Qt::WindowFlags fl ) this, SLOT(onGroupSelected(QTreeWidgetItem*))); onGroupSelected(paramGroup->currentItem()); - connect(ui->findGroupLE, SIGNAL(textChanged(QString)), - this, SLOT(on_findGroup_changed(QString))); - // setup for function on_findGroup_changed: // store the current font properties because // we don't know what style sheet the user uses for FC @@ -150,7 +147,7 @@ void DlgParameterImp::on_buttonFind_clicked() finder->show(); } -void DlgParameterImp::on_findGroup_changed(const QString &SearchStr) +void DlgParameterImp::on_findGroupLE_textChanged(const QString &SearchStr) { // search for group tree items and highlight found results @@ -163,7 +160,8 @@ void DlgParameterImp::on_findGroup_changed(const QString &SearchStr) item->setForeground(0, defaultColor); ExpandItem = item; // a group can be nested down to several levels - while (true) { + // do not collapse if the search string is empty + while (!SearchStr.isEmpty()) { if (!ExpandItem->parent()) break; else { @@ -185,6 +183,9 @@ void DlgParameterImp::on_findGroup_changed(const QString &SearchStr) // search the tree widget foundList = paramGroup->findItems(SearchStr, Qt::MatchContains | Qt::MatchRecursive); if (foundList.size() > 0) { + // reset background style sheet + if (!ui->findGroupLE->styleSheet().isEmpty()) + ui->findGroupLE->setStyleSheet(QString()); for (QTreeWidgetItem* item : foundList) { item->setFont(0, boldFont); item->setForeground(0, Qt::red); @@ -205,6 +206,15 @@ void DlgParameterImp::on_findGroup_changed(const QString &SearchStr) } } } + else { + // Set red background to indicate no matching + QString styleSheet = QString::fromLatin1( + " QLineEdit {\n" + " background-color: rgb(255,170,255);\n" + " }\n" + ); + ui->findGroupLE->setStyleSheet(styleSheet); + } } /** diff --git a/src/Gui/DlgParameterImp.h b/src/Gui/DlgParameterImp.h index 86e1b7cd09..2d32bbea22 100644 --- a/src/Gui/DlgParameterImp.h +++ b/src/Gui/DlgParameterImp.h @@ -57,7 +57,7 @@ public: protected Q_SLOTS: void onChangeParameterSet(int); void on_buttonFind_clicked(); - void on_findGroup_changed(const QString &SearchStr); + void on_findGroupLE_textChanged(const QString &SearchStr); void on_buttonSaveToDisk_clicked(); void onGroupSelected(QTreeWidgetItem *);