Commit 115ff763 authored by Gilles Caulier's avatar Gilles Caulier 🗼 Committed by Veaceslav Munteanu
Browse files

As under OSX, if toolbar is hidden during fullscreen mode, we display...

As under OSX, if toolbar is hidden during fullscreen mode, we display fullscreen switch button on top-right corner of active sceen when mouse is moved on this corner by end user.
Mouse move envent is handle by an event filter plug over managed window. FullScreenMngr is now a QObject class based.
CCBUGS: 214107
CCBUGS: 220739
CCBUGS: 289262
CCBUGS: 236234
CCBUGS: 258180
CCBUGS: 293676
parent 3de19c71
......@@ -27,6 +27,9 @@
#include <QList>
#include <QVBoxLayout>
#include <QCheckBox>
#include <QToolButton>
#include <QEvent>
#include <QHoverEvent>
// KDE includes
......@@ -41,6 +44,7 @@
#include <kactioncollection.h>
#include <kdialog.h>
#include <klocale.h>
#include <kapplication.h>
// Local includes
......@@ -58,6 +62,7 @@ public:
options = FS_DEFAULT;
win = 0;
fullScreenAction = 0;
fullScreenBtn = 0;
removeFullScreenButton = false;
}
......@@ -73,9 +78,12 @@ public:
/** Windo instance to manage */
KXmlGuiWindow* win;
/** Action plug in managed window to switch fullscreen state*/
/** Action plug in managed window to switch fullscreen state */
KToggleFullScreenAction* fullScreenAction;
/** Show only if toolbar is hidden */
QToolButton* fullScreenBtn;
/** Used by switchWindowToFullScreen() to manage state of full-screen button on managed window
*/
bool removeFullScreenButton;
......@@ -127,12 +135,17 @@ FullScreenMngr::~FullScreenMngr()
void FullScreenMngr::setManagedWindow(KXmlGuiWindow* const win)
{
d->win = win;
d->win->installEventFilter(this);
}
QAction* FullScreenMngr::createFullScreenAction(const QString& name)
{
d->fullScreenAction = KStandardAction::fullScreen(0, 0, d->win, d->win);
d->win->actionCollection()->addAction(name, d->fullScreenAction);
d->fullScreenBtn = new QToolButton(d->win);
d->fullScreenBtn->setDefaultAction(d->fullScreenAction);
d->fullScreenBtn->hide();
return d->fullScreenAction;
}
......@@ -179,6 +192,7 @@ void FullScreenMngr::switchWindowToFullScreen(bool set)
// restore toolbar
d->showToolBars();
d->fullScreenBtn->hide();
if (d->removeFullScreenButton)
{
......@@ -262,6 +276,54 @@ void FullScreenMngr::escapePressed()
}
}
bool FullScreenMngr::eventFilter(QObject* obj, QEvent* ev)
{
if (d->win && (obj == d->win))
{
if (ev && (ev->type() == QEvent::HoverMove))
{
if ((d->options & FS_TOOLBAR) && m_fullScreenHideToolBar)
{
QHoverEvent* const mev = dynamic_cast<QHoverEvent*>(ev);
if (mev)
{
QPoint pos(mev->pos());
QRect desktopRect = KGlobalSettings::desktopGeometry(kapp->activeWindow());
QRect sizeRect(QPoint(0, 0), d->fullScreenBtn->size());
QRect topLeft, topRight;
QRect topRightLarger;
desktopRect = QRect(desktopRect.y(), desktopRect.y(), desktopRect.width(), desktopRect.height());
topLeft = sizeRect;
topRight = sizeRect;
topLeft.moveTo(desktopRect.x(), desktopRect.y());
topRight.moveTo(desktopRect.x() + desktopRect.width() - sizeRect.width() - 1, topLeft.y());
topRightLarger = topRight.adjusted(-25, 0, 0, 10);
if (topRightLarger.contains(pos))
{
d->fullScreenBtn->move(topRight.topLeft());
d->fullScreenBtn->show();
}
else
{
d->fullScreenBtn->hide();
}
return false;
}
}
}
}
// pass the event on to the parent class
return QObject::eventFilter(obj, ev);
}
// -------------------------------------------------------------------------------------------------------------
class FullScreenSettings::Private
......
......@@ -27,6 +27,8 @@
// Qt includes
#include <QWidget>
#include <QObject>
#include <QRect>
// KDE includes
......@@ -36,6 +38,7 @@
#include "digikam_export.h"
class QEvent;
class QAction;
class KXmlGuiWindow;
......@@ -56,8 +59,9 @@ enum FullScreenOptions
/** Data container to use in managed window.
*/
class DIGIKAM_EXPORT FullScreenMngr
class DIGIKAM_EXPORT FullScreenMngr : public QObject
{
public:
explicit FullScreenMngr(int options);
......@@ -98,6 +102,10 @@ public:
*/
bool m_fullScreenHideThumbBar;
protected:
bool eventFilter(QObject* obj, QEvent* ev);
private:
class Private;
......
......@@ -214,7 +214,6 @@ EditorWindow::~EditorWindow()
delete m_IOFileSettings;
delete d->toolIface;
delete d->exposureSettings;
delete d->fullScreenMngr;
delete d;
}
......
......@@ -163,7 +163,6 @@ LightTableWindow::~LightTableWindow()
delete d->thumbView;
delete d->rightSideBar;
delete d->leftSideBar;
delete d->fullScreenMngr;
delete d;
}
......
......@@ -170,7 +170,6 @@ QueueMgrWindow::QueueMgrWindow()
QueueMgrWindow::~QueueMgrWindow()
{
m_instance = 0;
delete d->fullScreenMngr;
delete d;
}
......
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