1 | /* $Id: UISnapshotDetailsWidget.h 103803 2024-03-12 11:15:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UISnapshotDetailsWidget class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2008-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_snapshots_UISnapshotDetailsWidget_h
|
---|
29 | #define FEQT_INCLUDED_SRC_snapshots_UISnapshotDetailsWidget_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QWidget>
|
---|
36 |
|
---|
37 | /* GUI includes: */
|
---|
38 | #include "QIWithRetranslateUI.h"
|
---|
39 | #include "UIExtraDataDefs.h"
|
---|
40 |
|
---|
41 | /* COM includes: */
|
---|
42 | #include "CGraphicsAdapter.h"
|
---|
43 | #include "CMachine.h"
|
---|
44 | #include "CSnapshot.h"
|
---|
45 |
|
---|
46 | /* Forward declarations: */
|
---|
47 | class CNetworkAdapter;
|
---|
48 | class QGridLayout;
|
---|
49 | class QLabel;
|
---|
50 | class QLineEdit;
|
---|
51 | class QScrollArea;
|
---|
52 | class QTabWidget;
|
---|
53 | class QTextEdit;
|
---|
54 | class QVBoxLayout;
|
---|
55 | class QWidget;
|
---|
56 | class QIDialogButtonBox;
|
---|
57 | class UISnapshotDetailsElement;
|
---|
58 |
|
---|
59 |
|
---|
60 | /** Snapshot pane: Snapshot data. */
|
---|
61 | class UIDataSnapshot
|
---|
62 | {
|
---|
63 | public:
|
---|
64 |
|
---|
65 | /** Constructs data. */
|
---|
66 | UIDataSnapshot()
|
---|
67 | : m_strName(QString())
|
---|
68 | , m_strDescription(QString())
|
---|
69 | {}
|
---|
70 |
|
---|
71 | /** Returns name. */
|
---|
72 | QString name() const { return m_strName; }
|
---|
73 | /** Defines @a strName. */
|
---|
74 | void setName(const QString &strName) { m_strName = strName; }
|
---|
75 |
|
---|
76 | /** Returns description. */
|
---|
77 | QString description() const { return m_strDescription; }
|
---|
78 | /** Defines @a strDescription. */
|
---|
79 | void setDescription(const QString &strDescription) { m_strDescription = strDescription; }
|
---|
80 |
|
---|
81 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
82 | bool equal(const UIDataSnapshot &other) const
|
---|
83 | {
|
---|
84 | return true
|
---|
85 | && (m_strName == other.m_strName)
|
---|
86 | && (m_strDescription == other.m_strDescription)
|
---|
87 | ;
|
---|
88 | }
|
---|
89 |
|
---|
90 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
91 | bool operator==(const UIDataSnapshot &other) const { return equal(other); }
|
---|
92 | /** Returns whether the @a other passed data is different from this one. */
|
---|
93 | bool operator!=(const UIDataSnapshot &other) const { return !equal(other); }
|
---|
94 |
|
---|
95 | protected:
|
---|
96 |
|
---|
97 | /** Holds the name. */
|
---|
98 | QString m_strName;
|
---|
99 | /** Holds the description. */
|
---|
100 | QString m_strDescription;
|
---|
101 | };
|
---|
102 |
|
---|
103 |
|
---|
104 | /** QWidget extension providing GUI with snapshot details-widget. */
|
---|
105 | class UISnapshotDetailsWidget : public QIWithRetranslateUI<QWidget>
|
---|
106 | {
|
---|
107 | Q_OBJECT;
|
---|
108 |
|
---|
109 | signals:
|
---|
110 |
|
---|
111 | /** Notifies listeners about data change accepted and should be applied. */
|
---|
112 | void sigDataChangeAccepted();
|
---|
113 |
|
---|
114 | public:
|
---|
115 |
|
---|
116 | /** Constructs snapshot details-widget passing @a pParent to the base-class. */
|
---|
117 | UISnapshotDetailsWidget(QWidget *pParent = 0);
|
---|
118 |
|
---|
119 | /** Returns the snapshot data. */
|
---|
120 | const UIDataSnapshot &data() const { return m_newData; }
|
---|
121 | /** Defines the @a comMachine. */
|
---|
122 | void setData(const CMachine &comMachine);
|
---|
123 | /** Defines the @a comSnapshot and it's @a data. */
|
---|
124 | void setData(const UIDataSnapshot &data, const CSnapshot &comSnapshot);
|
---|
125 | /** Clears the snapshot data. */
|
---|
126 | void clearData();
|
---|
127 |
|
---|
128 | protected:
|
---|
129 |
|
---|
130 | /** Handles translation event. */
|
---|
131 | virtual void retranslateUi() RT_OVERRIDE;
|
---|
132 | /** Handles buttons translation. */
|
---|
133 | void retranslateButtons();
|
---|
134 |
|
---|
135 | private slots:
|
---|
136 |
|
---|
137 | /** Handles snapshot name change. */
|
---|
138 | void sltHandleNameChange();
|
---|
139 | /** Handles snapshot description change. */
|
---|
140 | void sltHandleDescriptionChange();
|
---|
141 |
|
---|
142 | /** Handles snapshot details anchor clicks. */
|
---|
143 | void sltHandleAnchorClicked(const QUrl &link);
|
---|
144 |
|
---|
145 | /** Handles snapshot details change accepting. */
|
---|
146 | void sltHandleChangeAccepted();
|
---|
147 | /** Handles snapshot details change rejecting. */
|
---|
148 | void sltHandleChangeRejected();
|
---|
149 |
|
---|
150 | private:
|
---|
151 |
|
---|
152 | /** Prepares all. */
|
---|
153 | void prepare();
|
---|
154 | /** Prepares tab-widget. */
|
---|
155 | void prepareTabWidget();
|
---|
156 | /** Prepares 'Options' tab. */
|
---|
157 | void prepareTabOptions();
|
---|
158 | /** Prepares 'Details' tab. */
|
---|
159 | void prepareTabDetails();
|
---|
160 |
|
---|
161 | /** Creates details element of passed @a enmType. */
|
---|
162 | static UISnapshotDetailsElement *createDetailsElement(DetailsElementType enmType);
|
---|
163 |
|
---|
164 | /** Loads snapshot data. */
|
---|
165 | void loadSnapshotData();
|
---|
166 |
|
---|
167 | /** Revalidates changes for passed @a pWidget. */
|
---|
168 | void revalidate(QWidget *pWidget = 0);
|
---|
169 | /** Retranslates validation for passed @a pWidget. */
|
---|
170 | void retranslateValidation(QWidget *pWidget = 0);
|
---|
171 | /** Updates button states. */
|
---|
172 | void updateButtonStates();
|
---|
173 |
|
---|
174 | /** Returns details report of requested @a enmType for a given @a comMachine. */
|
---|
175 | QString detailsReport(DetailsElementType enmType, const CMachine &comMachine, const CSnapshot &comSnapshot = CSnapshot()) const;
|
---|
176 |
|
---|
177 | /** Acquires @a comMachine group report. */
|
---|
178 | static QString groupReport(const CMachine &comMachine);
|
---|
179 | /** Acquires @a comMachine boot order report. */
|
---|
180 | static QString bootOrderReport(const CMachine &comMachine);
|
---|
181 | /** Acquires @a comMachine efi state report. */
|
---|
182 | static QString efiStateReport(const CMachine &comMachine);
|
---|
183 | /** Acquires @a comMachine acceleration report. */
|
---|
184 | static QString accelerationReport(const CMachine &comMachine);
|
---|
185 | /** Acquires @a comMachine scale-factor report. */
|
---|
186 | static double scaleFactorReport(CMachine comMachine);
|
---|
187 | /** Acquires @a comMachine display acceleration report. */
|
---|
188 | static QString displayAccelerationReport(CGraphicsAdapter comGraphics);
|
---|
189 | /** Acquires @a comMachine VRDE server report. */
|
---|
190 | static QStringList vrdeServerReport(CMachine comMachine);
|
---|
191 | /** Acquires @a comMachine recording report. */
|
---|
192 | static QStringList recordingReport(CMachine comMachine);
|
---|
193 | /** Acquires @a comMachine storage report. */
|
---|
194 | static QPair<QStringList, QList<QMap<QString, QString> > > storageReport(CMachine comMachine);
|
---|
195 | /** Acquires @a comMachine audio report. */
|
---|
196 | static QStringList audioReport(CMachine comMachine);
|
---|
197 | /** Acquires @a comMachine network report. */
|
---|
198 | static QStringList networkReport(CMachine comMachine);
|
---|
199 | /** Acquires @a comMachine serial report. */
|
---|
200 | static QStringList serialReport(CMachine comMachine);
|
---|
201 | /** Acquires @a comMachine usb report. */
|
---|
202 | static QStringList usbReport(CMachine comMachine);
|
---|
203 |
|
---|
204 | /** Wipes the HTML stuff from the passed @a strString. */
|
---|
205 | static QString wipeHtmlStuff(const QString &strString);
|
---|
206 |
|
---|
207 | /** Prepares emhasized report for a given @a strValue, comparing to @a strOldValue. */
|
---|
208 | static QString empReport(const QString &strValue, const QString &strOldValue);
|
---|
209 | /** Prepares emhasized report for a given @a strValue, depending on @a fDo flag. */
|
---|
210 | static QString empReport(const QString &strValue, bool fIgnore);
|
---|
211 |
|
---|
212 | /** Holds the machine object to load data from. */
|
---|
213 | CMachine m_comMachine;
|
---|
214 | /** Holds the snapshot object to load data from. */
|
---|
215 | CSnapshot m_comSnapshot;
|
---|
216 |
|
---|
217 | /** Holds the old data copy. */
|
---|
218 | UIDataSnapshot m_oldData;
|
---|
219 | /** Holds the new data copy. */
|
---|
220 | UIDataSnapshot m_newData;
|
---|
221 |
|
---|
222 | /** Holds the cached screenshot. */
|
---|
223 | QPixmap m_pixmapScreenshot;
|
---|
224 |
|
---|
225 | /** Holds the tab-widget instance. */
|
---|
226 | QTabWidget *m_pTabWidget;
|
---|
227 |
|
---|
228 | /** Holds the 'Options' layout instance. */
|
---|
229 | QGridLayout *m_pLayoutOptions;
|
---|
230 |
|
---|
231 | /** Holds the name label instance. */
|
---|
232 | QLabel *m_pLabelName;
|
---|
233 | /** Holds the name editor instance. */
|
---|
234 | QLineEdit *m_pEditorName;
|
---|
235 | /** Holds the name error pane. */
|
---|
236 | QLabel *m_pErrorPaneName;
|
---|
237 |
|
---|
238 | /** Holds the description label instance. */
|
---|
239 | QLabel *m_pLabelDescription;
|
---|
240 | /** Holds the description editor instance. */
|
---|
241 | QTextEdit *m_pBrowserDescription;
|
---|
242 | /** Holds the description error pane. */
|
---|
243 | QLabel *m_pErrorPaneDescription;
|
---|
244 |
|
---|
245 | /** Holds the button-box instance. */
|
---|
246 | QIDialogButtonBox *m_pButtonBox;
|
---|
247 |
|
---|
248 | /** Holds the 'Details' layout instance. */
|
---|
249 | QVBoxLayout *m_pLayoutDetails;
|
---|
250 |
|
---|
251 | /** Holds the details scroll-area instance. */
|
---|
252 | QScrollArea *m_pScrollAreaDetails;
|
---|
253 |
|
---|
254 | /** Holds the details element map. */
|
---|
255 | QMap<DetailsElementType, UISnapshotDetailsElement*> m_details;
|
---|
256 | };
|
---|
257 |
|
---|
258 | #endif /* !FEQT_INCLUDED_SRC_snapshots_UISnapshotDetailsWidget_h */
|
---|
259 |
|
---|