VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.h@ 103977

Last change on this file since 103977 was 101562, checked in by vboxsync, 14 months ago

FE/Qt: bugref:10450: Get rid of Qt5 stuff; This one is about touch/enter events related stuff.

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