VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.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: 6.4 KB
Line 
1/* $Id: UIMiniToolBar.h 76581 2019-01-01 06:24:57Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMiniToolBar class declaration.
4 */
5
6/*
7 * Copyright (C) 2009-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_UIMiniToolBar_h
19#define FEQT_INCLUDED_SRC_widgets_UIMiniToolBar_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* GUI includes: */
25#include "UIToolBar.h"
26
27/* Forward declarations: */
28class QMenu;
29class QTimer;
30class QLabel;
31class UIAnimation;
32class UIMiniToolBarPrivate;
33
34/** Geometry types. */
35enum GeometryType
36{
37 GeometryType_Available,
38 GeometryType_Full
39};
40
41
42/** QWidget reimplementation
43 * providing GUI with slideable mini-toolbar used in full-screen/seamless modes. */
44class UIMiniToolBar : public QWidget
45{
46 Q_OBJECT;
47 Q_PROPERTY(QPoint toolbarPosition READ toolbarPosition WRITE setToolbarPosition);
48 Q_PROPERTY(QPoint hiddenToolbarPosition READ hiddenToolbarPosition);
49 Q_PROPERTY(QPoint shownToolbarPosition READ shownToolbarPosition);
50
51signals:
52
53 /** Notifies listeners about action triggered to minimize. */
54 void sigMinimizeAction();
55 /** Notifies listeners about action triggered to exit. */
56 void sigExitAction();
57 /** Notifies listeners about action triggered to close. */
58 void sigCloseAction();
59
60 /** Notifies listeners about we are hovered. */
61 void sigHoverEnter();
62 /** Notifies listeners about we are unhovered. */
63 void sigHoverLeave();
64
65 /** Notifies listeners about we stole window activation. */
66 void sigNotifyAboutWindowActivationStolen();
67
68public:
69
70 /** Proposes default set of window flags for particular platform. */
71 static Qt::WindowFlags defaultWindowFlags(GeometryType geometryType);
72
73 /** Constructor, passes @a pParent to the QWidget constructor.
74 * @param geometryType determines the geometry type,
75 * @param alignment determines the alignment type,
76 * @param fAutoHide determines whether we should auto-hide.
77 * @param iWindowIndex determines the parent window index. */
78 UIMiniToolBar(QWidget *pParent,
79 GeometryType geometryType,
80 Qt::Alignment alignment,
81 bool fAutoHide = true,
82 int iWindowIndex = -1);
83 /** Destructor. */
84 ~UIMiniToolBar();
85
86 /** Defines @a alignment. */
87 void setAlignment(Qt::Alignment alignment);
88
89 /** Returns whether internal widget do auto-hide. */
90 bool autoHide() const { return m_fAutoHide; }
91 /** Defines whether internal widget do @a fAutoHide.
92 * @param fPropagateToChild determines should we propagate defined
93 * option value to internal widget. */
94 void setAutoHide(bool fAutoHide, bool fPropagateToChild = true);
95
96 /** Defines @a strText for internal widget. */
97 void setText(const QString &strText);
98
99 /** Adds @a menus to internal widget. */
100 void addMenus(const QList<QMenu*> &menus);
101
102 /** Adjusts geometry. */
103 void adjustGeometry();
104
105private slots:
106
107 /** Handles internal widget resize event. */
108 void sltHandleToolbarResize();
109
110 /** Handles internal widget auto-hide toggling. */
111 void sltAutoHideToggled();
112
113 /** Handles hovering. */
114 void sltHoverEnter();
115 /** Handles unhovering. */
116 void sltHoverLeave();
117
118 /** Notifies listeners about we stole window activation. */
119 void sltNotifyAboutWindowActivationStolen() { emit sigNotifyAboutWindowActivationStolen(); }
120
121 /** Hides window. */
122 void sltHide();
123 /** Shows and adjusts window according to parent. */
124 void sltShow();
125 /** Adjusts window according to parent. */
126 void sltAdjust();
127 /** Adjusts window transience according to parent. */
128 void sltAdjustTransience();
129
130private:
131
132 /** Prepare routine. */
133 void prepare();
134 /** Cleanup routine. */
135 void cleanup();
136
137 /** Mouse enter @a pEvent handler. */
138 void enterEvent(QEvent *pEvent);
139 /** Mouse leave @a pEvent handler. */
140 void leaveEvent(QEvent *pEvent);
141
142 /** Resize @a pEvent handler. */
143 void resizeEvent(QResizeEvent *pEvent);
144
145 /** Filters @a pEvent if <i>this</i> object has been
146 * installed as an event-filter for the @a pWatched. */
147 bool eventFilter(QObject *pWatched, QEvent *pEvent);
148
149 /** Simulates auto-hide animation. */
150 void simulateToolbarAutoHiding();
151
152 /** Defines internal widget @a position. */
153 void setToolbarPosition(QPoint position);
154 /** Returns internal widget position. */
155 QPoint toolbarPosition() const;
156 /** Returns internal widget position when it's hidden. */
157 QPoint hiddenToolbarPosition() const { return m_hiddenToolbarPosition; }
158 /** Returns internal widget position when it's shown. */
159 QPoint shownToolbarPosition() const { return m_shownToolbarPosition; }
160
161 /** Returns whether the parent is currently minimized. */
162 bool isParentMinimized() const;
163
164 /** Holds the parent reference. */
165 QWidget *m_pParent;
166
167 /** Holds the geometry type. */
168 const GeometryType m_geometryType;
169 /** Holds the alignment type. */
170 Qt::Alignment m_alignment;
171 /** Holds whether we should auto-hide. */
172 bool m_fAutoHide;
173 /** Holds the parent window index. */
174 int m_iWindowIndex;
175
176 /** Holds the area. */
177 QWidget *m_pArea;
178 /** Holds the internal widget. */
179 UIMiniToolBarPrivate *m_pToolbar;
180
181 /** Holds whether we are hovered. */
182 bool m_fHovered;
183 /** Holds the hover timer. */
184 QTimer *m_pHoverEnterTimer;
185 /** Holds the unhover timer. */
186 QTimer *m_pHoverLeaveTimer;
187 /** Holds the internal widget position when it's hidden. */
188 QPoint m_hiddenToolbarPosition;
189 /** Holds the internal widget position when it's shown. */
190 QPoint m_shownToolbarPosition;
191 /** Holds the animation framework object. */
192 UIAnimation *m_pAnimation;
193
194#ifdef VBOX_WS_X11
195 /** X11: Holds whether the parent is currently minimized.
196 * Used to restore the full-screen/maximized state
197 * when the parent restored again. */
198 bool m_fIsParentMinimized;
199#endif
200};
201
202#endif /* !FEQT_INCLUDED_SRC_widgets_UIMiniToolBar_h */
203
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use