VirtualBox

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

Last change on this file was 104251, checked in by vboxsync, 6 weeks ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in the manager UI classes.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use