diff --git a/cockatrice/src/keysignals.cpp b/cockatrice/src/keysignals.cpp index 326b006ea..5db58cb5e 100644 --- a/cockatrice/src/keysignals.cpp +++ b/cockatrice/src/keysignals.cpp @@ -11,39 +11,55 @@ bool KeySignals::eventFilter(QObject * /*object*/, QEvent *event) { switch(kevent->key()) { case Qt::Key_Return: case Qt::Key_Enter: - if(kevent->modifiers() & Qt::ControlModifier) + if (kevent->modifiers().testFlag(Qt::AltModifier) + && kevent->modifiers().testFlag(Qt::ControlModifier) ) + emit onCtrlAltEnter(); + else if (kevent->modifiers() & Qt::ControlModifier) emit onCtrlEnter(); else emit onEnter(); + break; case Qt::Key_Right: - if(kevent->modifiers() & Qt::ControlModifier) - emit onCtrlRight(); - else - emit onRight(); + emit onRight(); - if(!filterLROn) - return false; break; case Qt::Key_Left: - if(kevent->modifiers() & Qt::ControlModifier) - emit onCtrlLeft(); - else - emit onLeft(); + emit onLeft(); - if(!filterLROn) - return false; break; case Qt::Key_Delete: case Qt::Key_Backspace: emit onDelete(); - if(!filterDeleteOn) - return false; + break; + case Qt::Key_Minus: + if (kevent->modifiers().testFlag(Qt::AltModifier) + && kevent->modifiers().testFlag(Qt::ControlModifier) ) + emit onCtrlAltMinus(); + + break; + case Qt::Key_Equal: + if (kevent->modifiers().testFlag(Qt::AltModifier) + && kevent->modifiers().testFlag(Qt::ControlModifier) ) + emit onCtrlAltEqual(); + + break; + case Qt::Key_BracketLeft: + if (kevent->modifiers().testFlag(Qt::AltModifier) + && kevent->modifiers().testFlag(Qt::ControlModifier) ) + emit onCtrlAltLBracket(); + + break; + case Qt::Key_BracketRight: + if (kevent->modifiers().testFlag(Qt::AltModifier) + && kevent->modifiers().testFlag(Qt::ControlModifier) ) + emit onCtrlAltRBracket(); + break; default: return false; } - return true; + return false; } diff --git a/cockatrice/src/keysignals.h b/cockatrice/src/keysignals.h index 78ddf1e20..23a07b778 100644 --- a/cockatrice/src/keysignals.h +++ b/cockatrice/src/keysignals.h @@ -4,27 +4,18 @@ class KeySignals : public QObject { Q_OBJECT -private: - bool filterDeleteOn; - bool filterLROn; - signals: void onEnter(); void onCtrlEnter(); + void onCtrlAltEnter(); void onLeft(); - void onCtrlLeft(); void onRight(); - void onCtrlRight(); void onDelete(); + void onCtrlAltMinus(); + void onCtrlAltEqual(); + void onCtrlAltLBracket(); + void onCtrlAltRBracket(); protected: virtual bool eventFilter(QObject *, QEvent *event); - -public: - KeySignals() - : filterDeleteOn(true) - , filterLROn(true) - {} - void filterDelete(bool on) { filterDeleteOn = on; } - void filterLeftRight(bool on) { filterLROn = on; } }; diff --git a/cockatrice/src/tab_deck_editor.cpp b/cockatrice/src/tab_deck_editor.cpp index 075ee918c..91c8819e6 100644 --- a/cockatrice/src/tab_deck_editor.cpp +++ b/cockatrice/src/tab_deck_editor.cpp @@ -54,15 +54,17 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent) searchLabel = new QLabel(); searchEdit = new SearchLineEdit; searchLabel->setBuddy(searchEdit); + setFocusProxy(searchEdit); + setFocusPolicy(Qt::ClickFocus); - searchKeySignals.filterDelete(false); searchEdit->installEventFilter(&searchKeySignals); connect(searchEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateSearch(const QString &))); connect(&searchKeySignals, SIGNAL(onEnter()), this, SLOT(actAddCard())); - connect(&searchKeySignals, SIGNAL(onRight()), this, SLOT(actAddCard())); - connect(&searchKeySignals, SIGNAL(onCtrlRight()), this, SLOT(actAddCardToSideboard())); - connect(&searchKeySignals, SIGNAL(onLeft()), this, SLOT(actDecrementCard())); - connect(&searchKeySignals, SIGNAL(onCtrlLeft()), this, SLOT(actDecrementCardFromSideboard())); + connect(&searchKeySignals, SIGNAL(onCtrlAltEqual()), this, SLOT(actAddCard())); + connect(&searchKeySignals, SIGNAL(onCtrlAltRBracket()), this, SLOT(actAddCardToSideboard())); + connect(&searchKeySignals, SIGNAL(onCtrlAltMinus()), this, SLOT(actDecrementCard())); + connect(&searchKeySignals, SIGNAL(onCtrlAltLBracket()), this, SLOT(actDecrementCardFromSideboard())); + connect(&searchKeySignals, SIGNAL(onCtrlAltEnter()), this, SLOT(actAddCardToSideboard())); connect(&searchKeySignals, SIGNAL(onCtrlEnter()), this, SLOT(actAddCardToSideboard())); QToolBar *deckEditToolBar = new QToolBar; @@ -81,6 +83,7 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent) databaseDisplayModel->sort(0, Qt::AscendingOrder); databaseView = new QTreeView(); + databaseView->setFocusProxy(searchEdit); databaseView->setModel(databaseDisplayModel); databaseView->setUniformRowHeights(true); databaseView->setRootIsDecorated(false); @@ -90,13 +93,6 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent) databaseView->resizeColumnToContents(0); connect(databaseView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateCardInfoLeft(const QModelIndex &, const QModelIndex &))); connect(databaseView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(actAddCard())); - databaseView->installEventFilter(&dbViewKeySignals); - connect(&dbViewKeySignals, SIGNAL(onEnter()), this, SLOT(actAddCard())); - connect(&dbViewKeySignals, SIGNAL(onRight()), this, SLOT(actAddCard())); - connect(&dbViewKeySignals, SIGNAL(onCtrlRight()), this, SLOT(actAddCardToSideboard())); - connect(&dbViewKeySignals, SIGNAL(onLeft()), this, SLOT(actDecrementCard())); - connect(&dbViewKeySignals, SIGNAL(onCtrlLeft()), this, SLOT(actDecrementCardFromSideboard())); - connect(&dbViewKeySignals, SIGNAL(onCtrlEnter()), this, SLOT(actAddCardToSideboard())); searchEdit->setTreeView(databaseView); QVBoxLayout *leftFrame = new QVBoxLayout; @@ -137,10 +133,11 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent) deckView->setModel(deckModel); deckView->setUniformRowHeights(true); deckView->header()->setResizeMode(QHeaderView::ResizeToContents); - deckViewKeySignals.filterLeftRight(false); deckView->installEventFilter(&deckViewKeySignals); connect(deckView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateCardInfoRight(const QModelIndex &, const QModelIndex &))); connect(&deckViewKeySignals, SIGNAL(onEnter()), this, SLOT(actIncrement())); + connect(&deckViewKeySignals, SIGNAL(onCtrlAltEqual()), this, SLOT(actIncrement())); + connect(&deckViewKeySignals, SIGNAL(onCtrlAltMinus()), this, SLOT(actDecrement())); connect(&deckViewKeySignals, SIGNAL(onRight()), this, SLOT(actIncrement())); connect(&deckViewKeySignals, SIGNAL(onLeft()), this, SLOT(actDecrement())); connect(&deckViewKeySignals, SIGNAL(onDelete()), this, SLOT(actRemoveCard())); diff --git a/cockatrice/src/tab_deck_editor.h b/cockatrice/src/tab_deck_editor.h index bcdca8d31..3acf1d15e 100644 --- a/cockatrice/src/tab_deck_editor.h +++ b/cockatrice/src/tab_deck_editor.h @@ -80,7 +80,6 @@ private: DeckListModel *deckModel; QTreeView *databaseView; - KeySignals dbViewKeySignals; QTreeView *deckView; KeySignals deckViewKeySignals; CardFrame *cardInfo;