VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIMachinePreview.h@ 103977

Last change on this file since 103977 was 103803, checked in by vboxsync, 11 months ago

FE/Qt. bugref:10618. Splitting COMEnums.h file into individual enum header files.

  • 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/UIVMPreviewWindow.h58652,​70973
    /branches/VBox-3.2/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.h66309,​66318
    /branches/VBox-4.0/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.h70873
    /branches/VBox-4.1/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.h74233
    /branches/VBox-4.2/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGMachinePreview.h91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGMachinePreview.h91223
    /branches/VBox-4.3/trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGMachinePreview.h91223
    /branches/dsen/gui/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.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/UIGMachinePreview.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/UIGMachinePreview.h79645-79692
    /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.h79225,​79271
File size: 6.7 KB
Line 
1/* $Id: UIMachinePreview.h 103803 2024-03-12 11:15:18Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMachinePreview class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-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_UIMachinePreview_h
29#define FEQT_INCLUDED_SRC_manager_details_UIMachinePreview_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QHash>
36
37/* GUI includes: */
38#include "QIWithRetranslateUI.h"
39#include "UIDetailsItem.h"
40#include "UIExtraDataDefs.h"
41
42/* COM includes: */
43#include "CMachine.h"
44#include "CSession.h"
45
46/* Forward declarations: */
47class QAction;
48class QImage;
49class QPixmap;
50class QMenu;
51class QTimer;
52
53/** QIGraphicsWidget sub-class used as VM Preview widget inside Details pane. */
54class UIMachinePreview : public QIWithRetranslateUI4<QIGraphicsWidget>
55{
56 Q_OBJECT;
57
58signals:
59
60 /** @name Layout stuff.
61 * @{ */
62 /** Notifies about size-hint changes. */
63 void sigSizeHintChanged();
64 /** @} */
65
66public:
67
68 /** RTTI item type. */
69 enum { Type = UIDetailsItemType_Preview };
70
71 /** Constructs preview element, passing pParent to the base-class. */
72 UIMachinePreview(QIGraphicsWidget *pParent);
73 /** Destructs preview element. */
74 virtual ~UIMachinePreview() RT_OVERRIDE;
75
76 /** @name Item stuff.
77 * @{ */
78 /** Defines @a comMachine to make preview for. */
79 void setMachine(const CMachine &comMachine);
80 /** Retuirns machine we do preview for. */
81 CMachine machine() const;
82 /** @} */
83
84protected:
85
86 /** @name Event-handling stuff.
87 * @{ */
88 /** Handles translation event. */
89 virtual void retranslateUi() RT_OVERRIDE;
90
91 /** Handles resize @a pEvent. */
92 virtual void resizeEvent(QGraphicsSceneResizeEvent *pEvent) RT_OVERRIDE;
93
94 /** Handles show @a pEvent. */
95 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
96 /** Handles hide @a pEvent. */
97 virtual void hideEvent(QHideEvent *pEvent) RT_OVERRIDE;
98
99 /** Handles context-menu @a pEvent. */
100 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *pEvent) RT_OVERRIDE;
101
102 /** Performs painting using passed @a pPainter, @a pOptions and optionally specified @a pWidget. */
103 virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget *pWidget = 0) RT_OVERRIDE;
104 /** @} */
105
106 /** @name Item stuff.
107 * @{ */
108 /** Returns RTTI item type. */
109 virtual int type() const RT_OVERRIDE { return Type; }
110 /** @} */
111
112 /** @name Layout stuff.
113 * @{ */
114 /** Returns size-hint.
115 * @param enmWhich Brings size-hint type.
116 * @param constraint Brings size constraint. */
117 virtual QSizeF sizeHint(Qt::SizeHint enmWhich, const QSizeF &constraint = QSizeF()) const RT_OVERRIDE;
118 /** @} */
119
120private slots:
121
122 /** @name Event-handling stuff.
123 * @{ */
124 /** Handles machine-state change for item with @a uId. */
125 void sltMachineStateChange(const QUuid &uId);
126 /** @} */
127
128 /** @name Item stuff.
129 * @{ */
130 /** Handles request to recreate preview. */
131 void sltRecreatePreview();
132 /** @} */
133
134private:
135
136 /** Aspect ratio presets. */
137 enum AspectRatioPreset
138 {
139 AspectRatioPreset_16x10,
140 AspectRatioPreset_16x9,
141 AspectRatioPreset_4x3,
142 };
143
144 /** @name Prepare/cleanup cascade.
145 * @{ */
146 /** Prepares all. */
147 void prepare();
148
149 /** Cleanups all. */
150 void cleanup();
151 /** @} */
152
153 /** @name Item stuff.
154 * @{ */
155 /** Define update @a enmInterval, @a fSave it if requested. */
156 void setUpdateInterval(PreviewUpdateIntervalType enmInterval, bool fSave);
157
158 /** Recalculates preview rectangle. */
159 void recalculatePreviewRectangle();
160
161 /** Restarts preview uppdate routine. */
162 void restart();
163 /** Stops preview uppdate routine. */
164 void stop();
165 /** @} */
166
167 /** Looks for the best aspect-ratio preset for the passed @a dAspectRatio among all the passed @a ratios. */
168 static AspectRatioPreset bestAspectRatioPreset(const double dAspectRatio, const QMap<AspectRatioPreset, double> &ratios);
169 /** Calculates image size suitable to passed @a hostSize and @a guestSize. */
170 static QSize imageAspectRatioSize(const QSize &hostSize, const QSize &guestSize);
171
172 /** @name Item stuff.
173 * @{ */
174 /** Holds the session reference. */
175 CSession m_comSession;
176 /** Holds the machine reference. */
177 CMachine m_comMachine;
178
179 /** Holds the update timer instance. */
180 QTimer *m_pUpdateTimer;
181 /** Holds the update timer menu instance. */
182 QMenu *m_pUpdateTimerMenu;
183 /** Holds the update timer menu action list. */
184 QHash<PreviewUpdateIntervalType, QAction*> m_actions;
185 /** @} */
186
187 /** @name Layout stuff.
188 * @{ */
189 /** Holds the aspect-ratio of the preview. */
190 double m_dRatio;
191 /** Holds the layout margin. */
192 const int m_iMargin;
193 /** Holds the viewport rectangle. */
194 QRect m_vRect;
195
196 /** Holds the current aspect-ratio preset. */
197 AspectRatioPreset m_enmPreset;
198 /** Holds the aspect-ratio preset sizes. */
199 QMap<AspectRatioPreset, QSize> m_sizes;
200 /** Holds the aspect-ratio preset ratios. */
201 QMap<AspectRatioPreset, double> m_ratios;
202 /** Holds the aspect-ratio preset empty pixmaps. */
203 QMap<AspectRatioPreset, QPixmap*> m_emptyPixmaps;
204 /** Holds the aspect-ratio preset filled pixmaps. */
205 QMap<AspectRatioPreset, QPixmap*> m_fullPixmaps;
206 /** @} */
207
208 /** @name Painting stuff.
209 * @{ */
210 /** Holds the preview image instance. */
211 QImage *m_pPreviewImg;
212 /** Holds the preview name. */
213 QString m_strPreviewName;
214 /** @} */
215};
216
217#endif /* !FEQT_INCLUDED_SRC_manager_details_UIMachinePreview_h */
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