VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISlidingToolBar.h@ 76553

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

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
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: */
31class QCloseEvent;
32class QEvent;
33class QHBoxLayout;
34class QRect;
35class QShowEvent;
36class QWidget;
37class UIAnimation;
38
39/** QWidget subclass
40 * providing GUI with slideable tool-bar. */
41class 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
48signals:
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
57public:
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
73protected:
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
84private 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
97private:
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___ */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use