Changeset View
Changeset View
Standalone View
Standalone View
app/viewmainpage.cpp
Show First 20 Lines • Show All 778 Lines • ▼ Show 20 Line(s) | 771 | if (view) { | |||
---|---|---|---|---|---|
779 | } | 779 | } | ||
780 | } | 780 | } | ||
781 | emit goToBrowseModeRequested(); | 781 | emit goToBrowseModeRequested(); | ||
782 | } | 782 | } | ||
783 | 783 | | |||
784 | bool ViewMainPage::eventFilter(QObject* watched, QEvent* event) | 784 | bool ViewMainPage::eventFilter(QObject* watched, QEvent* event) | ||
785 | { | 785 | { | ||
786 | if (event->type() == QEvent::ShortcutOverride) { | 786 | if (event->type() == QEvent::ShortcutOverride) { | ||
787 | const QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event); | 787 | const int key = static_cast<QKeyEvent*>(event)->key(); | ||
788 | if (keyEvent->key() == Qt::Key_Escape) { | 788 | if (key == Qt::Key_Space || key == Qt::Key_Escape) { | ||
muhlenpfordt: Any reason why you use `auto` instead of `int`? | |||||
I kinda wanted to be flexible to whatever enum Key might be changed to in a very distant future. Nevertheless, using int is also okay, in particular since on the right-hand side int is not mentioned explicitly yet. rkflx: I kinda wanted to be flexible to whatever `enum Key` might be changed to in a very distant… | |||||
789 | const DocumentView* view = d->currentView(); | 789 | const DocumentView* view = d->currentView(); | ||
790 | if (view) { | 790 | if (view) { | ||
791 | AbstractRasterImageViewTool* tool = view->currentTool(); | 791 | AbstractRasterImageViewTool* tool = view->currentTool(); | ||
792 | if (tool) { | 792 | if (tool) { | ||
793 | QKeyEvent toolKeyEvent(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier); | 793 | QKeyEvent toolKeyEvent(QEvent::KeyPress, key, Qt::NoModifier); | ||
794 | tool->keyPressEvent(&toolKeyEvent); | 794 | tool->keyPressEvent(&toolKeyEvent); | ||
795 | if (toolKeyEvent.isAccepted()) { | 795 | if (toolKeyEvent.isAccepted()) { | ||
796 | event->accept(); | 796 | event->accept(); | ||
797 | } | 797 | } | ||
798 | } | 798 | } | ||
799 | } | 799 | } | ||
800 | } | 800 | } | ||
801 | } | 801 | } | ||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |
Any reason why you use auto instead of int?