VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.h@ 103538

Last change on this file since 103538 was 102423, checked in by vboxsync, 7 months ago

FE/Qt: macOS: Adjust cocoa native colors for QIToolBar and Chooser pane global item.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.3 KB
Line 
1/* $Id: UIChooserItemGlobal.h 102423 2023-12-01 14:23:43Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIChooserItemGlobal 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_chooser_UIChooserItemGlobal_h
29#define FEQT_INCLUDED_SRC_manager_chooser_UIChooserItemGlobal_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* GUI includes: */
35#include "UIChooserItem.h"
36
37/* Forward declarations: */
38class UIChooserNodeGlobal;
39
40
41/** UIChooserItem extension implementing global item. */
42class UIChooserItemGlobal : public UIChooserItem
43{
44 Q_OBJECT;
45
46public:
47
48 /** RTTI required for qgraphicsitem_cast. */
49 enum { Type = UIChooserNodeType_Global };
50
51 /** Build item for certain @a pNode, passing @a pParent to the base-class. */
52 UIChooserItemGlobal(UIChooserItem *pParent, UIChooserNodeGlobal *pNode);
53 /** Destructs global item. */
54 virtual ~UIChooserItemGlobal() RT_OVERRIDE;
55
56 /** @name Item stuff.
57 * @{ */
58 /** Returns global node reference. */
59 UIChooserNodeGlobal *nodeToGlobalType() const;
60
61 /** Returns whether passed @a position belongs to tool button area. */
62 bool isToolButtonArea(const QPoint &position, int iMarginMultiplier = 1) const;
63 /** Returns whether passed @a position belongs to pin button area. */
64 bool isPinButtonArea(const QPoint &position, int iMarginMultiplier = 1) const;
65 /** @} */
66
67 /** @name Layout stuff.
68 * @{ */
69 /** Returns height hint. */
70 int heightHint() const;
71 /** Defines height @a iHint. */
72 void setHeightHint(int iHint);
73 /** @} */
74
75protected:
76
77 /** @name Event-handling stuff.
78 * @{ */
79 /** Handles translation event. */
80 virtual void retranslateUi() RT_OVERRIDE;
81
82 /** Handles show @a pEvent. */
83 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
84
85 /** Handles resize @a pEvent. */
86 virtual void resizeEvent(QGraphicsSceneResizeEvent *pEvent) RT_OVERRIDE;
87
88 /** Handles mouse press @a pEvent. */
89 virtual void mousePressEvent(QGraphicsSceneMouseEvent *pEvent) RT_OVERRIDE;
90
91 /** Performs painting using passed @a pPainter, @a pOptions and optionally specified @a pWidget. */
92 virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget *pWidget = 0) RT_OVERRIDE;
93 /** @} */
94
95 /** @name Item stuff.
96 * @{ */
97 /** Returns RTTI item type. */
98 virtual int type() const RT_OVERRIDE { return Type; }
99
100 /** Defines whether item is @a fFavorite. */
101 virtual void setFavorite(bool fFavorite) RT_OVERRIDE;
102
103 /** Starts item editing. */
104 virtual void startEditing() RT_OVERRIDE;
105
106 /** Updates item. */
107 virtual void updateItem() RT_OVERRIDE;
108 /** Updates item tool-tip. */
109 virtual void updateToolTip() RT_OVERRIDE;
110 /** @} */
111
112 /** @name Children stuff.
113 * @{ */
114 /** Returns children items of certain @a enmType. */
115 virtual QList<UIChooserItem*> items(UIChooserNodeType enmType = UIChooserNodeType_Any) const RT_OVERRIDE;
116
117 /** Adds possible @a fFavorite child @a pItem to certain @a iPosition. */
118 virtual void addItem(UIChooserItem *pItem, bool fFavorite, int iPosition) RT_OVERRIDE;
119 /** Removes child @a pItem. */
120 virtual void removeItem(UIChooserItem *pItem) RT_OVERRIDE;
121
122 /** Searches for a first child item answering to specified @a strSearchTag and @a iSearchFlags. */
123 virtual UIChooserItem *searchForItem(const QString &strSearchTag, int iSearchFlags) RT_OVERRIDE;
124
125 /** Searches for a first machine child item. */
126 virtual UIChooserItem *firstMachineItem() RT_OVERRIDE;
127 /** @} */
128
129 /** @name Layout stuff.
130 * @{ */
131 /** Updates layout. */
132 virtual void updateLayout() RT_OVERRIDE;
133
134 /** Returns minimum width-hint. */
135 virtual int minimumWidthHint() const RT_OVERRIDE;
136 /** Returns minimum height-hint. */
137 virtual int minimumHeightHint() const RT_OVERRIDE;
138
139 /** Returns size-hint.
140 * @param enmWhich Brings size-hint type.
141 * @param constraint Brings size constraint. */
142 virtual QSizeF sizeHint(Qt::SizeHint enmWhich, const QSizeF &constraint = QSizeF()) const RT_OVERRIDE;
143 /** @} */
144
145 /** @name Navigation stuff.
146 * @{ */
147 /** Returns pixmap item representation. */
148 virtual QPixmap toPixmap() RT_OVERRIDE;
149
150 /** Returns whether item drop is allowed.
151 * @param pEvent Brings information about drop event.
152 * @param enmPlace Brings the place of drag token to the drop moment. */
153 virtual bool isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, UIChooserItemDragToken where) const RT_OVERRIDE;
154 /** Processes item drop.
155 * @param pEvent Brings information about drop event.
156 * @param pFromWho Brings the item according to which we choose drop position.
157 * @param enmPlace Brings the place of drag token to the drop moment (according to item mentioned above). */
158 virtual void processDrop(QGraphicsSceneDragDropEvent *pEvent, UIChooserItem *pFromWho, UIChooserItemDragToken where) RT_OVERRIDE;
159 /** Reset drag token. */
160 virtual void resetDragToken() RT_OVERRIDE;
161
162 /** Returns D&D mime data. */
163 virtual QMimeData *createMimeData() RT_OVERRIDE;
164 /** @} */
165
166private slots:
167
168 /** @name Item stuff.
169 * @{ */
170 /** Handles top-level window remaps. */
171 void sltHandleWindowRemapped();
172 /** @} */
173
174private:
175
176 /** Data field types. */
177 enum GlobalItemData
178 {
179 /* Layout hints: */
180 GlobalItemData_MarginHL,
181 GlobalItemData_MarginHR,
182 GlobalItemData_MarginV,
183 GlobalItemData_Spacing,
184 GlobalItemData_ButtonMargin,
185 };
186
187 /** @name Prepare/cleanup cascade.
188 * @{ */
189 /** Prepares all. */
190 void prepare();
191 /** Cleanups all. */
192 void cleanup();
193 /** @} */
194
195 /** @name Item stuff.
196 * @{ */
197 /** Returns abstractly stored data value for certain @a iKey. */
198 QVariant data(int iKey) const;
199 /** @} */
200
201 /** @name Layout stuff.
202 * @{ */
203 /** Updates pixmaps. */
204 void updatePixmaps();
205 /** Updates pixmap. */
206 void updatePixmap();
207 /** Updates tool pixmap. */
208 void updateToolPixmap();
209 /** Updates pin pixmap. */
210 void updatePinPixmap();
211 /** Updates minimum name width. */
212 void updateMinimumNameWidth();
213 /** Updates maximum name width. */
214 void updateMaximumNameWidth();
215 /** Updates visible name. */
216 void updateVisibleName();
217 /** @} */
218
219 /** @name Painting stuff.
220 * @{ */
221 /** Paints background using specified @a pPainter and certain @a rectangle. */
222 void paintBackground(QPainter *pPainter, const QRect &rectangle);
223 /** Paints frame using specified @a pPainter and certain @a rect. */
224 void paintFrame(QPainter *pPainter, const QRect &rectangle);
225 /** Paints global info using specified @a pPainter and certain @a pOptions. */
226 void paintGlobalInfo(QPainter *pPainter, const QRect &rectangle);
227 /** @} */
228
229 /** @name Item stuff.
230 * @{ */
231#ifdef VBOX_WS_MAC
232 /** Holds item start default darkness. */
233 int m_iDefaultColorDeviation;
234#endif
235 /** Holds item start hover lightness. */
236 int m_iHoverLightnessStart;
237 /** Holds item final hover lightness. */
238 int m_iHoverLightnessFinal;
239 /** Holds item start highlight lightness. */
240 int m_iHighlightLightnessStart;
241 /** Holds item final highlight lightness. */
242 int m_iHighlightLightnessFinal;
243
244 /** Holds item pixmap. */
245 QPixmap m_pixmap;
246 /** Holds item tool pixmap. */
247 QPixmap m_toolPixmap;
248 /** Holds item pin pixmap. */
249 QPixmap m_pinPixmap;
250
251 /** Holds item visible name. */
252 QString m_strVisibleName;
253
254 /** Holds item name font. */
255 QFont m_nameFont;
256 /** @} */
257
258 /** @name Layout stuff.
259 * @{ */
260 /** Holds pixmap size. */
261 QSize m_pixmapSize;
262 /** Holds tool pixmap size. */
263 QSize m_toolPixmapSize;
264 /** Holds pin pixmap size. */
265 QSize m_pinPixmapSize;
266 /** Holds visible name size. */
267 QSize m_visibleNameSize;
268
269 /** Holds minimum name width. */
270 int m_iMinimumNameWidth;
271 /** Holds maximum name width. */
272 int m_iMaximumNameWidth;
273
274 /** Holds the height hint. */
275 int m_iHeightHint;
276 /** @} */
277};
278
279
280#endif /* !FEQT_INCLUDED_SRC_manager_chooser_UIChooserItemGlobal_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use