From 3e1c8a36d5fc38feac47e1c301d814637ed30b67 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 9 Feb 2023 16:02:25 +0200 Subject: [PATCH] Fix QKeySequence. --- src/app/puzzle/scene/vpmaingraphicsview.cpp | 5 ++ src/app/puzzle/vpmainwindow.cpp | 35 +++++++++-- src/app/valentina/mainwindow.cpp | 70 ++++++++++++++++++--- 3 files changed, 95 insertions(+), 15 deletions(-) diff --git a/src/app/puzzle/scene/vpmaingraphicsview.cpp b/src/app/puzzle/scene/vpmaingraphicsview.cpp index a91f42ac8..a0937c81b 100644 --- a/src/app/puzzle/scene/vpmaingraphicsview.cpp +++ b/src/app/puzzle/scene/vpmaingraphicsview.cpp @@ -66,8 +66,13 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion") #endif +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +Q_GLOBAL_STATIC_WITH_ARGS(const QKeySequence, restoreOriginShortcut, // NOLINT + (QKeySequence(Qt::ControlModifier | Qt::Key_Asterisk))) +#else Q_GLOBAL_STATIC_WITH_ARGS(const QKeySequence, restoreOriginShortcut, // NOLINT (QKeySequence(Qt::ControlModifier + Qt::Key_Asterisk))) +#endif QT_WARNING_POP } diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 374b419bc..b8066ab92 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -1534,24 +1534,49 @@ void VPMainWindow::InitZoomToolBar() // connect the zoom buttons and shortcuts to the slots QList zoomInShortcuts; zoomInShortcuts.append(QKeySequence(QKeySequence::ZoomIn)); - zoomInShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Plus + Qt::KeypadModifier)); + zoomInShortcuts.append( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(QKeyCombination(Qt::ControlModifier), Qt::Key_Plus | Qt::KeypadModifier)); +#else + QKeySequence(Qt::ControlModifier + Qt::Key_Plus + Qt::KeypadModifier)); +#endif ui->actionZoomIn->setShortcuts(zoomInShortcuts); connect(ui->actionZoomIn, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomIn); QList zoomOutShortcuts; zoomOutShortcuts.append(QKeySequence(QKeySequence::ZoomOut)); - zoomOutShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier)); + zoomOutShortcuts.append( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(QKeyCombination(Qt::ControlModifier), Qt::Key_Minus | Qt::KeypadModifier)); +#else + QKeySequence(Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier)); +#endif ui->actionZoomOut->setShortcuts(zoomOutShortcuts); connect(ui->actionZoomOut, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomOut); QList zoomOriginalShortcuts; - zoomOriginalShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0)); - zoomOriginalShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0 + Qt::KeypadModifier)); + zoomOriginalShortcuts.append( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(Qt::ControlModifier | Qt::Key_0)); +#else + QKeySequence(Qt::ControlModifier + Qt::Key_0)); +#endif + zoomOriginalShortcuts.append( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(QKeyCombination(Qt::ControlModifier), Qt::Key_0 | Qt::KeypadModifier)); +#else + QKeySequence(Qt::ControlModifier + Qt::Key_0 + Qt::KeypadModifier)); +#endif ui->actionZoomOriginal->setShortcuts(zoomOriginalShortcuts); connect(ui->actionZoomOriginal, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomOriginal); QList zoomFitBestShortcuts; - zoomFitBestShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Equal)); + zoomFitBestShortcuts.append( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(Qt::ControlModifier | Qt::Key_Equal)); +#else + QKeySequence(Qt::ControlModifier + Qt::Key_Equal)); +#endif ui->actionZoomFitBest->setShortcuts(zoomFitBestShortcuts); connect(ui->actionZoomFitBest, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomFitBest); diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index de60dc241..70bfee8be 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -2899,36 +2899,71 @@ void MainWindow::ToolBarTools() QList zoomInShortcuts; zoomInShortcuts.append(QKeySequence(QKeySequence::ZoomIn)); - zoomInShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Plus + Qt::KeypadModifier)); + zoomInShortcuts.append( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(QKeyCombination(Qt::ControlModifier), Qt::Key_Plus | Qt::KeypadModifier)); +#else + QKeySequence(Qt::ControlModifier + Qt::Key_Plus + Qt::KeypadModifier)); +#endif ui->actionZoomIn->setShortcuts(zoomInShortcuts); connect(ui->actionZoomIn, &QAction::triggered, ui->view, &VMainGraphicsView::ZoomIn); QList zoomOutShortcuts; zoomOutShortcuts.append(QKeySequence(QKeySequence::ZoomOut)); - zoomOutShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier)); + zoomOutShortcuts.append( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(QKeyCombination(Qt::ControlModifier), Qt::Key_Minus | Qt::KeypadModifier)); +#else + QKeySequence(Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier)); +#endif ui->actionZoomOut->setShortcuts(zoomOutShortcuts); connect(ui->actionZoomOut, &QAction::triggered, ui->view, &VMainGraphicsView::ZoomOut); QList zoomOriginalShortcuts; - zoomOriginalShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0)); - zoomOriginalShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0 + Qt::KeypadModifier)); + zoomOriginalShortcuts.append( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(Qt::ControlModifier | Qt::Key_0)); +#else + QKeySequence(Qt::ControlModifier + Qt::Key_0)); +#endif + zoomOriginalShortcuts.append( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(QKeyCombination(Qt::ControlModifier), Qt::Key_0 | Qt::KeypadModifier)); +#else + QKeySequence(Qt::ControlModifier + Qt::Key_0 + Qt::KeypadModifier)); +#endif ui->actionZoomOriginal->setShortcuts(zoomOriginalShortcuts); connect(ui->actionZoomOriginal, &QAction::triggered, ui->view, &VMainGraphicsView::ZoomOriginal); QList zoomFitBestShortcuts; - zoomFitBestShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Equal)); + zoomFitBestShortcuts.append( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(Qt::ControlModifier | Qt::Key_Equal)); +#else + QKeySequence(Qt::ControlModifier + Qt::Key_Equal)); +#endif ui->actionZoomFitBest->setShortcuts(zoomFitBestShortcuts); connect(ui->actionZoomFitBest, &QAction::triggered, ui->view, &VMainGraphicsView::ZoomFitBest); QList zoomFitBestCurrentShortcuts; - zoomFitBestCurrentShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_M)); + zoomFitBestCurrentShortcuts.append( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(Qt::ControlModifier | Qt::Key_M)); +#else + QKeySequence(Qt::ControlModifier + Qt::Key_M)); +#endif ui->actionZoomFitBestCurrent->setShortcuts(zoomFitBestCurrentShortcuts); connect(ui->actionZoomFitBestCurrent, &QAction::triggered, this, &MainWindow::ZoomFitBestCurrent); connect(ui->actionPreviousPatternPiece, &QAction::triggered, this, &MainWindow::PreviousPatternPiece); connect(ui->actionNextPatternPiece, &QAction::triggered, this, &MainWindow::NextPatternPiece); - ui->actionIncreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Plus)); + ui->actionIncreaseLabelFont->setShortcut( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(Qt::ShiftModifier | Qt::Key_Plus)); +#else + QKeySequence(Qt::ShiftModifier + Qt::Key_Plus)); +#endif connect(ui->actionIncreaseLabelFont, &QAction::triggered, this, [this]() { VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); @@ -2944,7 +2979,12 @@ void MainWindow::ToolBarTools() } }); - ui->actionDecreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Minus)); + ui->actionDecreaseLabelFont->setShortcut( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(Qt::ShiftModifier | Qt::Key_Minus)); +#else + QKeySequence(Qt::ShiftModifier + Qt::Key_Minus)); +#endif connect(ui->actionDecreaseLabelFont, &QAction::triggered, this, [this]() { VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); @@ -2960,7 +3000,12 @@ void MainWindow::ToolBarTools() } }); - ui->actionOriginalLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_0)); + ui->actionOriginalLabelFont->setShortcut( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(Qt::ShiftModifier | Qt::Key_0)); +#else + QKeySequence(Qt::ShiftModifier + Qt::Key_0)); +#endif connect(ui->actionOriginalLabelFont, &QAction::triggered, this, [this]() { VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); @@ -2976,7 +3021,12 @@ void MainWindow::ToolBarTools() } }); - ui->actionHideLabels->setShortcut(QKeySequence(Qt::AltModifier + Qt::Key_L)); + ui->actionHideLabels->setShortcut( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QKeySequence(Qt::AltModifier | Qt::Key_L)); +#else + QKeySequence(Qt::AltModifier + Qt::Key_L)); +#endif ui->actionHideLabels->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->GetHideLabels()); connect(ui->actionHideLabels, &QAction::triggered, this, [this](bool checked) {