VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISlidingAnimation.h@ 74942

Last change on this file since 74942 was 73845, checked in by vboxsync, 6 years ago

FE/Qt: UISlidingAnimation: Notify about animation completion only when there really was an animation.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/* $Id: UISlidingAnimation.h 73845 2018-08-22 18:18:34Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UISlidingAnimation class declaration.
4 */
5
6/*
7 * Copyright (C) 2017-2018 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___UISlidingAnimation_h___
19#define ___UISlidingAnimation_h___
20
21/* Qt includes: */
22#include <QWidget>
23
24/* Forward declarations: */
25class QLabel;
26class QRect;
27class QWidget;
28class UIAnimation;
29
30
31/** Sliding direction. */
32enum SlidingDirection
33{
34 SlidingDirection_Forward,
35 SlidingDirection_Reverse
36};
37
38
39/** QWidget extension which renders a sliding animation
40 * while transiting from one widget to another. */
41class UISlidingAnimation : public QWidget
42{
43 Q_OBJECT;
44 Q_PROPERTY(QRect widgetGeometry READ widgetGeometry WRITE setWidgetGeometry);
45 Q_PROPERTY(QRect startWidgetGeometry READ startWidgetGeometry);
46 Q_PROPERTY(QRect finalWidgetGeometry READ finalWidgetGeometry);
47
48signals:
49
50 /** Commands to move animation in forward direction. */
51 void sigForward();
52 /** Commands to move animation in reverse direction. */
53 void sigReverse();
54
55 /** Notifies listeners about animation in specified @a enmDirection is complete. */
56 void sigAnimationComplete(SlidingDirection enmDirection);
57
58public:
59
60 /** Constructs sliding animation passing @a pParent to the base-class.
61 * @param enmOrientation Brings the widget orientation.
62 * @param fReverse Brings whether the animation should be initially reversed. */
63 UISlidingAnimation(Qt::Orientation enmOrientation, bool fReverse, QWidget *pParent = 0);
64
65 /** Defines @a pWidget1 and @a pWidget2. */
66 void setWidgets(QWidget *pWidget1, QWidget *pWidget2);
67
68 /** Animates cached pWidget1 and pWidget2 in passed @a enmDirection. */
69 void animate(SlidingDirection enmDirection);
70
71private slots:
72
73 /** Handles entering for 'Start' state. */
74 void sltHandleStateEnteredStart();
75 /** Handles entering for 'Final' state. */
76 void sltHandleStateEnteredFinal();
77
78private:
79
80 /** Prepares all. */
81 void prepare();
82
83 /** Defines sub-window geometry. */
84 void setWidgetGeometry(const QRect &rect);
85 /** Returns sub-window geometry. */
86 QRect widgetGeometry() const;
87 /** Returns sub-window start-geometry. */
88 QRect startWidgetGeometry() const { return m_startWidgetGeometry; }
89 /** Returns sub-window final-geometry. */
90 QRect finalWidgetGeometry() const { return m_finalWidgetGeometry; }
91
92 /** Holds the widget orientation. */
93 Qt::Orientation m_enmOrientation;
94 /** Holds whether the animation should be initially reversed. */
95 bool m_fReverse;
96 /** Holds the animation instance. */
97 UIAnimation *m_pAnimation;
98 /** Holds whether animation is in progress. */
99 bool m_fIsInProgress;
100 /** Holds sub-window start-geometry. */
101 QRect m_startWidgetGeometry;
102 /** Holds sub-window final-geometry. */
103 QRect m_finalWidgetGeometry;
104
105 /** Holds the sliding widget instance. */
106 QWidget *m_pWidget;
107 /** Holds the 1st label instance. */
108 QLabel *m_pLabel1;
109 /** Holds the 2nd label instance. */
110 QLabel *m_pLabel2;
111
112 /** Holds the 1st rendered-widget reference. */
113 QWidget *m_pWidget1;
114 /** Holds the 2nd rendered-widget reference. */
115 QWidget *m_pWidget2;
116};
117
118#endif /* !___UISlidingAnimation_h___ */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use