Commit 1e9a4482 authored by Peter Mühlenpfordt's avatar Peter Mühlenpfordt
Browse files

Exit fullscreen browse mode with Escape

Summary:
Previous versions of gwenview used {key Esc} to exit fullscreen mode.
By changing shortcut handling of {key Esc} this does not work anymore.
This patch adds an `eventFilter()` to leave fullscreen from browse
mode with {key Esc}.

BUG: 305659

Test Plan:
1. Open gwenview in browse mode
2. Switch to fullscreen mode (e.g. {key F11})
3. Press {key Esc}
-> Should switch back to windowed browse mode

Reviewers: ngraham, rkflx

Reviewed By: rkflx

Differential Revision: https://phabricator.kde.org/D10182
parent ba9fc33f
......@@ -76,6 +76,7 @@ struct BrowseMainPagePrivate : public Ui_BrowseMainPage
KSelectAction* mSortAction;
QActionGroup* mThumbnailDetailsActionGroup;
PreviewItemDelegate* mDelegate;
bool mFullScreenMode;
void setupWidgets()
{
......@@ -226,6 +227,7 @@ BrowseMainPage::BrowseMainPage(QWidget* parent, KActionCollection* actionCollect
d->mDirModel = gvCore->sortedDirModel();
d->mDocumentCount = 0;
d->mActionCollection = actionCollection;
d->mFullScreenMode = false;
d->setupWidgets();
d->setupActions(actionCollection);
d->setupFilterController();
......@@ -233,6 +235,8 @@ BrowseMainPage::BrowseMainPage(QWidget* parent, KActionCollection* actionCollect
loadConfig();
updateSortOrder();
updateThumbnailDetails();
installEventFilter(this);
}
BrowseMainPage::~BrowseMainPage()
......@@ -272,6 +276,19 @@ void BrowseMainPage::saveConfig() const
GwenviewConfig::setThumbnailDetails(d->mDelegate->thumbnailDetails());
}
bool BrowseMainPage::eventFilter(QObject* watched, QEvent* event)
{
if (d->mFullScreenMode && event->type() == QEvent::ShortcutOverride) {
const QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Escape) {
d->mActionCollection->action("leave_fullscreen")->trigger();
event->accept();
}
}
return QWidget::eventFilter(watched, event);
}
ThumbnailView* BrowseMainPage::thumbnailView() const
{
return d->mThumbnailView;
......@@ -353,6 +370,7 @@ void BrowseMainPage::updateThumbnailDetails()
void BrowseMainPage::setFullScreenMode(bool fullScreen)
{
d->mFullScreenMode = fullScreen;
setPalette(d->mGvCore->palette(fullScreen ? GvCore::FullScreenPalette : GvCore::NormalPalette));
d->mThumbnailView->setPalette(d->mGvCore->palette(fullScreen ? GvCore::FullScreenViewPalette : GvCore::NormalViewPalette));
d->updateUrlNavigatorBackgroundColor();
......
......@@ -79,6 +79,9 @@ private Q_SLOTS:
void slotUrlsDropped(const QUrl &destUrl, QDropEvent*);
void showMenuForDroppedUrls(const QList<QUrl>&, const QUrl &destUrl);
protected:
bool eventFilter(QObject* watched, QEvent* event) Q_DECL_OVERRIDE;
private:
BrowseMainPagePrivate* const d;
};
......
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