Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 140393d0 authored by Henrik Fehlauer's avatar Henrik Fehlauer

Clean up code tracking fullscreen state

Summary:
After syncing Gwenview's fullscreen mode with that of the window manager
in 0d917337, we can just ask the window for its fullscreen state
instead of having to track this for ourselves.

This gets rid of a bunch of `bools` and reduces chances those might
accidentally get out of sync at some point. In addition, we can
eliminate duplication and dependence on execution order in
`MainWindow::toggleFullScreen`.

Test Plan:
- `qDebug()` comparing `mFullScreenMode` and `window()->isFullscreen()`
- Manual testing of every functionality affected:
  - Switching to and from fullscreen mode (both via Gwenview and window manager).
  - {key Esc} to exit fullscreen mode.
  - Special fullscreen toolbar works.
  - Toggling sidebar resizes fullscreen toolbar.
  - Sidebar state remembered separately for normal and fullscreen mode.
  - Savebar not visible in fullscreen mode.
  - Memory warning bar still works in fullscreen mode.

Reviewers: muhlenpfordt

Reviewed By: muhlenpfordt

Differential Revision: https://phabricator.kde.org/D10412
parent 0d917337
......@@ -76,7 +76,6 @@ struct BrowseMainPagePrivate : public Ui_BrowseMainPage
KSelectAction* mSortAction;
QActionGroup* mThumbnailDetailsActionGroup;
PreviewItemDelegate* mDelegate;
bool mFullScreenMode;
void setupWidgets()
{
......@@ -227,7 +226,6 @@ 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();
......@@ -278,7 +276,7 @@ void BrowseMainPage::saveConfig() const
bool BrowseMainPage::eventFilter(QObject* watched, QEvent* event)
{
if (d->mFullScreenMode && event->type() == QEvent::ShortcutOverride) {
if (window()->isFullScreen() && event->type() == QEvent::ShortcutOverride) {
const QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Escape) {
d->mActionCollection->action("leave_fullscreen")->trigger();
......@@ -370,7 +368,6 @@ 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();
......
......@@ -102,7 +102,6 @@ private:
FullScreenContent::FullScreenContent(QObject* parent)
: QObject(parent)
{
mFullScreenMode = false;
mViewPageVisible = false;
}
......@@ -341,7 +340,7 @@ void FullScreenContent::updateLayout()
void FullScreenContent::updateContainerAppearance()
{
if (!mFullScreenMode || !mViewPageVisible) {
if (!mContent->window()->isFullScreen() || !mViewPageVisible) {
mAutoHideContainer->setActivated(false);
return;
}
......@@ -353,7 +352,7 @@ void FullScreenContent::updateContainerAppearance()
void FullScreenContent::adjustSize()
{
if (mFullScreenMode && mViewPageVisible) {
if (mContent->window()->isFullScreen() && mViewPageVisible) {
mAutoHideContainer->adjustSize();
}
}
......@@ -460,7 +459,7 @@ void FullScreenContent::showOptionsMenu()
void FullScreenContent::setFullScreenMode(bool fullScreenMode)
{
mFullScreenMode = fullScreenMode;
Q_UNUSED(fullScreenMode);
updateContainerAppearance();
}
......
......@@ -111,7 +111,6 @@ private:
QPointer<FullScreenConfigWidget> mConfigWidget;
QAction * mOptionsAction;
bool mFullScreenMode;
bool mViewPageVisible;
void createOptionsAction();
......
......@@ -695,7 +695,7 @@ struct MainWindow::Private
name = BROWSE_MODE_SIDE_BAR_GROUP;
break;
case ViewMainPageId:
name = mViewMainPage->isFullScreenMode()
name = q->isFullScreen()
? FULLSCREEN_MODE_SIDE_BAR_GROUP
: VIEW_MODE_SIDE_BAR_GROUP;
break;
......@@ -1275,16 +1275,7 @@ void MainWindow::toggleFullScreen(bool checked)
qApp->setProperty("KDE_COLOR_SCHEME_PATH", d->mGvCore->fullScreenPaletteName());
QApplication::setPalette(d->mGvCore->palette(GvCore::FullScreenPalette));
d->mFullScreenContent->setFullScreenMode(true);
d->mBrowseMainPage->setFullScreenMode(true);
d->mViewMainPage->setFullScreenMode(true);
d->mSaveBar->setFullScreenMode(true);
d->setScreenSaverEnabled(false);
// HACK: Only load sidebar config now, because it looks at
// ViewMainPage fullScreenMode property to determine the sidebar
// config group.
d->loadSideBarConfig();
} else {
setAutoSaveSettings();
......@@ -1292,11 +1283,7 @@ void MainWindow::toggleFullScreen(bool checked)
qApp->setProperty("KDE_COLOR_SCHEME_PATH", QVariant());
QApplication::setPalette(d->mGvCore->palette(GvCore::NormalPalette));
d->mFullScreenContent->setFullScreenMode(false);
d->mBrowseMainPage->setFullScreenMode(false);
d->mViewMainPage->setFullScreenMode(false);
d->mSlideShow->stop();
d->mSaveBar->setFullScreenMode(false);
KToggleFullScreenAction::setFullScreen(this, false);
menuBar()->setVisible(d->mShowMenuBarAction->isChecked());
toggleStatusBar();
......@@ -1304,13 +1291,17 @@ void MainWindow::toggleFullScreen(bool checked)
d->setScreenSaverEnabled(true);
// Keep this after mViewMainPage->setFullScreenMode(false).
// See call to loadSideBarConfig() above.
d->loadSideBarConfig();
// See resizeEvent
d->mFullScreenLeftAt = QDateTime::currentDateTime();
}
d->mFullScreenContent->setFullScreenMode(checked);
d->mBrowseMainPage->setFullScreenMode(checked);
d->mViewMainPage->setFullScreenMode(checked);
d->mSaveBar->setFullScreenMode(checked);
d->loadSideBarConfig();
setUpdatesEnabled(true);
d->autoAssignThumbnailProvider();
}
......
......@@ -69,7 +69,6 @@ struct SaveBarPrivate
QLabel* mActionsLabel;
QFrame* mTooManyChangesFrame;
QUrl mCurrentUrl;
bool mFullScreenMode;
void createTooManyChangesFrame()
{
......@@ -215,7 +214,7 @@ struct SaveBarPrivate
void updateWidgetSizes()
{
QVBoxLayout* layout = static_cast<QVBoxLayout*>(mSaveBarWidget->layout());
int topRowHeight = mFullScreenMode ? 0 : mTopRowWidget->height();
int topRowHeight = q->window()->isFullScreen() ? 0 : mTopRowWidget->height();
int bottomRowHeight = mTooManyChangesFrame->isVisibleTo(mSaveBarWidget) ? mTooManyChangesFrame->sizeHint().height() : 0;
int height = 2 * layout->margin() + topRowHeight + bottomRowHeight;
......@@ -231,7 +230,6 @@ SaveBar::SaveBar(QWidget* parent, KActionCollection* actionCollection)
, d(new SaveBarPrivate)
{
d->q = this;
d->mFullScreenMode = false;
d->mActionCollection = actionCollection;
d->mSaveBarWidget = new QWidget();
d->mSaveBarWidget->setObjectName(QLatin1String("saveBarWidget"));
......@@ -310,11 +308,10 @@ void SaveBar::initActionDependentWidgets()
d->updateWidgetSizes();
}
void SaveBar::setFullScreenMode(bool value)
void SaveBar::setFullScreenMode(bool isFullScreen)
{
d->mFullScreenMode = value;
d->mSaveAllFullScreenButton->setVisible(value);
if (value) {
d->mSaveAllFullScreenButton->setVisible(isFullScreen);
if (isFullScreen) {
d->applyFullScreenStyleSheet();
} else {
d->applyNormalStyleSheet();
......@@ -326,7 +323,7 @@ void SaveBar::updateContent()
{
QList<QUrl> lst = DocumentFactory::instance()->modifiedDocumentList();
if (d->mFullScreenMode) {
if (window()->isFullScreen()) {
d->mTopRowWidget->hide();
} else {
d->mTopRowWidget->show();
......@@ -336,7 +333,7 @@ void SaveBar::updateContent()
d->updateTooManyChangesFrame(lst);
d->updateWidgetSizes();
if (lst.isEmpty() || (d->mFullScreenMode && !d->mTooManyChangesFrame->isVisibleTo(d->mSaveBarWidget))) {
if (lst.isEmpty() || (window()->isFullScreen() && !d->mTooManyChangesFrame->isVisibleTo(d->mSaveBarWidget))) {
slideOut();
} else {
slideIn();
......
......@@ -160,7 +160,6 @@ struct ViewMainPagePrivate
// that use this KPart
QHash<DocumentView*, KActivities::ResourceInstance*> mActivityResources;
bool mFullScreenMode;
bool mCompareMode;
bool mThumbnailBarVisibleBeforeFullScreen;
ZoomMode::Enum mZoomMode;
......@@ -400,7 +399,6 @@ ViewMainPage::ViewMainPage(QWidget* parent, SlideShow* slideShow, KActionCollect
d->mSlideShow = slideShow;
d->mActionCollection = actionCollection;
d->mGvCore = gvCore;
d->mFullScreenMode = false;
d->mCompareMode = false;
d->mThumbnailBarVisibleBeforeFullScreen = false;
......@@ -507,7 +505,6 @@ void ViewMainPage::setStatusBarVisible(bool visible)
void ViewMainPage::setFullScreenMode(bool fullScreenMode)
{
d->mFullScreenMode = fullScreenMode;
d->mStatusBarContainer->setVisible(!fullScreenMode);
if (fullScreenMode) {
......@@ -524,11 +521,6 @@ void ViewMainPage::setFullScreenMode(bool fullScreenMode)
d->mToggleThumbnailBarAction->setEnabled(!fullScreenMode);
}
bool ViewMainPage::isFullScreenMode() const
{
return d->mFullScreenMode;
}
ThumbnailBarView* ViewMainPage::thumbnailBar() const
{
return d->mThumbnailBar;
......
......@@ -70,8 +70,6 @@ public:
void setFullScreenMode(bool fullScreen);
bool isFullScreenMode() const;
int statusBarHeight() const;
QSize sizeHint() const Q_DECL_OVERRIDE;
......
Markdown is supported
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