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. | |||||
120 | d->mEdgeTriggerEnabled = true; | 120 | d->mEdgeTriggerEnabled = true; | ||
121 | setObjectName(QLatin1String("fullScreenBar")); | 121 | setObjectName(QLatin1String("fullScreenBar")); | ||
122 | 122 | | |||
123 | d->mTimeLine = new QTimeLine(SLIDE_DURATION, this); | 123 | int animDuration = style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this); | ||
124 | connect(d->mTimeLine, &QTimeLine::valueChanged, this, &FullScreenBar::moveBar); | 124 | if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu) && animDuration > 0) { | ||
125 | d->mTimeLine = new QTimeLine(animDuration, this); | ||||
126 | connect(d->mTimeLine, &QTimeLine::valueChanged, this, &FullScreenBar::moveBar); | ||||
127 | } | ||||
125 | 128 | | |||
126 | d->mAutoHideCursorTimer = new QTimer(this); | 129 | d->mAutoHideCursorTimer = new QTimer(this); | ||
127 | d->mAutoHideCursorTimer->setInterval(AUTO_HIDE_CURSOR_TIMEOUT); | 130 | d->mAutoHideCursorTimer->setInterval(AUTO_HIDE_CURSOR_TIMEOUT); | ||
Context not available. | |||||
206 | 209 | | |||
207 | void FullScreenBar::slideOut() | 210 | void FullScreenBar::slideOut() | ||
208 | { | 211 | { | ||
209 | d->mInitialHideTimer->stop(); | 212 | if (d->mTimeLine) { | ||
210 | d->mTimeLine->setDirection(QTimeLine::Backward); | 213 | d->mInitialHideTimer->stop(); | ||
211 | d->startTimeLine(); | 214 | d->mTimeLine->setDirection(QTimeLine::Backward); | ||
215 | d->startTimeLine(); | ||||
216 | } else { | ||||
217 | FullScreenBar::moveBar(0.); | ||||
218 | } | ||||
212 | } | 219 | } | ||
213 | 220 | | |||
214 | void FullScreenBar::slideIn() | 221 | void FullScreenBar::slideIn() | ||
215 | { | 222 | { | ||
216 | d->mInitialHideTimer->stop(); | 223 | if (d->mTimeLine) { | ||
217 | d->mTimeLine->setDirection(QTimeLine::Forward); | 224 | d->mInitialHideTimer->stop(); | ||
218 | d->startTimeLine(); | 225 | d->mTimeLine->setDirection(QTimeLine::Forward); | ||
226 | d->startTimeLine(); | ||||
227 | } else { | ||||
228 | FullScreenBar::moveBar(1.); | ||||
229 | } | ||||
219 | } | 230 | } | ||
220 | 231 | | |||
221 | bool FullScreenBar::eventFilter(QObject* object, QEvent* event) | 232 | bool FullScreenBar::eventFilter(QObject* object, QEvent* event) | ||
Context not available. |