From 880183632130382008ffef87e73766df0a96c501 Mon Sep 17 00:00:00 2001 From: Uwe Date: Fri, 27 Jan 2023 02:11:37 +0100 Subject: [PATCH] [Gui] modernize some UI connections --- src/Gui/ComboView.cpp | 3 ++- src/Gui/DAGView/DAGModel.cpp | 6 +++--- src/Gui/DAGView/DAGView.cpp | 3 ++- src/Gui/DemoMode.cpp | 2 +- src/Gui/DlgActionsImp.cpp | 16 ++++++---------- src/Gui/DlgCheckableMessageBox.cpp | 7 ++++--- src/Gui/DlgCommandsImp.cpp | 8 ++++---- src/Gui/DlgExpressionInput.cpp | 6 ++++-- src/Gui/DlgInputDialogImp.cpp | 4 ++-- src/Gui/DlgObjectSelection.cpp | 23 ++++++++++------------- src/Gui/DlgProjectInformationImp.cpp | 6 ++++-- src/Gui/DlgSettingsNavigation.cpp | 8 ++++---- 12 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/Gui/ComboView.cpp b/src/Gui/ComboView.cpp index 51887e93d2..5ffeb3c1ea 100644 --- a/src/Gui/ComboView.cpp +++ b/src/Gui/ComboView.cpp @@ -58,7 +58,8 @@ ComboView::ComboView(bool showModel, Gui::Document* pcDocument, QWidget *parent) tabs->setTabPosition(QTabWidget::North); pLayout->addWidget( tabs, 0, 0 ); - connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(onCurrentTabChanged(int))); + connect(tabs, qOverload(&QTabWidget::currentChanged), + this, &ComboView::onCurrentTabChanged); if (showModel) { // splitter between tree and property view auto splitter = new QSplitter(); diff --git a/src/Gui/DAGView/DAGModel.cpp b/src/Gui/DAGView/DAGModel.cpp index f815d39eca..3332ce73cf 100644 --- a/src/Gui/DAGView/DAGModel.cpp +++ b/src/Gui/DAGView/DAGModel.cpp @@ -129,7 +129,7 @@ Model::Model(QObject *parentIn, const Gui::Document &documentIn) : QGraphicsScen #ifndef Q_OS_MAC renameAction->setShortcut(Qt::Key_F2); #endif - connect(renameAction, SIGNAL(triggered()), this, SLOT(onRenameSlot())); + connect(renameAction, &QAction::triggered, this, &Model::renameAcceptedSlot); editingFinishedAction = new QAction(this); editingFinishedAction->setText(tr("Finish editing")); @@ -1102,8 +1102,8 @@ void Model::onRenameSlot() auto lineEdit = new LineEdit(); auto text = (*theGraph)[selections.front()].text.get(); lineEdit->setText(text->toPlainText()); - connect(lineEdit, SIGNAL(acceptedSignal()), this, SLOT(renameAcceptedSlot())); - connect(lineEdit, SIGNAL(rejectedSignal()), this, SLOT(renameRejectedSlot())); + connect(lineEdit, &LineEdit::acceptedSignal, this, &Model::renameAcceptedSlot); + connect(lineEdit, &LineEdit::rejectedSignal, this, &Model::renameRejectedSlot); proxy = this->addWidget(lineEdit); proxy->setGeometry(text->sceneBoundingRect()); diff --git a/src/Gui/DAGView/DAGView.cpp b/src/Gui/DAGView/DAGView.cpp index d099669d28..6cc21e13f5 100644 --- a/src/Gui/DAGView/DAGView.cpp +++ b/src/Gui/DAGView/DAGView.cpp @@ -54,7 +54,8 @@ View::View(QWidget* parentIn): QGraphicsView(parentIn) conDelete = Application::Instance->signalDeleteDocument.connect(boost::bind(&View::slotDeleteDocument, this, bp::_1)); //just update the dagview when the gui process is idle. - connect(QAbstractEventDispatcher::instance(), SIGNAL(awake()), this, SLOT(awakeSlot())); + connect(QAbstractEventDispatcher::instance(), &QAbstractEventDispatcher::awake, + this, &View::awakeSlot); } View::~View() diff --git a/src/Gui/DemoMode.cpp b/src/Gui/DemoMode.cpp index 6b75b2b529..87a8c51a24 100644 --- a/src/Gui/DemoMode.cpp +++ b/src/Gui/DemoMode.cpp @@ -57,7 +57,7 @@ DemoMode::DemoMode(QWidget* /*parent*/, Qt::WindowFlags fl) wasHidden = false; showHideTimer = new QTimer(this); showHideTimer->setInterval(5000); - connect(showHideTimer, SIGNAL(timeout()), this, SLOT(hide())); + connect(showHideTimer, &QTimer::timeout, this, &DemoMode::hide); } /** Destroys the object and frees any allocated resources */ diff --git a/src/Gui/DlgActionsImp.cpp b/src/Gui/DlgActionsImp.cpp index 8dbf05de4c..65294c591b 100644 --- a/src/Gui/DlgActionsImp.cpp +++ b/src/Gui/DlgActionsImp.cpp @@ -386,10 +386,8 @@ IconDialog::IconDialog(QWidget* parent) ui->setupUi(this); ui->listWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // signals and slots connections - connect(ui->listWidget, SIGNAL(itemClicked (QListWidgetItem *)), - this, SLOT(accept())); - connect(ui->addButton, SIGNAL(clicked()), - this, SLOT(onAddIconPath())); + connect(ui->listWidget, &QListWidget::itemClicked, this, &IconDialog::accept); + connect(ui->addButton, &QPushButton::clicked, this, &IconDialog::onAddIconPath); QListWidgetItem* item; QStringList names = BitmapFactory().findIconFiles(); @@ -503,10 +501,8 @@ IconFolders::IconFolders(const QStringList& paths, QWidget* parent) resize(600,400); auto buttonBox = new QDialogButtonBox(this); buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - connect(buttonBox, SIGNAL(accepted()), - this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), - this, SLOT(reject())); + connect(buttonBox, &QDialogButtonBox::accepted, this, &IconFolders::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &IconFolders::reject); gridLayout = new QGridLayout(); auto mainLayout = new QGridLayout(this); @@ -536,7 +532,7 @@ IconFolders::IconFolders(const QStringList& paths, QWidget* parent) } buttonMap.append(qMakePair(edit, removeButton)); - connect(removeButton, SIGNAL(clicked()), this, SLOT(removeFolder())); + connect(removeButton, &QPushButton::clicked, this, &IconFolders::removeFolder); } textLabel = new QLabel(this); @@ -547,7 +543,7 @@ IconFolders::IconFolders(const QStringList& paths, QWidget* parent) gridLayout->addWidget(textLabel, maxRow, 0, 1, 1); gridLayout->addWidget(addButton, maxRow, 1, 1, 1); - connect(addButton, SIGNAL(clicked()), this, SLOT(addFolder())); + connect(addButton, &QPushButton::clicked, this, &IconFolders::addFolder); if (numPaths >= this->maxLines) addButton->setDisabled(true); } diff --git a/src/Gui/DlgCheckableMessageBox.cpp b/src/Gui/DlgCheckableMessageBox.cpp index b0917fe93c..bda4d147de 100644 --- a/src/Gui/DlgCheckableMessageBox.cpp +++ b/src/Gui/DlgCheckableMessageBox.cpp @@ -120,9 +120,10 @@ DlgCheckableMessageBox::DlgCheckableMessageBox(QWidget *parent) : setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); m_d->ui.setupUi(this); m_d->ui.pixmapLabel->setVisible(false); - connect(m_d->ui.buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(m_d->ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - connect(m_d->ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(slotClicked(QAbstractButton*))); + connect(m_d->ui.buttonBox, &QDialogButtonBox::accepted, this, &DlgCheckableMessageBox::accept); + connect(m_d->ui.buttonBox, &QDialogButtonBox::rejected, this, &DlgCheckableMessageBox::reject); + connect(m_d->ui.buttonBox, &QDialogButtonBox::clicked, + this, &DlgCheckableMessageBox::slotClicked); } DlgCheckableMessageBox::~DlgCheckableMessageBox() diff --git a/src/Gui/DlgCommandsImp.cpp b/src/Gui/DlgCommandsImp.cpp index 9df306a0eb..ce6fb871f7 100644 --- a/src/Gui/DlgCommandsImp.cpp +++ b/src/Gui/DlgCommandsImp.cpp @@ -73,10 +73,10 @@ DlgCustomCommandsImp::DlgCustomCommandsImp( QWidget* parent ) pal.setColor(QPalette::Inactive, QPalette::HighlightedText, pal.color(QPalette::Active, QPalette::HighlightedText)); ui->categoryTreeWidget->setPalette( pal ); - connect(ui->commandTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), - this, SLOT(onDescription(QTreeWidgetItem*))); - connect(ui->categoryTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), - this, SLOT(onGroupActivated(QTreeWidgetItem*))); + connect(ui->commandTreeWidget, &QTreeWidget::currentItemChanged, + this, &DlgCustomCommandsImp::onDescription); + connect(ui->commandTreeWidget, &QTreeWidget::currentItemChanged, + this, &DlgCustomCommandsImp::onGroupActivated); CommandManager & cCmdMgr = Application::Instance->commandManager(); std::map sCommands = cCmdMgr.getCommands(); diff --git a/src/Gui/DlgExpressionInput.cpp b/src/Gui/DlgExpressionInput.cpp index f670761ee5..ff93a60adc 100644 --- a/src/Gui/DlgExpressionInput.cpp +++ b/src/Gui/DlgExpressionInput.cpp @@ -57,8 +57,10 @@ DlgExpressionInput::DlgExpressionInput(const App::ObjectIdentifier & _path, ui->setupUi(this); // Connect signal(s) - connect(ui->expression, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); - connect(ui->discardBtn, SIGNAL(clicked()), this, SLOT(setDiscarded())); + connect(ui->expression, &ExpressionLineEdit::textChanged, + this, &DlgExpressionInput::textChanged); + connect(ui->discardBtn, &QPushButton::clicked, + this, &DlgExpressionInput::setDiscarded); if (expression) { ui->expression->setText(Base::Tools::fromStdString(expression->toString())); diff --git a/src/Gui/DlgInputDialogImp.cpp b/src/Gui/DlgInputDialogImp.cpp index 66458bb1a3..3941b0f271 100644 --- a/src/Gui/DlgInputDialogImp.cpp +++ b/src/Gui/DlgInputDialogImp.cpp @@ -54,8 +54,8 @@ DlgInputDialogImp::DlgInputDialogImp( const QString& labelTxt, QWidget* parent, setType(type); resize(qMax(sh.width(), 400), 1); - connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(tryAccept())); - connect(ui->lineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&))); + connect(ui->lineEdit, &QLineEdit::returnPressed, this, &DlgInputDialogImp::tryAccept); + connect(ui->lineEdit, &QLineEdit::textChanged, this, &DlgInputDialogImp::textChanged); } /** diff --git a/src/Gui/DlgObjectSelection.cpp b/src/Gui/DlgObjectSelection.cpp index b4f94c3a8d..1392ab3b47 100644 --- a/src/Gui/DlgObjectSelection.cpp +++ b/src/Gui/DlgObjectSelection.cpp @@ -158,22 +158,19 @@ void DlgObjectSelection::init(const std::vector &objs, useOriginalsBtn->setToolTip(tr("Ignore dependencies and proceed with objects\noriginally selected prior to opening this dialog")); ui->buttonBox->addButton(useOriginalsBtn, QDialogButtonBox::ResetRole); - connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)), - this, SLOT(onObjItemChanged(QTreeWidgetItem*,int))); - connect(ui->depList, SIGNAL(itemChanged(QTreeWidgetItem*,int)), - this, SLOT(onDepItemChanged(QTreeWidgetItem*,int))); - connect(ui->inList, SIGNAL(itemChanged(QTreeWidgetItem*,int)), - this, SLOT(onDepItemChanged(QTreeWidgetItem*,int))); - connect(ui->treeWidget, SIGNAL(itemSelectionChanged()), - this, SLOT(onItemSelectionChanged())); - connect(useOriginalsBtn, SIGNAL(clicked()), - this, SLOT(onUseOriginalsBtnClicked())); + connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &DlgObjectSelection::onObjItemChanged); + connect(ui->depList, &QTreeWidget::itemChanged, this, &DlgObjectSelection::onDepItemChanged); + connect(ui->inList, &QTreeWidget::itemChanged, this, &DlgObjectSelection::onDepItemChanged); + connect(ui->treeWidget, &QTreeWidget::itemSelectionChanged, + this, &DlgObjectSelection::onItemSelectionChanged); + connect(useOriginalsBtn, &QPushButton::clicked, + this, &DlgObjectSelection::onUseOriginalsBtnClicked); - connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &DlgObjectSelection::accept); + connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &DlgObjectSelection::reject); timer.setSingleShot(true); - connect(&timer, SIGNAL(timeout()), this, SLOT(checkItemChanged())); + connect(&timer, &QTimer::timeout, this, &DlgObjectSelection::checkItemChanged); } /** diff --git a/src/Gui/DlgProjectInformationImp.cpp b/src/Gui/DlgProjectInformationImp.cpp index 1216d025bf..5ac518847d 100644 --- a/src/Gui/DlgProjectInformationImp.cpp +++ b/src/Gui/DlgProjectInformationImp.cpp @@ -98,8 +98,10 @@ DlgProjectInformationImp::DlgProjectInformationImp(App::Document* doc, QWidget* #endif QString text = lines.join(QLatin1String("\n")); ui->textEditComment->setPlainText( text ); - connect(ui->pushButtonOpenURL, SIGNAL(clicked()),this, SLOT(open_url())); - connect(ui->comboLicense, SIGNAL(currentIndexChanged(int)), this, SLOT(onLicenseTypeChanged(int))); + connect(ui->pushButtonOpenURL, &QPushButton::clicked, + this, &DlgProjectInformationImp::open_url); + connect(ui->comboLicense, qOverload(&QComboBox::currentIndexChanged), + this, &DlgProjectInformationImp::onLicenseTypeChanged); } /** diff --git a/src/Gui/DlgSettingsNavigation.cpp b/src/Gui/DlgSettingsNavigation.cpp index 79a96e1d8f..b6d57e1a2b 100644 --- a/src/Gui/DlgSettingsNavigation.cpp +++ b/src/Gui/DlgSettingsNavigation.cpp @@ -173,8 +173,8 @@ void DlgSettingsNavigation::loadSettings() q3 = hCustom->GetFloat("Q3", q3); } - connect(ui->comboNewDocView, SIGNAL(currentIndexChanged(int)), - this, SLOT(onNewDocViewChanged(int))); + connect(ui->comboNewDocView, qOverload(&QComboBox::currentIndexChanged), + this, &DlgSettingsNavigation::onNewDocViewChanged); // fill up font styles hGrp = App::GetApplication().GetParameterGroupByPath( @@ -338,8 +338,8 @@ CameraDialog::CameraDialog(QWidget* parent) currentViewButton->setObjectName(QString::fromLatin1("currentView")); layout->addWidget(currentViewButton, 4, 1, 2, 1); - QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); QMetaObject::connectSlotsByName(this); }