update to hotkey settings in deck editor tab

removed LEFT/RIGHT increment/decrement while
the card database/quicksearch edit have focus.
LEFT/RIGHT increment/decrement remains while the
deck view has focus.

also, now the card database delegates focus the
quicksearch editor so that any characters typed
while the card database has focus will narrow
the search down using the quicksearch filter.

`control`+`alt`+`-`/`=` now increment/decrement
the mainboard and `control`+`alt`+`[`/`]` now
increment/decrement the sideboard (alt could not
be used alone as OSX inserts special characters
using alt.
This commit is contained in:
sylvanbasilisk 2014-04-24 20:17:21 +00:00
parent 040d9d15a3
commit 841847cda4
4 changed files with 47 additions and 44 deletions

View file

@ -11,39 +11,55 @@ bool KeySignals::eventFilter(QObject * /*object*/, QEvent *event) {
switch(kevent->key()) { switch(kevent->key()) {
case Qt::Key_Return: case Qt::Key_Return:
case Qt::Key_Enter: 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(); emit onCtrlEnter();
else else
emit onEnter(); emit onEnter();
break; break;
case Qt::Key_Right: case Qt::Key_Right:
if(kevent->modifiers() & Qt::ControlModifier) emit onRight();
emit onCtrlRight();
else
emit onRight();
if(!filterLROn)
return false;
break; break;
case Qt::Key_Left: case Qt::Key_Left:
if(kevent->modifiers() & Qt::ControlModifier) emit onLeft();
emit onCtrlLeft();
else
emit onLeft();
if(!filterLROn)
return false;
break; break;
case Qt::Key_Delete: case Qt::Key_Delete:
case Qt::Key_Backspace: case Qt::Key_Backspace:
emit onDelete(); emit onDelete();
if(!filterDeleteOn) break;
return false; 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; break;
default: default:
return false; return false;
} }
return true; return false;
} }

View file

@ -4,27 +4,18 @@
class KeySignals : public QObject { class KeySignals : public QObject {
Q_OBJECT Q_OBJECT
private:
bool filterDeleteOn;
bool filterLROn;
signals: signals:
void onEnter(); void onEnter();
void onCtrlEnter(); void onCtrlEnter();
void onCtrlAltEnter();
void onLeft(); void onLeft();
void onCtrlLeft();
void onRight(); void onRight();
void onCtrlRight();
void onDelete(); void onDelete();
void onCtrlAltMinus();
void onCtrlAltEqual();
void onCtrlAltLBracket();
void onCtrlAltRBracket();
protected: protected:
virtual bool eventFilter(QObject *, QEvent *event); virtual bool eventFilter(QObject *, QEvent *event);
public:
KeySignals()
: filterDeleteOn(true)
, filterLROn(true)
{}
void filterDelete(bool on) { filterDeleteOn = on; }
void filterLeftRight(bool on) { filterLROn = on; }
}; };

View file

@ -54,15 +54,17 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
searchLabel = new QLabel(); searchLabel = new QLabel();
searchEdit = new SearchLineEdit; searchEdit = new SearchLineEdit;
searchLabel->setBuddy(searchEdit); searchLabel->setBuddy(searchEdit);
setFocusProxy(searchEdit);
setFocusPolicy(Qt::ClickFocus);
searchKeySignals.filterDelete(false);
searchEdit->installEventFilter(&searchKeySignals); searchEdit->installEventFilter(&searchKeySignals);
connect(searchEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateSearch(const QString &))); connect(searchEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateSearch(const QString &)));
connect(&searchKeySignals, SIGNAL(onEnter()), this, SLOT(actAddCard())); connect(&searchKeySignals, SIGNAL(onEnter()), this, SLOT(actAddCard()));
connect(&searchKeySignals, SIGNAL(onRight()), this, SLOT(actAddCard())); connect(&searchKeySignals, SIGNAL(onCtrlAltEqual()), this, SLOT(actAddCard()));
connect(&searchKeySignals, SIGNAL(onCtrlRight()), this, SLOT(actAddCardToSideboard())); connect(&searchKeySignals, SIGNAL(onCtrlAltRBracket()), this, SLOT(actAddCardToSideboard()));
connect(&searchKeySignals, SIGNAL(onLeft()), this, SLOT(actDecrementCard())); connect(&searchKeySignals, SIGNAL(onCtrlAltMinus()), this, SLOT(actDecrementCard()));
connect(&searchKeySignals, SIGNAL(onCtrlLeft()), this, SLOT(actDecrementCardFromSideboard())); connect(&searchKeySignals, SIGNAL(onCtrlAltLBracket()), this, SLOT(actDecrementCardFromSideboard()));
connect(&searchKeySignals, SIGNAL(onCtrlAltEnter()), this, SLOT(actAddCardToSideboard()));
connect(&searchKeySignals, SIGNAL(onCtrlEnter()), this, SLOT(actAddCardToSideboard())); connect(&searchKeySignals, SIGNAL(onCtrlEnter()), this, SLOT(actAddCardToSideboard()));
QToolBar *deckEditToolBar = new QToolBar; QToolBar *deckEditToolBar = new QToolBar;
@ -81,6 +83,7 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
databaseDisplayModel->sort(0, Qt::AscendingOrder); databaseDisplayModel->sort(0, Qt::AscendingOrder);
databaseView = new QTreeView(); databaseView = new QTreeView();
databaseView->setFocusProxy(searchEdit);
databaseView->setModel(databaseDisplayModel); databaseView->setModel(databaseDisplayModel);
databaseView->setUniformRowHeights(true); databaseView->setUniformRowHeights(true);
databaseView->setRootIsDecorated(false); databaseView->setRootIsDecorated(false);
@ -90,13 +93,6 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
databaseView->resizeColumnToContents(0); databaseView->resizeColumnToContents(0);
connect(databaseView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateCardInfoLeft(const QModelIndex &, const QModelIndex &))); 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())); 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); searchEdit->setTreeView(databaseView);
QVBoxLayout *leftFrame = new QVBoxLayout; QVBoxLayout *leftFrame = new QVBoxLayout;
@ -137,10 +133,11 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
deckView->setModel(deckModel); deckView->setModel(deckModel);
deckView->setUniformRowHeights(true); deckView->setUniformRowHeights(true);
deckView->header()->setResizeMode(QHeaderView::ResizeToContents); deckView->header()->setResizeMode(QHeaderView::ResizeToContents);
deckViewKeySignals.filterLeftRight(false);
deckView->installEventFilter(&deckViewKeySignals); deckView->installEventFilter(&deckViewKeySignals);
connect(deckView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateCardInfoRight(const QModelIndex &, const QModelIndex &))); 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(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(onRight()), this, SLOT(actIncrement()));
connect(&deckViewKeySignals, SIGNAL(onLeft()), this, SLOT(actDecrement())); connect(&deckViewKeySignals, SIGNAL(onLeft()), this, SLOT(actDecrement()));
connect(&deckViewKeySignals, SIGNAL(onDelete()), this, SLOT(actRemoveCard())); connect(&deckViewKeySignals, SIGNAL(onDelete()), this, SLOT(actRemoveCard()));

View file

@ -80,7 +80,6 @@ private:
DeckListModel *deckModel; DeckListModel *deckModel;
QTreeView *databaseView; QTreeView *databaseView;
KeySignals dbViewKeySignals;
QTreeView *deckView; QTreeView *deckView;
KeySignals deckViewKeySignals; KeySignals deckViewKeySignals;
CardFrame *cardInfo; CardFrame *cardInfo;