From ae8239a53ea9c512d60f54903c741aab33a6b439 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 4 Sep 2020 21:58:18 +0200 Subject: Use operator| to compose key sequences In preparation for deprecating operator+. It's deprecated in C++20. Insert casts as necessary. Drive-by, prepare for deprecation of operator+ for building key sequences. Initial-patch-by: Giuseppe D'Angelo Pick-to: 5.15 Change-Id: Iaae4e35a56aa1c2365bc25af2582cf820de38d5e Reviewed-by: Jarek Kobus --- src/assistant/assistant/mainwindow.cpp | 8 ++++---- .../src/components/formeditor/formwindowmanager.cpp | 20 ++++++++++---------- src/designer/src/designer/qdesigner_actions.cpp | 2 +- src/designer/src/designer/qdesigner_toolwindow.cpp | 2 +- src/linguist/linguist/phraseview.h | 3 ++- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/assistant/assistant/mainwindow.cpp b/src/assistant/assistant/mainwindow.cpp index 94d9b6b65..b4492b6bf 100644 --- a/src/assistant/assistant/mainwindow.cpp +++ b/src/assistant/assistant/mainwindow.cpp @@ -610,12 +610,12 @@ void MainWindow::setupActions() tmp = menu->addAction(tr("Next Page"), openPages, &OpenPagesManager::nextPage); tmp->setShortcuts(QList() << QKeySequence(tr("Ctrl+Alt+Right")) - << QKeySequence(Qt::CTRL + Qt::Key_PageDown)); + << QKeySequence(Qt::CTRL | Qt::Key_PageDown)); tmp = menu->addAction(tr("Previous Page"), openPages, &OpenPagesManager::previousPage); tmp->setShortcuts(QList() << QKeySequence(tr("Ctrl+Alt+Left")) - << QKeySequence(Qt::CTRL + Qt::Key_PageUp)); + << QKeySequence(Qt::CTRL | Qt::Key_PageUp)); const Qt::Modifier modifier = #ifdef Q_OS_MAC @@ -624,10 +624,10 @@ void MainWindow::setupActions() Qt::CTRL; #endif - QShortcut *sct = new QShortcut(QKeySequence(modifier + Qt::Key_Tab), this); + QShortcut *sct = new QShortcut(QKeySequence(modifier | Qt::Key_Tab), this); connect(sct, &QShortcut::activated, openPages, &OpenPagesManager::nextPageWithSwitcher); - sct = new QShortcut(QKeySequence(modifier + Qt::SHIFT + Qt::Key_Tab), this); + sct = new QShortcut(QKeySequence(modifier | Qt::SHIFT | Qt::Key_Tab), this); connect(sct, &QShortcut::activated, openPages, &OpenPagesManager::previousPageWithSwitcher); diff --git a/src/designer/src/components/formeditor/formwindowmanager.cpp b/src/designer/src/components/formeditor/formwindowmanager.cpp index 60ad4da5e..c0f84061a 100644 --- a/src/designer/src/components/formeditor/formwindowmanager.cpp +++ b/src/designer/src/components/formeditor/formwindowmanager.cpp @@ -410,7 +410,7 @@ void FormWindowManager::setupActions() m_actionRaise = new QAction(createIconSet(QStringLiteral("editraise.png")), tr("Bring to &Front"), this); m_actionRaise->setObjectName(QStringLiteral("__qt_raise_action")); - m_actionRaise->setShortcut(Qt::CTRL + Qt::Key_L); + m_actionRaise->setShortcut(Qt::CTRL | Qt::Key_L); m_actionRaise->setStatusTip(tr("Raises the selected widgets")); m_actionRaise->setWhatsThis(tr("Raises the selected widgets")); connect(m_actionRaise, &QAction::triggered, this, &FormWindowManager::slotActionRaiseActivated); @@ -418,7 +418,7 @@ void FormWindowManager::setupActions() m_actionLower = new QAction(createIconSet(QStringLiteral("editlower.png")), tr("Send to &Back"), this); m_actionLower->setObjectName(QStringLiteral("__qt_lower_action")); - m_actionLower->setShortcut(Qt::CTRL + Qt::Key_K); + m_actionLower->setShortcut(Qt::CTRL | Qt::Key_K); m_actionLower->setStatusTip(tr("Lowers the selected widgets")); m_actionLower->setWhatsThis(tr("Lowers the selected widgets")); connect(m_actionLower, &QAction::triggered, this, &FormWindowManager::slotActionLowerActivated); @@ -426,7 +426,7 @@ void FormWindowManager::setupActions() m_actionAdjustSize = new QAction(createIconSet(QStringLiteral("adjustsize.png")), tr("Adjust &Size"), this); m_actionAdjustSize->setObjectName(QStringLiteral("__qt_adjust_size_action")); - m_actionAdjustSize->setShortcut(Qt::CTRL + Qt::Key_J); + m_actionAdjustSize->setShortcut(Qt::CTRL | Qt::Key_J); m_actionAdjustSize->setStatusTip(tr("Adjusts the size of the selected widget")); m_actionAdjustSize->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Adjust Size"))); connect(m_actionAdjustSize, &QAction::triggered, this, &FormWindowManager::slotActionAdjustSizeActivated); @@ -435,7 +435,7 @@ void FormWindowManager::setupActions() m_actionHorizontalLayout = new QAction(createIconSet(QStringLiteral("edithlayout.png")), tr("Lay Out &Horizontally"), this); m_actionHorizontalLayout->setObjectName(QStringLiteral("__qt_horizontal_layout_action")); - m_actionHorizontalLayout->setShortcut(Qt::CTRL + Qt::Key_1); + m_actionHorizontalLayout->setShortcut(Qt::CTRL | Qt::Key_1); m_actionHorizontalLayout->setStatusTip(tr("Lays out the selected widgets horizontally")); m_actionHorizontalLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Horizontally"))); m_actionHorizontalLayout->setData(LayoutInfo::HBox); @@ -444,7 +444,7 @@ void FormWindowManager::setupActions() m_actionVerticalLayout = new QAction(createIconSet(QStringLiteral("editvlayout.png")), tr("Lay Out &Vertically"), this); m_actionVerticalLayout->setObjectName(QStringLiteral("__qt_vertical_layout_action")); - m_actionVerticalLayout->setShortcut(Qt::CTRL + Qt::Key_2); + m_actionVerticalLayout->setShortcut(Qt::CTRL | Qt::Key_2); m_actionVerticalLayout->setStatusTip(tr("Lays out the selected widgets vertically")); m_actionVerticalLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Vertically"))); m_actionVerticalLayout->setData(LayoutInfo::VBox); @@ -454,7 +454,7 @@ void FormWindowManager::setupActions() QIcon formIcon = QIcon::fromTheme(QStringLiteral("designer-form-layout"), createIconSet(QStringLiteral("editform.png"))); m_actionFormLayout = new QAction(formIcon, tr("Lay Out in a &Form Layout"), this); m_actionFormLayout->setObjectName(QStringLiteral("__qt_form_layout_action")); - m_actionFormLayout->setShortcut(Qt::CTRL + Qt::Key_6); + m_actionFormLayout->setShortcut(Qt::CTRL | Qt::Key_6); m_actionFormLayout->setStatusTip(tr("Lays out the selected widgets in a form layout")); m_actionFormLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out in a Form"))); m_actionFormLayout->setData(LayoutInfo::Form); @@ -463,7 +463,7 @@ void FormWindowManager::setupActions() m_actionGridLayout = new QAction(createIconSet(QStringLiteral("editgrid.png")), tr("Lay Out in a &Grid"), this); m_actionGridLayout->setObjectName(QStringLiteral("__qt_grid_layout_action")); - m_actionGridLayout->setShortcut(Qt::CTRL + Qt::Key_5); + m_actionGridLayout->setShortcut(Qt::CTRL | Qt::Key_5); m_actionGridLayout->setStatusTip(tr("Lays out the selected widgets in a grid")); m_actionGridLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out in a Grid"))); m_actionGridLayout->setData(LayoutInfo::Grid); @@ -473,7 +473,7 @@ void FormWindowManager::setupActions() m_actionSplitHorizontal = new QAction(createIconSet(QStringLiteral("edithlayoutsplit.png")), tr("Lay Out Horizontally in S&plitter"), this); m_actionSplitHorizontal->setObjectName(QStringLiteral("__qt_split_horizontal_action")); - m_actionSplitHorizontal->setShortcut(Qt::CTRL + Qt::Key_3); + m_actionSplitHorizontal->setShortcut(Qt::CTRL | Qt::Key_3); m_actionSplitHorizontal->setStatusTip(tr("Lays out the selected widgets horizontally in a splitter")); m_actionSplitHorizontal->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Horizontally in Splitter"))); m_actionSplitHorizontal->setData(LayoutInfo::HSplitter); @@ -483,7 +483,7 @@ void FormWindowManager::setupActions() m_actionSplitVertical = new QAction(createIconSet(QStringLiteral("editvlayoutsplit.png")), tr("Lay Out Vertically in Sp&litter"), this); m_actionSplitVertical->setObjectName(QStringLiteral("__qt_split_vertical_action")); - m_actionSplitVertical->setShortcut(Qt::CTRL + Qt::Key_4); + m_actionSplitVertical->setShortcut(Qt::CTRL | Qt::Key_4); m_actionSplitVertical->setStatusTip(tr("Lays out the selected widgets vertically in a splitter")); m_actionSplitVertical->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Vertically in Splitter"))); connect(m_actionSplitVertical, &QAction::triggered, this, &FormWindowManager::createLayout); @@ -493,7 +493,7 @@ void FormWindowManager::setupActions() m_actionBreakLayout = new QAction(createIconSet(QStringLiteral("editbreaklayout.png")), tr("&Break Layout"), this); m_actionBreakLayout->setObjectName(QStringLiteral("__qt_break_layout_action")); - m_actionBreakLayout->setShortcut(Qt::CTRL + Qt::Key_0); + m_actionBreakLayout->setShortcut(Qt::CTRL | Qt::Key_0); m_actionBreakLayout->setStatusTip(tr("Breaks the selected layout")); m_actionBreakLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Break Layout"))); connect(m_actionBreakLayout, &QAction::triggered, this, &FormWindowManager::slotActionBreakLayoutActivated); diff --git a/src/designer/src/designer/qdesigner_actions.cpp b/src/designer/src/designer/qdesigner_actions.cpp index e0a7d7136..d21eb010c 100644 --- a/src/designer/src/designer/qdesigner_actions.cpp +++ b/src/designer/src/designer/qdesigner_actions.cpp @@ -442,7 +442,7 @@ QActionGroup *QDesignerActions::createHelpActions() QAction *mainHelpAction = new QAction(tr("Qt Designer &Help"), this); mainHelpAction->setObjectName(QStringLiteral("__qt_designer_help_action")); connect(mainHelpAction, &QAction::triggered, this, &QDesignerActions::showDesignerHelp); - mainHelpAction->setShortcut(Qt::CTRL + Qt::Key_Question); + mainHelpAction->setShortcut(Qt::CTRL | Qt::Key_Question); helpActions->addAction(mainHelpAction); helpActions->addAction(createSeparator(this)); diff --git a/src/designer/src/designer/qdesigner_toolwindow.cpp b/src/designer/src/designer/qdesigner_toolwindow.cpp index 6262d15ac..2a003bb25 100644 --- a/src/designer/src/designer/qdesigner_toolwindow.cpp +++ b/src/designer/src/designer/qdesigner_toolwindow.cpp @@ -172,7 +172,7 @@ PropertyEditorToolWindow::PropertyEditorToolWindow(QDesignerWorkbench *workbench QStringLiteral("__qt_property_editor_action"), Qt::RightDockWidgetArea) { - action()->setShortcut(Qt::CTRL + Qt::Key_I); + action()->setShortcut(Qt::CTRL | Qt::Key_I); } diff --git a/src/linguist/linguist/phraseview.h b/src/linguist/linguist/phraseview.h index 9f773c0b0..6e5b42703 100644 --- a/src/linguist/linguist/phraseview.h +++ b/src/linguist/linguist/phraseview.h @@ -48,7 +48,8 @@ public: GuessShortcut(int nkey, QWidget *parent, const char *member) : QShortcut(parent), nrkey(nkey) { - setKey(Qt::CTRL + (Qt::Key_1 + nrkey)); + const auto key = static_cast(int(Qt::Key_1) + nrkey); + setKey(Qt::CTRL | key); connect(this, SIGNAL(activated()), this, SLOT(keyActivated())); connect(this, SIGNAL(activated(int)), parent, member); } -- cgit v1.2.3