VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISlidingWidget.h@ 82781

Last change on this file since 82781 was 76581, checked in by vboxsync, 5 years ago

Fe/QT: scm header guard alignment.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/* $Id: UISlidingWidget.h 76581 2019-01-01 06:24:57Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UISlidingWidget class declaration.
4 */
5
6/*
7 * Copyright (C) 2017-2019 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 FEQT_INCLUDED_SRC_widgets_UISlidingWidget_h
19#define FEQT_INCLUDED_SRC_widgets_UISlidingWidget_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* Qt includes: */
25#include <QWidget>
26
27/* Forward declarations: */
28class QBoxLayout;
29class QRect;
30class QWidget;
31class UIAnimation;
32
33
34/** Some kind of splitter which allows to switch between
35 * two widgets using horizontal sliding animation. */
36class UISlidingWidget : public QWidget
37{
38 Q_OBJECT;
39 Q_PROPERTY(QRect widgetGeometry READ widgetGeometry WRITE setWidgetGeometry);
40 Q_PROPERTY(QRect startWidgetGeometry READ startWidgetGeometry);
41 Q_PROPERTY(QRect finalWidgetGeometry READ finalWidgetGeometry);
42
43signals:
44
45 /** Commands to move animation forward. */
46 void sigForward();
47 /** Commands to move animation backward. */
48 void sigBackward();
49
50public:
51
52 /** Sliding state. */
53 enum State
54 {
55 State_Start,
56 State_GoingForward,
57 State_Final,
58 State_GoingBackward
59 };
60
61 /** Constructs sliding widget passing @a pParent to the base-class.
62 * @param enmOrientation Brings the widget orientation. */
63 UISlidingWidget(Qt::Orientation enmOrientation, QWidget *pParent = 0);
64
65 /** Holds the minimum widget size. */
66 virtual QSize minimumSizeHint() const /* pverride */;
67
68 /** Defines @a pWidget1 and @a pWidget2. */
69 void setWidgets(QWidget *pWidget1, QWidget *pWidget2);
70
71 /** Returns sliding state. */
72 State state() const { return m_enmState; }
73
74 /** Moves animation forward. */
75 void moveForward() { m_enmState = State_GoingForward; emit sigForward(); }
76 /** Moves animation backward. */
77 void moveBackward() { m_enmState = State_GoingBackward; emit sigBackward(); }
78
79protected:
80
81 /** Handles any Qt @a pEvent. */
82 virtual bool event(QEvent *pEvent) /* override */;
83
84 /** Handles resize @a pEvent. */
85 virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
86
87private slots:
88
89 /** Marks state as start. */
90 void sltSetStateToStart() { m_enmState = State_Start; }
91 /** Marks state as final. */
92 void sltSetStateToFinal() { m_enmState = State_Final; }
93
94private:
95
96 /** Prepares all. */
97 void prepare();
98
99 /** Updates animation. */
100 void updateAnimation();
101
102 /** Defines sub-window geometry. */
103 void setWidgetGeometry(const QRect &rect);
104 /** Returns sub-window geometry. */
105 QRect widgetGeometry() const;
106 /** Returns sub-window start-geometry. */
107 QRect startWidgetGeometry() const { return m_startWidgetGeometry; }
108 /** Returns sub-window final-geometry. */
109 QRect finalWidgetGeometry() const { return m_finalWidgetGeometry; }
110
111 /** Holds the widget orientation. */
112 Qt::Orientation m_enmOrientation;
113
114 /** Holds whether we are in animation final state. */
115 State m_enmState;
116 /** Holds the shift left/right animation instance. */
117 UIAnimation *m_pAnimation;
118 /** Holds sub-window start-geometry. */
119 QRect m_startWidgetGeometry;
120 /** Holds sub-window final-geometry. */
121 QRect m_finalWidgetGeometry;
122
123 /** Holds the private sliding widget instance. */
124 QWidget *m_pWidget;
125 /** Holds the widget layout instance. */
126 QBoxLayout *m_pLayout;
127 /** Holds the 1st widget reference. */
128 QWidget *m_pWidget1;
129 /** Holds the 2nd widget reference. */
130 QWidget *m_pWidget2;
131};
132
133#endif /* !FEQT_INCLUDED_SRC_widgets_UISlidingWidget_h */
134
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use