Commit cde52bd9 authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

Port fullscreen mode from Light Table to FullScreenMngr.

CCBUGS: 214107
CCBUGS: 220739
CCBUGS: 289262
CCBUGS: 236234
CCBUGS: 258180
CCBUGS: 293676
parent c91cc77f
......@@ -128,6 +128,11 @@ LightTableWindow::LightTableWindow()
// We don't want to be deleted on close
setAttribute(Qt::WA_DeleteOnClose, false);
// --------------------------------------------------------
d->fullScreenMngr = new FullScreenMngr(FS_TOOLBAR);
d->fullScreenMngr->setManagedWindow(this);
// -- Build the GUI -------------------------------
setupUserArea();
......@@ -158,6 +163,7 @@ LightTableWindow::~LightTableWindow()
delete d->thumbView;
delete d->rightSideBar;
delete d->leftSideBar;
delete d->fullScreenMngr;
delete d;
}
......@@ -175,6 +181,8 @@ void LightTableWindow::readSettings()
d->leftSideBar->loadState();
d->rightSideBar->setConfigGroup(KConfigGroup(&group, "Right Sidebar"));
d->rightSideBar->loadState();
d->fullScreenMngr->readSettings(group);
}
void LightTableWindow::writeSettings()
......@@ -190,6 +198,9 @@ void LightTableWindow::writeSettings()
d->leftSideBar->saveState();
d->rightSideBar->setConfigGroup(KConfigGroup(&group, "Right Sidebar"));
d->rightSideBar->saveState();
d->fullScreenMngr->saveSettings(group);
config->sync();
}
......@@ -199,9 +210,12 @@ void LightTableWindow::applySettings()
KConfigGroup group = config->group("LightTable Settings");
d->autoLoadOnRightPanel = group.readEntry("Auto Load Right Panel", true);
d->autoSyncPreview = group.readEntry("Auto Sync Preview", true);
d->fullScreenHideToolBar = group.readEntry("FullScreen Hide ToolBar", false);
d->clearOnCloseAction->setChecked(group.readEntry("Clear On Close", false));
d->previewView->setLoadFullImageSize(group.readEntry("Load Full Image size", false));
// Restore full screen Mode
d->fullScreenMngr->readSettings(group);
// NOTE: Image orientation settings in thumbbar is managed by image model.
refreshView();
}
......@@ -534,9 +548,8 @@ void LightTableWindow::setupActions()
d->showThumbBarAction = d->barViewDock->getToggleAction(this);
actionCollection()->addAction("lighttable_showthumbbar", d->showThumbBarAction);
d->fullScreenAction = KStandardAction::fullScreen(0, 0, this, this);
actionCollection()->addAction("lighttable_fullscreen", d->fullScreenAction);
connect(d->fullScreenAction, SIGNAL(toggled(bool)), this, SLOT(slotToggleFullScreen(bool)));
QAction* const fullScreenAction = d->fullScreenMngr->createFullScreenAction("lighttable_fullscreen");
connect(fullScreenAction, SIGNAL(toggled(bool)), this, SLOT(slotToggleFullScreen(bool)));
d->slideShowAction = new KAction(KIcon("view-presentation"), i18n("Slideshow"), this);
d->slideShowAction->setShortcut(KShortcut(Qt::Key_F9));
......@@ -1445,26 +1458,6 @@ void LightTableWindow::slotProgressBarCancelButtonPressed()
d->cancelSlideShow = true;
}
void LightTableWindow::showToolBars()
{
QList<KToolBar*> toolbars = toolBars();
foreach(KToolBar* const toolbar, toolbars)
{
toolbar->show();
}
}
void LightTableWindow::hideToolBars()
{
QList<KToolBar*> toolbars = toolBars();
foreach(KToolBar* const toolbar, toolbars)
{
toolbar->hide();
}
}
void LightTableWindow::slotEditKeys()
{
KShortcutsDialog dialog(KShortcutsEditor::AllActions,
......@@ -1626,86 +1619,29 @@ void LightTableWindow::slotThemeChanged()
void LightTableWindow::slotToggleFullScreen(bool b)
{
KToggleFullScreenAction::setFullScreen(this, b);
d->fullScreenMngr->switchWindowToFullScreen(b);
if (!b)
{
// Switch off fullscreen
slotShowMenuBar();
statusBar()->show();
showToolBars();
if (d->removeFullScreenButton)
{
QList<KToolBar*> toolbars = toolBars();
foreach(KToolBar* const toolbar, toolbars)
{
// name is set in ui.rc XML file
if (toolbar->objectName() == "ToolBar")
{
toolbar->removeAction(d->fullScreenAction);
break;
}
}
}
kDebug() << "TURN OFF fullscreen";
d->leftSideBar->restore();
d->rightSideBar->restore();
}
else
{
// Switch on fullscreen
// hide the menubar and the statusbar
menuBar()->hide();
statusBar()->hide();
if (d->fullScreenHideToolBar)
{
hideToolBars();
}
else
{
showToolBars();
QList<KToolBar*> toolbars = toolBars();
KToolBar* mainToolbar = 0;
foreach(KToolBar* const toolbar, toolbars)
{
if (toolbar->objectName() == "ToolBar")
{
mainToolbar = toolbar;
break;
}
}
// add fullscreen action if necessary
if (mainToolbar && !mainToolbar->actions().contains(d->fullScreenAction))
{
mainToolbar->addAction(d->fullScreenAction);
d->removeFullScreenButton = true;
}
else
{
// If FullScreen button is enabled in toolbar settings,
// we shall not remove it when leaving of fullscreen mode.
d->removeFullScreenButton = false;
}
}
kDebug() << "TURN ON fullscreen";
d->leftSideBar->backup();
d->rightSideBar->backup();
}
}
void LightTableWindow::slotEscapePressed()
void LightTableWindow::keyPressEvent(QKeyEvent* e)
{
if (d->fullScreenAction->isChecked())
if (e->key() == Qt::Key_Escape)
{
d->fullScreenAction->activate(QAction::Trigger);
d->fullScreenMngr->escapePressed();
}
}
......
......@@ -78,6 +78,7 @@ public Q_SLOTS:
protected:
void moveEvent(QMoveEvent* e);
void keyPressEvent(QKeyEvent* e);
private:
......@@ -88,8 +89,6 @@ private:
void setupUserArea();
void setupStatusBar();
void slideShow(SlideShowSettings& settings);
void showToolBars();
void hideToolBars();
void readSettings();
void writeSettings();
......@@ -145,7 +144,6 @@ private Q_SLOTS:
void slotProgressBarCancelButtonPressed();
void slotToggleSlideShow();
void slotToggleFullScreen(bool);
void slotEscapePressed();
void slotEditKeys();
void slotConfToolbars();
void slotConfNotifications();
......
......@@ -43,8 +43,7 @@
#include "lighttableview.h"
#include "lighttablethumbbar.h"
#include "thumbbardock.h"
class KToggleFullScreenAction;
#include "fullscreenmngr.h"
namespace Digikam
{
......@@ -57,10 +56,7 @@ public:
Private() :
autoLoadOnRightPanel(true),
autoSyncPreview(true),
fullScreenHideToolBar(false),
removeFullScreenButton(false),
cancelSlideShow(false),
fullScreenAction(0),
setItemLeftAction(0),
setItemRightAction(0),
clearListAction(0),
......@@ -105,11 +101,8 @@ public:
bool autoLoadOnRightPanel;
bool autoSyncPreview;
bool fullScreenHideToolBar;
bool removeFullScreenButton;
bool cancelSlideShow;
KToggleFullScreenAction* fullScreenAction;
KAction* setItemLeftAction;
KAction* setItemRightAction;
KAction* clearListAction;
......@@ -162,6 +155,8 @@ public:
ImagePropertiesSideBarDB* rightSideBar;
DAboutData* about;
FullScreenMngr* fullScreenMngr;
};
} // namespace Digikam
......
......@@ -6,7 +6,7 @@
* Date : 2007-05-11
* Description : setup Light Table tab.
*
* Copyright (C) 2007-2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2007-2013 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
......@@ -38,6 +38,10 @@
#include <kglobal.h>
#include <klocale.h>
// Local includes
#include "fullscreenmngr.h"
namespace Digikam
{
......@@ -46,29 +50,28 @@ class SetupLightTable::Private
public:
Private() :
hideToolBar(0),
autoSyncPreview(0),
autoLoadOnRightPanel(0),
loadFullImageSize(0),
clearOnClose(0)
clearOnClose(0),
fullScreenSettings(0)
{}
static const QString configGroupName;
static const QString configFullScreenHideToolBarEntry;
static const QString configAutoSyncPreviewEntry;
static const QString configAutoLoadRightPanelEntry;
static const QString configLoadFullImagesizeEntry;
static const QString configClearOnCloseEntry;
QCheckBox* hideToolBar;
QCheckBox* autoSyncPreview;
QCheckBox* autoLoadOnRightPanel;
QCheckBox* loadFullImageSize;
QCheckBox* clearOnClose;
FullScreenSettings* fullScreenSettings;
};
const QString SetupLightTable::Private::configGroupName("LightTable Settings");
const QString SetupLightTable::Private::configFullScreenHideToolBarEntry("FullScreen Hide ToolBar");
const QString SetupLightTable::Private::configAutoSyncPreviewEntry("Auto Sync Preview");
const QString SetupLightTable::Private::configAutoLoadRightPanelEntry("Auto Load Right Panel");
const QString SetupLightTable::Private::configLoadFullImagesizeEntry("Load Full Image size");
......@@ -108,7 +111,7 @@ SetupLightTable::SetupLightTable(QWidget* const parent)
"<p><b>Note:</b> for Raw images, a half size version of the Raw data "
"is used instead of the embedded JPEG preview.</p>"));
d->hideToolBar = new QCheckBox(i18n("H&ide toolbar in fullscreen mode"), interfaceOptionsGroup);
d->fullScreenSettings = new FullScreenSettings(FS_TOOLBAR, interfaceOptionsGroup);
d->clearOnClose = new QCheckBox(i18n("Clear the light table on close"));
d->clearOnClose->setWhatsThis(i18n("Set this option to remove all images "
......@@ -119,7 +122,7 @@ SetupLightTable::SetupLightTable(QWidget* const parent)
gLayout->addWidget(d->autoSyncPreview);
gLayout->addWidget(d->autoLoadOnRightPanel);
gLayout->addWidget(d->loadFullImageSize);
gLayout->addWidget(d->hideToolBar);
gLayout->addWidget(d->fullScreenSettings);
gLayout->addWidget(d->clearOnClose);
gLayout->setMargin(KDialog::spacingHint());
gLayout->setSpacing(0);
......@@ -154,7 +157,7 @@ void SetupLightTable::readSettings()
QColor Black(Qt::black);
QColor White(Qt::white);
d->hideToolBar->setChecked(group.readEntry(d->configFullScreenHideToolBarEntry, false));
d->fullScreenSettings->readSettings(group);
d->autoSyncPreview->setChecked(group.readEntry(d->configAutoSyncPreviewEntry, true));
d->autoLoadOnRightPanel->setChecked(group.readEntry(d->configAutoLoadRightPanelEntry, true));
d->loadFullImageSize->setChecked(group.readEntry(d->configLoadFullImagesizeEntry, false));
......@@ -165,7 +168,7 @@ void SetupLightTable::applySettings()
{
KSharedConfig::Ptr config = KGlobal::config();
KConfigGroup group = config->group(d->configGroupName);
group.writeEntry(d->configFullScreenHideToolBarEntry, d->hideToolBar->isChecked());
d->fullScreenSettings->saveSettings(group);
group.writeEntry(d->configAutoSyncPreviewEntry, d->autoSyncPreview->isChecked());
group.writeEntry(d->configAutoLoadRightPanelEntry, d->autoLoadOnRightPanel->isChecked());
group.writeEntry(d->configLoadFullImagesizeEntry, d->loadFullImageSize->isChecked());
......
......@@ -6,7 +6,7 @@
* Date : 2007-05-11
* Description : setup Light Table tab.
*
* Copyright (C) 2007-2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2007-2013 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
......
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