VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.h

Last change on this file was 98103, checked in by vboxsync, 17 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property svn:mergeinfo set to (toggle deleted branches)
    /branches/VBox-3.0/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h58652,​70973
    /branches/VBox-3.2/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h66309,​66318
    /branches/VBox-4.0/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h70873
    /branches/VBox-4.1/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h74233
    /branches/VBox-4.2/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h91223
    /branches/VBox-4.3/trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h91223
    /branches/dsen/gui/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h79076-79078,​79089,​79109-79110,​79112-79113,​79127-79130,​79134,​79141,​79151,​79155,​79157-79159,​79193,​79197
    /branches/dsen/gui2/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h79562-79569,​79572-79573,​79578,​79581-79582,​79590-79591,​79598-79599,​79602-79603,​79605-79606,​79632,​79635,​79637,​79644
    /branches/dsen/gui3/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h79645-79692
    /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h79225,​79271
File size: 14.8 KB
Line 
1/* $Id: UIDetailsElement.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIDetailsElement class declaration.
4 */
5
6/*
7 * Copyright (C) 2012-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_manager_details_UIDetailsElement_h
29#define FEQT_INCLUDED_SRC_manager_details_UIDetailsElement_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QIcon>
36
37/* GUI includes: */
38#include "UIDetailsItem.h"
39#include "UIExtraDataDefs.h"
40#include "UITextTable.h"
41
42/* Forward declarations: */
43class QPropertyAnimation;
44class QStateMachine;
45class QTextLayout;
46class UIDetailsSet;
47class UIGraphicsRotatorButton;
48class UIGraphicsTextPane;
49class CCloudMachine;
50class CMachine;
51
52
53/** UIDetailsItem extension implementing element item. */
54class UIDetailsElement : public UIDetailsItem
55{
56 Q_OBJECT;
57 Q_PROPERTY(int animatedValue READ animatedValue WRITE setAnimatedValue);
58 Q_PROPERTY(int additionalHeight READ additionalHeight WRITE setAdditionalHeight);
59
60signals:
61
62 /** @name Item stuff.
63 * @{ */
64 /** Notifies about hover enter. */
65 void sigHoverEnter();
66 /** Notifies about hover leave. */
67 void sigHoverLeave();
68
69 /** Notifies about @a enmType element @a fToggled. */
70 void sigToggleElement(DetailsElementType enmType, bool fToggled);
71 /** Notifies about element toggle finished. */
72 void sigToggleElementFinished();
73
74 /** Notifies about element link clicked.
75 * @param strCategory Brings the link category.
76 * @param strControl Brings the wanted settings control.
77 * @param uId Brings the ID. */
78 void sigLinkClicked(const QString &strCategory, const QString &strControl, const QUuid &uId);
79 /** @} */
80
81public:
82
83 /** RTTI item type. */
84 enum { Type = UIDetailsItemType_Element };
85
86 /** Constructs element item, passing pParent to the base-class.
87 * @param enmType Brings element type.
88 * @param fOpened Brings whether element is opened. */
89 UIDetailsElement(UIDetailsSet *pParent, DetailsElementType enmType, bool fOpened);
90 /** Destructs element item. */
91 virtual ~UIDetailsElement() RT_OVERRIDE;
92
93 /** @name Item stuff.
94 * @{ */
95 /** Returns element type. */
96 DetailsElementType elementType() const { return m_enmType; }
97
98 /** Defines the @a text table as the passed one. */
99 void setText(const UITextTable &text);
100 /** Returns the reference to the text table. */
101 UITextTable &text() const;
102
103 /** Closes group in @a fAnimated way if requested. */
104 void close(bool fAnimated = true);
105 /** Returns whether group is closed. */
106 bool isClosed() const { return m_fClosed; }
107
108 /** Opens group in @a fAnimated way if requested. */
109 void open(bool fAnimated = true);
110 /** Returns whether group is opened. */
111 bool isOpened() const { return !m_fClosed; }
112
113 /** Returns whether toggle animation is running. */
114 bool isAnimationRunning() const { return m_fAnimationRunning; }
115 /** Marks animation finished. */
116 void markAnimationFinished();
117
118 /** Updates element appearance. */
119 virtual void updateAppearance();
120 /** @} */
121
122 /** @name Layout stuff.
123 * @{ */
124 /** Updates layout. */
125 virtual void updateLayout() RT_OVERRIDE;
126
127 /** Returns minimum width-hint. */
128 virtual int minimumWidthHint() const RT_OVERRIDE;
129 /** Returns minimum height-hint. */
130 virtual int minimumHeightHint() const RT_OVERRIDE;
131 /** @} */
132
133protected:
134
135 /** Data field types. */
136 enum ElementData
137 {
138 /* Hints: */
139 ElementData_Margin,
140 ElementData_Spacing
141 };
142
143 /** @name Event-handling stuff.
144 * @{ */
145 /** Handles show @a pEvent. */
146 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
147
148 /** This event handler is delivered after the widget has been resized. */
149 virtual void resizeEvent(QGraphicsSceneResizeEvent *pEvent) RT_OVERRIDE;
150
151 /** Handles hover enter @a event. */
152 virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent) RT_OVERRIDE;
153 /** Handles hover leave @a event. */
154 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent) RT_OVERRIDE;
155
156 /** Handles mouse press @a event. */
157 virtual void mousePressEvent(QGraphicsSceneMouseEvent *pEvent) RT_OVERRIDE;
158 /** Handles mouse double-click @a event. */
159 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *pEvent) RT_OVERRIDE;
160
161 /** Performs painting using passed @a pPainter, @a pOptions and optionally specified @a pWidget. */
162 virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget *pWidget = 0) RT_OVERRIDE;
163 /** @} */
164
165 /** @name Item stuff.
166 * @{ */
167 /** Returns RTTI item type. */
168 virtual int type() const RT_OVERRIDE { return Type; }
169
170 /** Returns the description of the item. */
171 virtual QString description() const RT_OVERRIDE;
172
173 /** Returns cached machine reference. */
174 const CMachine &machine();
175 /** Returns cached cloud machine reference. */
176 const CCloudMachine &cloudMachine();
177
178 /** Returns whether element is of local type. */
179 bool isLocal() const;
180
181 /** Defines element @a strName. */
182 void setName(const QString &strName);
183
184 /** Defines @a iAdditionalHeight during toggle animation. */
185 void setAdditionalHeight(int iAdditionalHeight);
186 /** Returns additional height during toggle animation. */
187 int additionalHeight() const { return m_iAdditionalHeight; }
188 /** Returns toggle button instance. */
189 UIGraphicsRotatorButton *button() const { return m_pButton; }
190
191 /** Returns abstractly stored data value for certain @a iKey. */
192 QVariant data(int iKey) const;
193 /** @} */
194
195 /** @name Children stuff.
196 * @{ */
197 /** Adds child @a pItem. */
198 virtual void addItem(UIDetailsItem *pItem) RT_OVERRIDE;
199 /** Removes child @a pItem. */
200 virtual void removeItem(UIDetailsItem *pItem) RT_OVERRIDE;
201
202 /** Returns children items of certain @a enmType. */
203 virtual QList<UIDetailsItem*> items(UIDetailsItemType enmType) const RT_OVERRIDE;
204 /** Returns whether there are children items of certain @a enmType. */
205 virtual bool hasItems(UIDetailsItemType enmType) const RT_OVERRIDE;
206 /** Clears children items of certain @a enmType. */
207 virtual void clearItems(UIDetailsItemType enmType) RT_OVERRIDE;
208 /** @} */
209
210 /** @name Layout stuff.
211 * @{ */
212 /** Returns minimum width-hint for @a fClosed element. */
213 virtual int minimumHeightHintForElement(bool fClosed) const;
214
215 /** Returns minimum header width. */
216 int minimumHeaderWidth() const { return m_iMinimumHeaderWidth; }
217 /** Returns minimum header height. */
218 int minimumHeaderHeight() const { return m_iMinimumHeaderHeight; }
219 /** @} */
220
221private slots:
222
223 /** @name Item stuff.
224 * @{ */
225 /** Handles top-level window remaps. */
226 void sltHandleWindowRemapped();
227
228 /** Handles toggle button click. */
229 void sltToggleButtonClicked();
230 /** Handles toggle start. */
231 void sltElementToggleStart();
232 /** Handles toggle finish. */
233 void sltElementToggleFinish(bool fToggled);
234
235 /** Handles child anchor clicks. */
236 void sltHandleAnchorClicked(const QString &strAnchor);
237 /** Handles child copy request. */
238 void sltHandleCopyRequest();
239 /** Handles child edit request. */
240 void sltHandleEditRequest();
241 /** @} */
242
243 /** @name Layout stuff.
244 * @{ */
245 /** Handles children geometry changes. */
246 void sltUpdateGeometry() { updateGeometry(); }
247 /** @} */
248
249 /** @name Move to sub-class.
250 * @{ */
251 /** Handles mount storage medium requests. */
252 void sltMountStorageMedium();
253 /** @} */
254
255private:
256
257 /** @name Prepare/cleanup cascade.
258 * @{ */
259 /** Prepares element. */
260 void prepareElement();
261 /** Prepares toggle button. */
262 void prepareButton();
263 /** Prepares text pane. */
264 void prepareTextPane();
265 /** @} */
266
267 /** @name Item stuff.
268 * @{ */
269 /** Updates icon. */
270 void updateIcon();
271
272 /** Defines animated @a iValue. */
273 void setAnimatedValue(int iValue) { m_iAnimatedValue = iValue; update(); }
274 /** Returns animated value. */
275 int animatedValue() const { return m_iAnimatedValue; }
276
277 /** Handles any kind of hover @a pEvent. */
278 void handleHoverEvent(QGraphicsSceneHoverEvent *pEvent);
279 /** Updates hovered link. */
280 void updateNameHoverLink();
281
282 /** Updates animation parameters. */
283 void updateAnimationParameters();
284 /** Updates toggle button visibility. */
285 void updateButtonVisibility();
286
287 /** Popups name & system editor. */
288 void popupNameAndSystemEditor(bool fChooseName, bool fChoosePath, bool fChooseType, const QString &strValue);
289 /** Popups base-memory editor. */
290 void popupBaseMemoryEditor(const QString &strValue);
291 /** Popups boot-order editor. */
292 void popupBootOrderEditor(const QString &strValue);
293 /** Popups video-memory editor. */
294 void popupVideoMemoryEditor(const QString &strValue);
295 /** Popups graphics controller type editor. */
296 void popupGraphicsControllerTypeEditor(const QString &strValue);
297 /** Popups storage editor. */
298 void popupStorageEditor(const QString &strValue);
299 /** Popups audio host-driver type editor. */
300 void popupAudioHostDriverTypeEditor(const QString &strValue);
301 /** Popups audio controller type editor. */
302 void popupAudioControllerTypeEditor(const QString &strValue);
303 /** Popups network attachment type editor. */
304 void popupNetworkAttachmentTypeEditor(const QString &strValue);
305 /** Popups USB controller type editor. */
306 void popupUSBControllerTypeEditor(const QString &strValue);
307 /** Popups visual-state type editor. */
308 void popupVisualStateTypeEditor(const QString &strValue);
309#ifndef VBOX_WS_MAC
310 /** Popups menu-bar editor. */
311 void popupMenuBarEditor(const QString &strValue);
312#endif
313 /** Popups status-bar editor. */
314 void popupStatusBarEditor(const QString &strValue);
315#ifndef VBOX_WS_MAC
316 /** Popups mini-toolbar editor. */
317 void popupMiniToolbarEditor(const QString &strValue);
318#endif
319 /** Popups cloud editor. */
320 void popupCloudEditor(const QString &strValue);
321 /** @} */
322
323 /** @name Layout stuff.
324 * @{ */
325 /** Updates minimum header width. */
326 void updateMinimumHeaderWidth();
327 /** Updates minimum header height. */
328 void updateMinimumHeaderHeight();
329 /** @} */
330
331 /** @name Painting stuff.
332 * @{ */
333 /** Paints background using specified @a pPainter and certain @a pOptions. */
334 void paintBackground(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions) const;
335 /** Paints element info using specified @a pPainter and certain @a pOptions. */
336 void paintElementInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions) const;
337
338 /** Paints @a pixmap using passed @a pPainter and spified @a rect. */
339 static void paintPixmap(QPainter *pPainter, const QRect &rect, const QPixmap &pixmap);
340 /** Paints @a strText using passed @a pPainter, @a font, @a color, @a pPaintDevice and spified @a point. */
341 static void paintText(QPainter *pPainter, QPoint point,
342 const QFont &font, QPaintDevice *pPaintDevice,
343 const QString &strText, const QColor &color);
344 /** @} */
345
346 /** @name Item stuff.
347 * @{ */
348 /** Holds the parent reference. */
349 UIDetailsSet *m_pSet;
350 /** Holds the element type. */
351 DetailsElementType m_enmType;
352
353 /** Holds the element pixmap. */
354 QPixmap m_pixmap;
355 /** Holds the element name. */
356 QString m_strName;
357
358 /** Holds the name font. */
359 QFont m_nameFont;
360 /** Holds the text font. */
361 QFont m_textFont;
362
363 /** Holds the start default darkness. */
364 int m_iDefaultDarknessStart;
365 /** Holds the final default darkness. */
366 int m_iDefaultDarknessFinal;
367
368 /** Holds whether element is hovered. */
369 bool m_fHovered;
370 /** Holds whether element name is hovered. */
371 bool m_fNameHovered;
372 /** Holds the hovering animation machine instance. */
373 QStateMachine *m_pHoveringMachine;
374 /** Holds the forward hovering animation instance. */
375 QPropertyAnimation *m_pHoveringAnimationForward;
376 /** Holds the backward hovering animation instance. */
377 QPropertyAnimation *m_pHoveringAnimationBackward;
378 /** Holds the animation duration. */
379 int m_iAnimationDuration;
380 /** Holds the default animation value. */
381 int m_iDefaultValue;
382 /** Holds the hovered animation value. */
383 int m_iHoveredValue;
384 /** Holds the animated value. */
385 int m_iAnimatedValue;
386
387 /** Holds the toggle button instance. */
388 UIGraphicsRotatorButton *m_pButton;
389 /** Holds whether element is closed. */
390 bool m_fClosed;
391 /** Holds whether animation is running. */
392 bool m_fAnimationRunning;
393 /** Holds the additional height. */
394 int m_iAdditionalHeight;
395
396 /** Holds the graphics text pane instance. */
397 UIGraphicsTextPane *m_pTextPane;
398 /** @} */
399
400 /** @name Layout stuff.
401 * @{ */
402 /** Holds the pixmap size. */
403 QSize m_pixmapSize;
404 /** Holds the name size. */
405 QSize m_nameSize;
406 /** Holds the button size. */
407 QSize m_buttonSize;
408
409 /** Holds minimum header width. */
410 int m_iMinimumHeaderWidth;
411 /** Holds minimum header height. */
412 int m_iMinimumHeaderHeight;
413 /** @} */
414};
415
416#endif /* !FEQT_INCLUDED_SRC_manager_details_UIDetailsElement_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use