summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuigi Toscano <[email protected]>2017-03-15 23:36:07 +0100
committerLuigi Toscano <[email protected]>2017-03-16 01:41:32 +0100
commitfa044d7a27299adb99354298e768c02260d491ad (patch)
treea163c34b6549de927b18829fa3a071ce67d06d61
parent4fe493295416100b27b8d27b9ad2bd5a3820944f (diff)
Port KShortcut to QKeySequence/KActionCollection
- use directly KActionCollection (as strongly suggested by the log messages; - increase back the upper bound of the loop which defines the keys to 32, as in the current master/kdelibs4: I lost it in a merge; - use the same indentation style as the rest of the code; - a bit more brackets when required.
-rw-r--r--src/gui/ksudoku.cpp4
-rw-r--r--src/gui/views/gameactions.cpp45
2 files changed, 23 insertions, 26 deletions
diff --git a/src/gui/ksudoku.cpp b/src/gui/ksudoku.cpp
index df1df31..0412cb5 100644
--- a/src/gui/ksudoku.cpp
+++ b/src/gui/ksudoku.cpp
@@ -43,7 +43,7 @@
#define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API
#include <libkdegamesprivate/kgamethemeselector.h>
-#include <KShortcut>
+#include <QKeySequence>
#include <KUrl>
#include <kmessagebox.h>
#include <KLocalizedString>
@@ -461,7 +461,7 @@ void KSudoku::setupActions()
m_gameActions = new ksudoku::GameActions(actionCollection());
m_gameActions->init();
- KShortcut shortcut;
+ QKeySequence shortcut;
setAcceptDrops(true);
diff --git a/src/gui/views/gameactions.cpp b/src/gui/views/gameactions.cpp
index beb0c03..52904b3 100644
--- a/src/gui/views/gameactions.cpp
+++ b/src/gui/views/gameactions.cpp
@@ -24,7 +24,7 @@
#include <QAction>
#include <KActionCollection>
#include <QSignalMapper>
-#include <KShortcut>
+#include <QKeySequence>
namespace ksudoku {
GameActions::GameActions(KActionCollection* collection) {
@@ -51,8 +51,9 @@ void GameActions::init() {
/* Qt::Key_Asterisk, */ Qt::Key_Plus, Qt::Key_Space,
Qt::Key_Return};
QAction * a;
- //QT5 KShortcut shortcut;
- for(int i = 0; i < 25; ++i) {
+ QList<QKeySequence> shortcuts;
+ for(int i = 0; i < 31; ++i) {
+ shortcuts.clear();
a = new QAction(this);
m_collection->addAction(QString("val-select%1").arg(i+1,2,10,QChar('0')), a);
a->setText(i18n("Select %1 (%2)", QChar('a'+i), i+1));
@@ -63,38 +64,35 @@ void GameActions::init() {
a = new QAction(this);
m_collection->addAction(QString("val-enter%1").arg(i+1,2,10,QChar('0')), a);
a->setText(i18n("Enter %1 (%2)", QChar('a'+i), i+1));
-#if 0 //QT5
- shortcut = a->shortcut();
- if (i < 25) {;
- // Keys A to Y, for Sudoku puzzles.
- shortcut.setPrimary( Qt::Key_A + i);
+ if (i < 25) {
+ // Keys A to Y, for Sudoku puzzles.
+ shortcuts << QKeySequence(Qt::Key_A + i);
}
else {
- // Extras for keying in Mathdoku and Killer Sudoku puzzles.
- shortcut.setPrimary (extras[i - 25]);
+ // Extras for keying in Mathdoku and Killer Sudoku puzzles.
+ shortcuts << QKeySequence(extras[i - 25]);
}
- if(i < 9) {
- // Keys 1 to 9, for puzzles of order 9 or less.
- shortcut.setAlternate( Qt::Key_1 + i);
+ if (i < 9) {
+ // Keys 1 to 9, for puzzles of order 9 or less.
+ shortcuts << QKeySequence(Qt::Key_1 + i);
}
- a->setShortcut(shortcut);
-#endif
+ m_collection->setDefaultShortcuts(a, shortcuts);
m_enterValueMapper->setMapping(a, i+1);
connect(a, SIGNAL(triggered(bool)), m_enterValueMapper, SLOT(map()));
m_actions << a;
if (i >= 25) {
- continue;
+ continue;
}
+ shortcuts.clear();
a = new QAction(this);
m_collection->addAction(QString("val-mark%1").arg(i+1,2,10,QChar('0')), a);
a->setText(i18n("Mark %1 (%2)", QChar('a'+i), i+1));
- //QT5 shortcut = a->shortcut();
- //QT5 shortcut.setPrimary( QKeySequence(Qt::ShiftModifier | Qt::Key_A + i));
+ shortcuts << QKeySequence(Qt::ShiftModifier | (Qt::Key_A + i));
if(i < 9) {
- //QT5 shortcut.setAlternate( QKeySequence(Qt::ShiftModifier | Qt::Key_1 + i));
+ shortcuts << QKeySequence(Qt::ShiftModifier | (Qt::Key_1 + i));
}
- //QT5 a->setShortcut(shortcut);
+ m_collection->setDefaultShortcuts(a, shortcuts);
m_markValueMapper->setMapping(a, i+1);
connect(a, SIGNAL(triggered(bool)), m_markValueMapper, SLOT(map()));
m_actions << a;
@@ -131,10 +129,9 @@ void GameActions::init() {
a = new QAction(this);
m_collection->addAction("move_clear_cell", a);
a->setText(i18n("Clear Cell"));
- //QT5 shortcut = a->shortcut();
- //QT5 shortcut.setPrimary(Qt::Key_Backspace);
- //QT5 shortcut.setAlternate(Qt::Key_Delete);
- //QT5 a->setShortcut(shortcut);
+ m_collection->setDefaultShortcuts(a, QList<QKeySequence>()
+ << QKeySequence(Qt::Key_Backspace)
+ << QKeySequence(Qt::Key_Delete));
connect(a, SIGNAL(triggered(bool)), SLOT(clearValue()));
m_actions << a;
}