From 13c853d92fc23e756f723765b3ce9d1aa591094f Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sat, 23 Mar 2013 20:30:52 -0400 Subject: [PATCH] Qt5: QKeySequence doesn't convert to int anymore Thus uses in a switch construct do not compile anymore. This required a careful conversion to a cascaded if..else if construct. --- src/mainimpl.cpp | 103 +++++++++++++++++++++++++------------------------------ 1 file changed, 47 insertions(+), 56 deletions(-) diff --git a/src/mainimpl.cpp b/src/mainimpl.cpp index 658cd01..7a4d612 100644 --- a/src/mainimpl.cpp +++ b/src/mainimpl.cpp @@ -942,64 +942,55 @@ void MainImpl::setupShortcuts() { void MainImpl::shortCutActivated() { QShortcut* se = dynamic_cast(sender()); - if (!se) - return; - - bool isKey_P = false; - switch (se->key()) { + if (se) { + const QKeySequence& key = se->key(); - case Qt::Key_I: - rv->tab()->listViewLog->on_keyUp(); - break; - case Qt::Key_K: - case Qt::Key_N: - rv->tab()->listViewLog->on_keyDown(); - break; - case Qt::SHIFT | Qt::Key_Up: - goMatch(-1); - break; - case Qt::SHIFT | Qt::Key_Down: - goMatch(1); - break; - case Qt::Key_Left: - ActBack_activated(); - break; - case Qt::Key_Right: - ActForward_activated(); - break; - case Qt::CTRL | Qt::Key_Plus: - adjustFontSize(1); - break; - case Qt::CTRL | Qt::Key_Minus: - adjustFontSize(-1); - break; - case Qt::Key_U: - scrollTextEdit(-18); - break; - case Qt::Key_D: - scrollTextEdit(18); - break; - case Qt::Key_Delete: - case Qt::Key_B: - case Qt::Key_Backspace: - scrollTextEdit(-1); - break; - case Qt::Key_Space: - scrollTextEdit(1); - break; - case Qt::Key_R: - tabWdg->setCurrentWidget(rv->tabPage()); - break; - case Qt::Key_P: - isKey_P = true; - case Qt::Key_F: { - QWidget* cp = tabWdg->currentWidget(); - Domain* d = isKey_P ? static_cast(firstTab(cp)) : - static_cast(firstTab(cp)); - if (d) - tabWdg->setCurrentWidget(d->tabPage()); } - break; + if (key == Qt::Key_I) { + rv->tab()->listViewLog->on_keyUp(); + } + else if (key == Qt::Key_K or key == Qt::Key_N) { + rv->tab()->listViewLog->on_keyDown(); + } + else if (key == Qt::SHIFT | Qt::Key_Up) { + goMatch(-1); + } + else if (key == Qt::SHIFT | Qt::Key_Down) { + goMatch(1); + } + else if (key == Qt::Key_Left) { + ActBack_activated(); + } + else if (key == Qt::Key_Right) { + ActForward_activated(); + } + else if (key == Qt::CTRL | Qt::Key_Plus) { + adjustFontSize(1); //TODO replace magic constant + } + else if (key == Qt::CTRL | Qt::Key_Minus) { + adjustFontSize(-1); //TODO replace magic constant + } + else if (key == Qt::Key_U) { + scrollTextEdit(-18); //TODO replace magic constant + } + else if (key == Qt::Key_D) { + scrollTextEdit(18); //TODO replace magic constant + } + else if (key == Qt::Key_Delete or key == Qt::Key_B or key == Qt::Key_Backspace) { + scrollTextEdit(-1); //TODO replace magic constant + } + else if (key == Qt::Key_Space) { + scrollTextEdit(1); + } + else if (key == Qt::Key_R) { + tabWdg->setCurrentWidget(rv->tabPage()); + } + else if (key == Qt::Key_P or key == Qt::Key_F) { + QWidget* cp = tabWdg->currentWidget(); + Domain* d = key == Qt::Key_P? static_cast(firstTab(cp)) : + static_cast(firstTab(cp)); + if (d) tabWdg->setCurrentWidget(d->tabPage()); + } } } -- 2.11.4.GIT