Commit fa044d7a authored by Luigi Toscano's avatar Luigi Toscano

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.
parent 4fe49329
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API #define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API
#include <libkdegamesprivate/kgamethemeselector.h> #include <libkdegamesprivate/kgamethemeselector.h>
#include <KShortcut> #include <QKeySequence>
#include <KUrl> #include <KUrl>
#include <kmessagebox.h> #include <kmessagebox.h>
#include <KLocalizedString> #include <KLocalizedString>
...@@ -461,7 +461,7 @@ void KSudoku::setupActions() ...@@ -461,7 +461,7 @@ void KSudoku::setupActions()
m_gameActions = new ksudoku::GameActions(actionCollection()); m_gameActions = new ksudoku::GameActions(actionCollection());
m_gameActions->init(); m_gameActions->init();
KShortcut shortcut; QKeySequence shortcut;
setAcceptDrops(true); setAcceptDrops(true);
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <QAction> #include <QAction>
#include <KActionCollection> #include <KActionCollection>
#include <QSignalMapper> #include <QSignalMapper>
#include <KShortcut> #include <QKeySequence>
namespace ksudoku { namespace ksudoku {
GameActions::GameActions(KActionCollection* collection) { GameActions::GameActions(KActionCollection* collection) {
...@@ -51,8 +51,9 @@ void GameActions::init() { ...@@ -51,8 +51,9 @@ void GameActions::init() {
/* Qt::Key_Asterisk, */ Qt::Key_Plus, Qt::Key_Space, /* Qt::Key_Asterisk, */ Qt::Key_Plus, Qt::Key_Space,
Qt::Key_Return}; Qt::Key_Return};
QAction * a; QAction * a;
//QT5 KShortcut shortcut; QList<QKeySequence> shortcuts;
for(int i = 0; i < 25; ++i) { for(int i = 0; i < 31; ++i) {
shortcuts.clear();
a = new QAction(this); a = new QAction(this);
m_collection->addAction(QString("val-select%1").arg(i+1,2,10,QChar('0')), a); 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)); a->setText(i18n("Select %1 (%2)", QChar('a'+i), i+1));
...@@ -63,38 +64,35 @@ void GameActions::init() { ...@@ -63,38 +64,35 @@ void GameActions::init() {
a = new QAction(this); a = new QAction(this);
m_collection->addAction(QString("val-enter%1").arg(i+1,2,10,QChar('0')), a); 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)); a->setText(i18n("Enter %1 (%2)", QChar('a'+i), i+1));
#if 0 //QT5 if (i < 25) {
shortcut = a->shortcut(); // Keys A to Y, for Sudoku puzzles.
if (i < 25) {; shortcuts << QKeySequence(Qt::Key_A + i);
// Keys A to Y, for Sudoku puzzles.
shortcut.setPrimary( Qt::Key_A + i);
} }
else { else {
// Extras for keying in Mathdoku and Killer Sudoku puzzles. // Extras for keying in Mathdoku and Killer Sudoku puzzles.
shortcut.setPrimary (extras[i - 25]); shortcuts << QKeySequence(extras[i - 25]);
} }
if(i < 9) { if (i < 9) {
// Keys 1 to 9, for puzzles of order 9 or less. // Keys 1 to 9, for puzzles of order 9 or less.
shortcut.setAlternate( Qt::Key_1 + i); shortcuts << QKeySequence(Qt::Key_1 + i);
} }
a->setShortcut(shortcut); m_collection->setDefaultShortcuts(a, shortcuts);
#endif
m_enterValueMapper->setMapping(a, i+1); m_enterValueMapper->setMapping(a, i+1);
connect(a, SIGNAL(triggered(bool)), m_enterValueMapper, SLOT(map())); connect(a, SIGNAL(triggered(bool)), m_enterValueMapper, SLOT(map()));
m_actions << a; m_actions << a;
if (i >= 25) { if (i >= 25) {
continue; continue;
} }
shortcuts.clear();
a = new QAction(this); a = new QAction(this);
m_collection->addAction(QString("val-mark%1").arg(i+1,2,10,QChar('0')), a); 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)); a->setText(i18n("Mark %1 (%2)", QChar('a'+i), i+1));
//QT5 shortcut = a->shortcut(); shortcuts << QKeySequence(Qt::ShiftModifier | (Qt::Key_A + i));
//QT5 shortcut.setPrimary( QKeySequence(Qt::ShiftModifier | Qt::Key_A + i));
if(i < 9) { 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); m_markValueMapper->setMapping(a, i+1);
connect(a, SIGNAL(triggered(bool)), m_markValueMapper, SLOT(map())); connect(a, SIGNAL(triggered(bool)), m_markValueMapper, SLOT(map()));
m_actions << a; m_actions << a;
...@@ -131,10 +129,9 @@ void GameActions::init() { ...@@ -131,10 +129,9 @@ void GameActions::init() {
a = new QAction(this); a = new QAction(this);
m_collection->addAction("move_clear_cell", a); m_collection->addAction("move_clear_cell", a);
a->setText(i18n("Clear Cell")); a->setText(i18n("Clear Cell"));
//QT5 shortcut = a->shortcut(); m_collection->setDefaultShortcuts(a, QList<QKeySequence>()
//QT5 shortcut.setPrimary(Qt::Key_Backspace); << QKeySequence(Qt::Key_Backspace)
//QT5 shortcut.setAlternate(Qt::Key_Delete); << QKeySequence(Qt::Key_Delete));
//QT5 a->setShortcut(shortcut);
connect(a, SIGNAL(triggered(bool)), SLOT(clearValue())); connect(a, SIGNAL(triggered(bool)), SLOT(clearValue()));
m_actions << a; m_actions << a;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment