Changeset View
Changeset View
Standalone View
Standalone View
app/viewmainpage.cpp
Show All 37 Lines | |||||
38 | #include <KActivities/ResourceInstance> | 38 | #include <KActivities/ResourceInstance> | ||
39 | 39 | | |||
40 | // Local | 40 | // Local | ||
41 | #include "fileoperations.h" | 41 | #include "fileoperations.h" | ||
42 | #include <gvcore.h> | 42 | #include <gvcore.h> | ||
43 | #include "splitter.h" | 43 | #include "splitter.h" | ||
44 | #include <lib/document/document.h> | 44 | #include <lib/document/document.h> | ||
45 | #include <lib/documentview/abstractdocumentviewadapter.h> | 45 | #include <lib/documentview/abstractdocumentviewadapter.h> | ||
46 | #include <lib/documentview/abstractrasterimageviewtool.h> | ||||
46 | #include <lib/documentview/documentview.h> | 47 | #include <lib/documentview/documentview.h> | ||
47 | #include <lib/documentview/documentviewcontainer.h> | 48 | #include <lib/documentview/documentviewcontainer.h> | ||
48 | #include <lib/documentview/documentviewcontroller.h> | 49 | #include <lib/documentview/documentviewcontroller.h> | ||
49 | #include <lib/documentview/documentviewsynchronizer.h> | 50 | #include <lib/documentview/documentviewsynchronizer.h> | ||
50 | #include <lib/gvdebug.h> | 51 | #include <lib/gvdebug.h> | ||
51 | #include <lib/gwenviewconfig.h> | 52 | #include <lib/gwenviewconfig.h> | ||
52 | #include <lib/paintutils.h> | 53 | #include <lib/paintutils.h> | ||
53 | #include <lib/semanticinfo/sorteddirmodel.h> | 54 | #include <lib/semanticinfo/sorteddirmodel.h> | ||
▲ Show 20 Lines • Show All 344 Lines • ▼ Show 20 Line(s) | 397 | { | |||
398 | d->mDirModelToBarModelProxyMapper = 0; // Initialized later | 399 | d->mDirModelToBarModelProxyMapper = 0; // Initialized later | ||
399 | d->mSlideShow = slideShow; | 400 | d->mSlideShow = slideShow; | ||
400 | d->mActionCollection = actionCollection; | 401 | d->mActionCollection = actionCollection; | ||
401 | d->mGvCore = gvCore; | 402 | d->mGvCore = gvCore; | ||
402 | d->mFullScreenMode = false; | 403 | d->mFullScreenMode = false; | ||
403 | d->mCompareMode = false; | 404 | d->mCompareMode = false; | ||
404 | d->mThumbnailBarVisibleBeforeFullScreen = false; | 405 | d->mThumbnailBarVisibleBeforeFullScreen = false; | ||
405 | 406 | | |||
406 | QShortcut* goToBrowseModeShortcut = new QShortcut(this); | 407 | QShortcut* enterKeyShortcut = new QShortcut(Qt::Key_Return, this); | ||
407 | goToBrowseModeShortcut->setKey(Qt::Key_Return); | 408 | connect(enterKeyShortcut, &QShortcut::activated, this, &ViewMainPage::slotEnterPressed); | ||
408 | connect(goToBrowseModeShortcut, &QShortcut::activated, this, &ViewMainPage::goToBrowseModeRequested); | 409 | QShortcut* escapeKeyShortcut = new QShortcut(Qt::Key_Escape, this); | ||
410 | connect(escapeKeyShortcut, &QShortcut::activated, this, &ViewMainPage::slotEscapePressed); | ||||
409 | 411 | | |||
410 | d->setupToolContainer(); | 412 | d->setupToolContainer(); | ||
411 | d->setupStatusBar(); | 413 | d->setupStatusBar(); | ||
412 | 414 | | |||
413 | d->setupAdapterContainer(); | 415 | d->setupAdapterContainer(); | ||
414 | 416 | | |||
415 | d->setupThumbnailBar(); | 417 | d->setupThumbnailBar(); | ||
416 | 418 | | |||
▲ Show 20 Lines • Show All 314 Lines • ▼ Show 20 Line(s) | 730 | { | |||
731 | d->mDocumentViews.clear(); | 733 | d->mDocumentViews.clear(); | ||
732 | } | 734 | } | ||
733 | 735 | | |||
734 | void ViewMainPage::slotViewFocused(DocumentView* view) | 736 | void ViewMainPage::slotViewFocused(DocumentView* view) | ||
735 | { | 737 | { | ||
736 | d->setCurrentView(view); | 738 | d->setCurrentView(view); | ||
737 | } | 739 | } | ||
738 | 740 | | |||
741 | void ViewMainPage::slotEnterPressed() | ||||
742 | { | ||||
743 | DocumentView *view = d->currentView(); | ||||
744 | if (view) { | ||||
745 | AbstractRasterImageViewTool *tool = view->currentTool(); | ||||
746 | if (tool) { | ||||
gateau: Maybe this could go in AbstractRasterImageViewTool as a `bool onEnterPressed()` method, which… | |||||
747 | QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier); | ||||
748 | tool->keyPressEvent(&event); | ||||
749 | if (event.isAccepted()) { | ||||
750 | return; | ||||
751 | } | ||||
752 | } | ||||
753 | } | ||||
754 | emit goToBrowseModeRequested(); | ||||
755 | } | ||||
756 | | ||||
757 | void ViewMainPage::slotEscapePressed() | ||||
758 | { | ||||
759 | DocumentView *view = d->currentView(); | ||||
760 | if (view) { | ||||
761 | AbstractRasterImageViewTool *tool = view->currentTool(); | ||||
762 | if (tool) { | ||||
gateau: Same here with a `bool onEscapePressed()` method | |||||
763 | QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier); | ||||
764 | tool->keyPressEvent(&event); | ||||
765 | if (event.isAccepted()) { | ||||
766 | return; | ||||
767 | } | ||||
768 | } | ||||
769 | } | ||||
770 | emit goToBrowseModeRequested(); | ||||
771 | } | ||||
772 | | ||||
739 | void ViewMainPage::trashView(DocumentView* view) | 773 | void ViewMainPage::trashView(DocumentView* view) | ||
740 | { | 774 | { | ||
741 | QUrl url = view->url(); | 775 | QUrl url = view->url(); | ||
742 | deselectView(view); | 776 | deselectView(view); | ||
743 | FileOperations::trash(QList<QUrl>() << url, this); | 777 | FileOperations::trash(QList<QUrl>() << url, this); | ||
744 | } | 778 | } | ||
745 | 779 | | |||
746 | void ViewMainPage::deselectView(DocumentView* view) | 780 | void ViewMainPage::deselectView(DocumentView* view) | ||
Show All 34 Lines |
Maybe this could go in AbstractRasterImageViewTool as a bool onEnterPressed() method, which would return true if the tool has accepted the Enter key press?