Commit 841847cd authored by sylvanbasilisk's avatar sylvanbasilisk
Browse files

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.
parent 040d9d15
......@@ -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;
}
......@@ -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; }
};
......@@ -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()));
......
......@@ -80,7 +80,6 @@ private:
DeckListModel *deckModel;
QTreeView *databaseView;
KeySignals dbViewKeySignals;
QTreeView *deckView;
KeySignals deckViewKeySignals;
CardFrame *cardInfo;
......
Supports Markdown
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