diff --git a/src/Gui/CommandCompleter.cpp b/src/Gui/CommandCompleter.cpp index aa12acd94d..7ec5844e7a 100644 --- a/src/Gui/CommandCompleter.cpp +++ b/src/Gui/CommandCompleter.cpp @@ -156,9 +156,11 @@ CommandCompleter::CommandCompleter(QLineEdit *lineedit, QObject *parent) this->setCaseSensitivity(Qt::CaseInsensitive); this->setCompletionMode(QCompleter::PopupCompletion); this->setWidget(lineedit); - connect(lineedit, SIGNAL(textEdited(QString)), this, SLOT(onTextChanged(QString))); - connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(onCommandActivated(QModelIndex))); - connect(this, SIGNAL(highlighted(QString)), lineedit, SLOT(setText(QString))); + connect(lineedit, &QLineEdit::textEdited, this, &CommandCompleter::onTextChanged); + connect(this, qOverload(&CommandCompleter::activated), + this, &CommandCompleter::onCommandActivated); + connect(this, qOverload(&CommandCompleter::highlighted), + lineedit, &QLineEdit::setText); } bool CommandCompleter::eventFilter(QObject *o, QEvent *ev) diff --git a/src/Gui/CommandCompleter.h b/src/Gui/CommandCompleter.h index a2edd07236..18a3f35e1f 100644 --- a/src/Gui/CommandCompleter.h +++ b/src/Gui/CommandCompleter.h @@ -23,6 +23,7 @@ #ifndef GUI_COMMAND_COMPLETER_H #define GUI_COMMAND_COMPLETER_H +#include #include class QLineEdit; diff --git a/src/Gui/DlgKeyboardImp.cpp b/src/Gui/DlgKeyboardImp.cpp index bbe95b7ac2..f03b47a2d9 100644 --- a/src/Gui/DlgKeyboardImp.cpp +++ b/src/Gui/DlgKeyboardImp.cpp @@ -101,9 +101,12 @@ DlgCustomKeyboardImp::DlgCustomKeyboardImp( QWidget* parent ) ui->shortcutTimeout->onRestore(); QTimer *timer = new QTimer(this); - QObject::connect(ui->shortcutTimeout, QOverload::of(&QSpinBox::valueChanged), - timer, [=](int) {timer->start(100);}); - QObject::connect(timer, &QTimer::timeout, [=](){ui->shortcutTimeout->onSave();}); + QObject::connect(ui->shortcutTimeout, QOverload::of(&QSpinBox::valueChanged), timer, [=](int) { + timer->start(100); + }); + QObject::connect(timer, &QTimer::timeout, [=]() { + ui->shortcutTimeout->onSave(); + }); } /** Destroys the object and frees any allocated resources */ @@ -153,11 +156,14 @@ void DlgCustomKeyboardImp::populateCommandList(QTreeWidget *commandTreeWidget, if (auto item = commandTreeWidget->currentItem()) current = item->data(1, Qt::UserRole).toByteArray(); - if (separatorItem) + if (separatorItem) { commandTreeWidget->takeTopLevelItem(commandTreeWidget->indexOfTopLevelItem(separatorItem)); + } commandTreeWidget->clear(); - if (separatorItem) + if (separatorItem) { commandTreeWidget->addTopLevelItem(separatorItem); + } + CommandManager & cCmdMgr = Application::Instance->commandManager(); auto group = combo->itemData(combo->currentIndex(), Qt::UserRole).toByteArray(); auto cmds = group == "All" ? cCmdMgr.getAllCommands() @@ -210,11 +216,13 @@ DlgCustomKeyboardImp::initCommandList(QTreeWidget *commandTreeWidget, populateCommandList(commandTreeWidget, separatorItem, combo); }); - QObject::connect(ShortcutManager::instance(), &ShortcutManager::shortcutChanged, - timer, [timer]() { timer->start(100); }); + QObject::connect(ShortcutManager::instance(), &ShortcutManager::shortcutChanged, timer, [timer]() { + timer->start(100); + }); - QObject::connect(combo, QOverload::of(&QComboBox::activated), - timer, [timer]() { timer->start(100); }); + QObject::connect(combo, QOverload::of(&QComboBox::activated), timer, [timer]() { + timer->start(100); + }); return Application::Instance->commandManager().signalChanged.connect([timer](){ timer->start(100); @@ -285,11 +293,18 @@ DlgCustomKeyboardImp::initCommandWidgets(QTreeWidget *commandTreeWidget, auto timer = new QTimer(priorityList); timer->setSingleShot(true); - if (currentShortcut) - QObject::connect(currentShortcut, &QLineEdit::textChanged, timer, [timer](){timer->start(200);}); - QObject::connect(editShortcut, &QLineEdit::textChanged, timer, [timer](){timer->start(200);}); - QObject::connect(ShortcutManager::instance(), &ShortcutManager::priorityChanged, timer, [timer](){timer->start(200);}); - QObject::connect(timer, &QTimer::timeout, [=](){ + if (currentShortcut) { + QObject::connect(currentShortcut, &QLineEdit::textChanged, timer, [timer]() { + timer->start(200); + }); + } + QObject::connect(editShortcut, &QLineEdit::textChanged, timer, [timer]() { + timer->start(200); + }); + QObject::connect(ShortcutManager::instance(), &ShortcutManager::priorityChanged, timer, [timer](){ + timer->start(200); + }); + QObject::connect(timer, &QTimer::timeout, [=]() { populatePriorityList(priorityList, editShortcut, currentShortcut); }); } @@ -510,8 +525,9 @@ void DlgCustomKeyboardImp::onModifyMacroAction(const QByteArray&) { QVariant data = ui->categoryBox->itemData(ui->categoryBox->currentIndex(), Qt::UserRole); QString group = data.toString(); - if (group == QLatin1String("Macros")) + if (group == QLatin1String("Macros")) { ui->categoryBox->activated(ui->categoryBox->currentIndex()); + } } void DlgCustomKeyboardImp::changeEvent(QEvent *e) @@ -531,8 +547,10 @@ void DlgCustomKeyboardImp::changeEvent(QEvent *e) } ui->categoryBox->activated(ui->categoryBox->currentIndex()); } - else if (e->type() == QEvent::StyleChange) + else if (e->type() == QEvent::StyleChange) { ui->categoryBox->activated(ui->categoryBox->currentIndex()); + } + QWidget::changeEvent(e); } diff --git a/src/Gui/DlgToolbarsImp.cpp b/src/Gui/DlgToolbarsImp.cpp index 72c5b51ffa..5da2271086 100644 --- a/src/Gui/DlgToolbarsImp.cpp +++ b/src/Gui/DlgToolbarsImp.cpp @@ -532,8 +532,10 @@ void DlgCustomToolbars::changeEvent(QEvent *e) } ui->categoryBox->activated(ui->categoryBox->currentIndex()); } - else if (e->type() == QEvent::StyleChange) + else if (e->type() == QEvent::StyleChange) { ui->categoryBox->activated(ui->categoryBox->currentIndex()); + } + QWidget::changeEvent(e); } diff --git a/src/Gui/ToolBarManager.cpp b/src/Gui/ToolBarManager.cpp index 7709af19ff..a26ae3af06 100644 --- a/src/Gui/ToolBarManager.cpp +++ b/src/Gui/ToolBarManager.cpp @@ -180,8 +180,9 @@ void ToolBarManager::setup(ToolBarItem* toolBarItems) return; // empty menu bar static QPointer _ActionWidget; - if (!_ActionWidget) + if (!_ActionWidget) { _ActionWidget = new QWidget(getMainWindow()); + } else { for (auto action : _ActionWidget->actions()) _ActionWidget->removeAction(action); @@ -231,8 +232,9 @@ void ToolBarManager::setup(ToolBarItem* toolBarItems) // setup the toolbar setup(*it, toolbar); - for (auto action : toolbar->actions()) + for (auto action : toolbar->actions()) { _ActionWidget->addAction(action); + } // try to add some breaks to avoid to have all toolbars in one line if (toolbar_added) { @@ -287,15 +289,19 @@ void ToolBarManager::setup(ToolBarItem* item, QToolBar* toolbar) const if (!action) { if ((*it)->command() == "Separator") { action = toolbar->addSeparator(); - } else { + } + else { // Check if action was added successfully if (mgr.addTo((*it)->command().c_str(), toolbar)) action = toolbar->actions().constLast(); } // set the tool button user data - if (action) action->setData(QString::fromLatin1((*it)->command().c_str())); - } else { + if (action) { + action->setData(QString::fromLatin1((*it)->command().c_str())); + } + } + else { // Note: For toolbars we do not remove and re-add the actions // because this causes flicker effects. So, it could happen that the order of // buttons doesn't match with the order of commands in the workbench. @@ -421,4 +427,4 @@ void ToolBarManager::setToolbarVisibility(bool show, const QString& name) { tb->toggleViewAction()->setVisible(false); } } -} \ No newline at end of file +}