VirtualBox

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

Last change on this file since 100347 was 98103, checked in by vboxsync, 22 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1/* $Id: UISlidingToolBar.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UISlidingToolBar class declaration.
4 */
5
6/*
7 * Copyright (C) 2014-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_widgets_UISlidingToolBar_h
29#define FEQT_INCLUDED_SRC_widgets_UISlidingToolBar_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QWidget>
36
37/* GUI includes: */
38#include "UILibraryDefs.h"
39
40/* Forward declarations: */
41class QCloseEvent;
42class QEvent;
43class QHBoxLayout;
44class QRect;
45class QShowEvent;
46class QWidget;
47class UIAnimation;
48
49/** QWidget subclass
50 * providing GUI with slideable tool-bar. */
51class SHARED_LIBRARY_STUFF UISlidingToolBar : public QWidget
52{
53 Q_OBJECT;
54 Q_PROPERTY(QRect widgetGeometry READ widgetGeometry WRITE setWidgetGeometry);
55 Q_PROPERTY(QRect startWidgetGeometry READ startWidgetGeometry);
56 Q_PROPERTY(QRect finalWidgetGeometry READ finalWidgetGeometry);
57
58signals:
59
60 /** Notifies about window shown. */
61 void sigShown();
62 /** Commands window to expand. */
63 void sigExpand();
64 /** Commands window to collapse. */
65 void sigCollapse();
66
67public:
68
69 /** Possible positions. */
70 enum Position
71 {
72 Position_Top,
73 Position_Bottom
74 };
75
76 /** Constructs sliding tool-bar passing @a pParentWidget to the base-class.
77 * @param pParentWidget Brings the parent-widget geometry.
78 * @param pIndentWidget Brings the indent-widget geometry.
79 * @param pChildWidget Brings the child-widget to be injected into tool-bar.
80 * @param enmPosition Brings the tool-bar position. */
81 UISlidingToolBar(QWidget *pParentWidget, QWidget *pIndentWidget, QWidget *pChildWidget, Position enmPosition);
82
83public slots:
84
85 /** Performs window activation. */
86 void sltActivateWindow() { activateWindow(); }
87
88protected:
89
90#ifdef VBOX_WS_MAC
91 /** Handles any Qt @a pEvent. */
92 virtual bool event(QEvent *pEvent) RT_OVERRIDE;
93#endif
94 /** Handles show @a pEvent. */
95 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
96 /** Handles close @a pEvent. */
97 virtual void closeEvent(QCloseEvent *pEvent) RT_OVERRIDE;
98
99private slots:
100
101 /** Marks window as expanded. */
102 void sltMarkAsExpanded() { m_fExpanded = true; }
103 /** Marks window as collapsed. */
104 void sltMarkAsCollapsed() { close(); m_fExpanded = false; }
105
106 /** Handles parent geometry change. */
107 void sltParentGeometryChanged(const QRect &parentRect);
108
109private:
110
111 /** Prepares all. */
112 void prepare();
113 /** Prepares contents. */
114 void prepareContents();
115 /** Prepares geometry. */
116 void prepareGeometry();
117 /** Prepares animation. */
118 void prepareAnimation();
119
120 /** Updates geometry. */
121 void adjustGeometry();
122 /** Updates animation. */
123 void updateAnimation();
124
125 /** Defines sub-window geometry. */
126 void setWidgetGeometry(const QRect &rect);
127 /** Returns sub-window geometry. */
128 QRect widgetGeometry() const;
129 /** Returns sub-window start-geometry. */
130 QRect startWidgetGeometry() const { return m_startWidgetGeometry; }
131 /** Returns sub-window final-geometry. */
132 QRect finalWidgetGeometry() const { return m_finalWidgetGeometry; }
133
134 /** @name Geometry
135 * @{ */
136 /** Holds the tool-bar position. */
137 const Position m_enmPosition;
138 /** Holds the cached parent-widget geometry. */
139 QRect m_parentRect;
140 /** Holds the cached indent-widget geometry. */
141 QRect m_indentRect;
142 /** @} */
143
144 /** @name Geometry: Animation
145 * @{ */
146 /** Holds the expand/collapse animation instance. */
147 UIAnimation *m_pAnimation;
148 /** Holds whether window is expanded. */
149 bool m_fExpanded;
150 /** Holds sub-window start-geometry. */
151 QRect m_startWidgetGeometry;
152 /** Holds sub-window final-geometry. */
153 QRect m_finalWidgetGeometry;
154 /** @} */
155
156 /** @name Contents
157 * @{ */
158 /** Holds the main-layout instance. */
159 QHBoxLayout *m_pMainLayout;
160 /** Holds the area instance. */
161 QWidget *m_pArea;
162 /** Holds the child-widget reference. */
163 QWidget *m_pWidget;
164 /** @} */
165};
166
167#endif /* !FEQT_INCLUDED_SRC_widgets_UISlidingToolBar_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette