1 | /* $Id: UISlidingToolBar.h 76553 2019-01-01 01:45:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UISlidingToolBar class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2014-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 ___UISlidingToolBar_h___
|
---|
19 | #define ___UISlidingToolBar_h___
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QWidget>
|
---|
26 |
|
---|
27 | /* GUI includes: */
|
---|
28 | #include "UILibraryDefs.h"
|
---|
29 |
|
---|
30 | /* Forward declarations: */
|
---|
31 | class QCloseEvent;
|
---|
32 | class QEvent;
|
---|
33 | class QHBoxLayout;
|
---|
34 | class QRect;
|
---|
35 | class QShowEvent;
|
---|
36 | class QWidget;
|
---|
37 | class UIAnimation;
|
---|
38 |
|
---|
39 | /** QWidget subclass
|
---|
40 | * providing GUI with slideable tool-bar. */
|
---|
41 | class SHARED_LIBRARY_STUFF UISlidingToolBar : 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 |
|
---|
48 | signals:
|
---|
49 |
|
---|
50 | /** Notifies about window shown. */
|
---|
51 | void sigShown();
|
---|
52 | /** Commands window to expand. */
|
---|
53 | void sigExpand();
|
---|
54 | /** Commands window to collapse. */
|
---|
55 | void sigCollapse();
|
---|
56 |
|
---|
57 | public:
|
---|
58 |
|
---|
59 | /** Possible positions. */
|
---|
60 | enum Position
|
---|
61 | {
|
---|
62 | Position_Top,
|
---|
63 | Position_Bottom
|
---|
64 | };
|
---|
65 |
|
---|
66 | /** Constructs sliding tool-bar passing @a pParentWidget to the base-class.
|
---|
67 | * @param pParentWidget Brings the parent-widget geometry.
|
---|
68 | * @param pIndentWidget Brings the indent-widget geometry.
|
---|
69 | * @param pChildWidget Brings the child-widget to be injected into tool-bar.
|
---|
70 | * @param enmPosition Brings the tool-bar position. */
|
---|
71 | UISlidingToolBar(QWidget *pParentWidget, QWidget *pIndentWidget, QWidget *pChildWidget, Position enmPosition);
|
---|
72 |
|
---|
73 | protected:
|
---|
74 |
|
---|
75 | #ifdef VBOX_WS_MAC
|
---|
76 | /** Handles any Qt @a pEvent. */
|
---|
77 | virtual bool event(QEvent *pEvent) /* override */;
|
---|
78 | #endif
|
---|
79 | /** Handles show @a pEvent. */
|
---|
80 | virtual void showEvent(QShowEvent *pEvent) /* override */;
|
---|
81 | /** Handles close @a pEvent. */
|
---|
82 | virtual void closeEvent(QCloseEvent *pEvent) /* override */;
|
---|
83 |
|
---|
84 | private slots:
|
---|
85 |
|
---|
86 | /** Performs window activation. */
|
---|
87 | void sltActivateWindow() { activateWindow(); }
|
---|
88 |
|
---|
89 | /** Marks window as expanded. */
|
---|
90 | void sltMarkAsExpanded() { m_fExpanded = true; }
|
---|
91 | /** Marks window as collapsed. */
|
---|
92 | void sltMarkAsCollapsed() { close(); m_fExpanded = false; }
|
---|
93 |
|
---|
94 | /** Handles parent geometry change. */
|
---|
95 | void sltParentGeometryChanged(const QRect &parentRect);
|
---|
96 |
|
---|
97 | private:
|
---|
98 |
|
---|
99 | /** Prepares all. */
|
---|
100 | void prepare();
|
---|
101 | /** Prepares contents. */
|
---|
102 | void prepareContents();
|
---|
103 | /** Prepares geometry. */
|
---|
104 | void prepareGeometry();
|
---|
105 | /** Prepares animation. */
|
---|
106 | void prepareAnimation();
|
---|
107 |
|
---|
108 | /** Updates geometry. */
|
---|
109 | void adjustGeometry();
|
---|
110 | /** Updates animation. */
|
---|
111 | void updateAnimation();
|
---|
112 |
|
---|
113 | /** Defines sub-window geometry. */
|
---|
114 | void setWidgetGeometry(const QRect &rect);
|
---|
115 | /** Returns sub-window geometry. */
|
---|
116 | QRect widgetGeometry() const;
|
---|
117 | /** Returns sub-window start-geometry. */
|
---|
118 | QRect startWidgetGeometry() const { return m_startWidgetGeometry; }
|
---|
119 | /** Returns sub-window final-geometry. */
|
---|
120 | QRect finalWidgetGeometry() const { return m_finalWidgetGeometry; }
|
---|
121 |
|
---|
122 | /** @name Geometry
|
---|
123 | * @{ */
|
---|
124 | /** Holds the tool-bar position. */
|
---|
125 | const Position m_enmPosition;
|
---|
126 | /** Holds the cached parent-widget geometry. */
|
---|
127 | QRect m_parentRect;
|
---|
128 | /** Holds the cached indent-widget geometry. */
|
---|
129 | QRect m_indentRect;
|
---|
130 | /** @} */
|
---|
131 |
|
---|
132 | /** @name Geometry: Animation
|
---|
133 | * @{ */
|
---|
134 | /** Holds the expand/collapse animation instance. */
|
---|
135 | UIAnimation *m_pAnimation;
|
---|
136 | /** Holds whether window is expanded. */
|
---|
137 | bool m_fExpanded;
|
---|
138 | /** Holds sub-window start-geometry. */
|
---|
139 | QRect m_startWidgetGeometry;
|
---|
140 | /** Holds sub-window final-geometry. */
|
---|
141 | QRect m_finalWidgetGeometry;
|
---|
142 | /** @} */
|
---|
143 |
|
---|
144 | /** @name Contents
|
---|
145 | * @{ */
|
---|
146 | /** Holds the main-layout instance. */
|
---|
147 | QHBoxLayout *m_pMainLayout;
|
---|
148 | /** Holds the area instance. */
|
---|
149 | QWidget *m_pArea;
|
---|
150 | /** Holds the child-widget reference. */
|
---|
151 | QWidget *m_pWidget;
|
---|
152 | /** @} */
|
---|
153 | };
|
---|
154 |
|
---|
155 | #endif /* !___UISlidingToolBar_h___ */
|
---|