Changeset View
Changeset View
Standalone View
Standalone View
lib/fullscreenbar.cpp
Context not available. | |||||
32 | #include <QTimeLine> | 32 | #include <QTimeLine> | ||
---|---|---|---|---|---|
33 | #include <QTimer> | 33 | #include <QTimer> | ||
34 | #include <QToolButton> | 34 | #include <QToolButton> | ||
35 | #include <QStyle> | ||||
35 | 36 | | |||
36 | // KDE | 37 | // KDE | ||
37 | #include <KLocalizedString> | 38 | #include <KLocalizedString> | ||
Context not available. | |||||
41 | namespace Gwenview | 42 | namespace Gwenview | ||
42 | { | 43 | { | ||
43 | 44 | | |||
44 | static const int SLIDE_DURATION = 150; | | |||
45 | static const int AUTO_HIDE_CURSOR_TIMEOUT = 1000; | 45 | static const int AUTO_HIDE_CURSOR_TIMEOUT = 1000; | ||
46 | 46 | | |||
47 | // How long before the bar slide out after switching to fullscreen | 47 | // How long before the bar slide out after switching to fullscreen | ||
Context not available. | |||||
54 | struct FullScreenBarPrivate | 54 | struct FullScreenBarPrivate | ||
55 | { | 55 | { | ||
56 | FullScreenBar* q; | 56 | FullScreenBar* q; | ||
57 | QTimeLine* mTimeLine; | 57 | QTimeLine* mTimeLine = nullptr; | ||
58 | QTimer* mAutoHideCursorTimer; | 58 | QTimer* mAutoHideCursorTimer; | ||
59 | bool mAutoHidingEnabled; | 59 | bool mAutoHidingEnabled; | ||
60 | bool mEdgeTriggerEnabled; | 60 | bool mEdgeTriggerEnabled; | ||
Context not available. | |||||
62 | 62 | | |||
63 | void startTimeLine() | 63 | void startTimeLine() | ||
64 | { | 64 | { | ||
65 | if (mTimeLine->state() != QTimeLine::Running) { | 65 | if (mTimeLine && mTimeLine->state() != QTimeLine::Running) { | ||
66 | mTimeLine->start(); | 66 | mTimeLine->start(); | ||
67 | } | 67 | } | ||
68 | } | 68 | } | ||
Context not available. | |||||
124 | d->mEdgeTriggerEnabled = true; | 124 | d->mEdgeTriggerEnabled = true; | ||
125 | setObjectName(QStringLiteral("fullScreenBar")); | 125 | setObjectName(QStringLiteral("fullScreenBar")); | ||
126 | 126 | | |||
127 | d->mTimeLine = new QTimeLine(SLIDE_DURATION, this); | 127 | int animDuration = style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this); | ||
128 | connect(d->mTimeLine, &QTimeLine::valueChanged, this, &FullScreenBar::moveBar); | 128 | if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu) && animDuration > 0) { | ||
129 | d->mTimeLine = new QTimeLine(animDuration, this); | ||||
130 | connect(d->mTimeLine, &QTimeLine::valueChanged, this, &FullScreenBar::moveBar); | ||||
131 | } | ||||
129 | 132 | | |||
130 | d->mAutoHideCursorTimer = new QTimer(this); | 133 | d->mAutoHideCursorTimer = new QTimer(this); | ||
131 | d->mAutoHideCursorTimer->setInterval(AUTO_HIDE_CURSOR_TIMEOUT); | 134 | d->mAutoHideCursorTimer->setInterval(AUTO_HIDE_CURSOR_TIMEOUT); | ||
Context not available. | |||||
210 | 213 | | |||
211 | void FullScreenBar::slideOut() | 214 | void FullScreenBar::slideOut() | ||
212 | { | 215 | { | ||
213 | d->mInitialHideTimer->stop(); | 216 | if (d->mTimeLine) { | ||
214 | d->mTimeLine->setDirection(QTimeLine::Backward); | 217 | d->mInitialHideTimer->stop(); | ||
215 | d->startTimeLine(); | 218 | d->mTimeLine->setDirection(QTimeLine::Backward); | ||
219 | d->startTimeLine(); | ||||
220 | } else { | ||||
221 | FullScreenBar::moveBar(0.); | ||||
222 | } | ||||
216 | } | 223 | } | ||
217 | 224 | | |||
218 | void FullScreenBar::slideIn() | 225 | void FullScreenBar::slideIn() | ||
219 | { | 226 | { | ||
220 | d->mInitialHideTimer->stop(); | 227 | if (d->mTimeLine) { | ||
221 | d->mTimeLine->setDirection(QTimeLine::Forward); | 228 | d->mInitialHideTimer->stop(); | ||
222 | d->startTimeLine(); | 229 | d->mTimeLine->setDirection(QTimeLine::Forward); | ||
230 | d->startTimeLine(); | ||||
231 | } else { | ||||
232 | FullScreenBar::moveBar(1.); | ||||
233 | } | ||||
223 | } | 234 | } | ||
224 | 235 | | |||
225 | bool FullScreenBar::eventFilter(QObject* object, QEvent* event) | 236 | bool FullScreenBar::eventFilter(QObject* object, QEvent* event) | ||
Context not available. |