1 | /* $Id: UIMediumDetailsWidget.h 103803 2024-03-12 11:15:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIMediumDetailsWidget class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-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_medium_UIMediumDetailsWidget_h
|
---|
29 | #define FEQT_INCLUDED_SRC_medium_UIMediumDetailsWidget_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 "QIManagerDialog.h"
|
---|
39 | #include "QIWithRetranslateUI.h"
|
---|
40 | #include "UIMediumDefs.h"
|
---|
41 |
|
---|
42 | /* COM includes: */
|
---|
43 | #include "KMediumType.h"
|
---|
44 | #include "KMediumVariant.h"
|
---|
45 |
|
---|
46 | /* Forward declarations: */
|
---|
47 | class QAbstractButton;
|
---|
48 | class QComboBox;
|
---|
49 | class QLabel;
|
---|
50 | class QLineEdit;
|
---|
51 | class QStackedLayout;
|
---|
52 | class QTextEdit;
|
---|
53 | class QWidget;
|
---|
54 | class QILabel;
|
---|
55 | class QITabWidget;
|
---|
56 | class QIToolButton;
|
---|
57 | class UIEnumerationProgressBar;
|
---|
58 | class UIMediumManagerWidget;
|
---|
59 | class UIMediumSizeEditor;
|
---|
60 |
|
---|
61 |
|
---|
62 | /** Virtual Media Manager: Medium options data structure. */
|
---|
63 | struct UIDataMediumOptions
|
---|
64 | {
|
---|
65 | /** Constructs data. */
|
---|
66 | UIDataMediumOptions()
|
---|
67 | : m_enmMediumType(KMediumType_Normal)
|
---|
68 | , m_strLocation(QString())
|
---|
69 | , m_strDescription(QString())
|
---|
70 | , m_uLogicalSize(0)
|
---|
71 | {}
|
---|
72 |
|
---|
73 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
74 | bool equal(const UIDataMediumOptions &other) const
|
---|
75 | {
|
---|
76 | return true
|
---|
77 | && (m_enmMediumType == other.m_enmMediumType)
|
---|
78 | && (m_strLocation == other.m_strLocation)
|
---|
79 | && (m_strDescription == other.m_strDescription)
|
---|
80 | && (m_uLogicalSize == other.m_uLogicalSize)
|
---|
81 | ;
|
---|
82 | }
|
---|
83 |
|
---|
84 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
85 | bool operator==(const UIDataMediumOptions &other) const { return equal(other); }
|
---|
86 | /** Returns whether the @a other passed data is different from this one. */
|
---|
87 | bool operator!=(const UIDataMediumOptions &other) const { return !equal(other); }
|
---|
88 |
|
---|
89 | /** Holds the medium type. */
|
---|
90 | KMediumType m_enmMediumType;
|
---|
91 | /** Holds the location. */
|
---|
92 | QString m_strLocation;
|
---|
93 | /** Holds the description. */
|
---|
94 | QString m_strDescription;
|
---|
95 | /** Holds the logical size. */
|
---|
96 | qulonglong m_uLogicalSize;
|
---|
97 | };
|
---|
98 |
|
---|
99 |
|
---|
100 | /** Virtual Media Manager: Medium details data structure. */
|
---|
101 | struct UIDataMediumDetails
|
---|
102 | {
|
---|
103 | /** Constructs data. */
|
---|
104 | UIDataMediumDetails()
|
---|
105 | : m_aLabels(QStringList())
|
---|
106 | , m_aFields(QStringList())
|
---|
107 | {}
|
---|
108 |
|
---|
109 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
110 | bool equal(const UIDataMediumDetails &other) const
|
---|
111 | {
|
---|
112 | return true
|
---|
113 | && (m_aLabels == other.m_aLabels)
|
---|
114 | && (m_aFields == other.m_aFields)
|
---|
115 | ;
|
---|
116 | }
|
---|
117 |
|
---|
118 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
119 | bool operator==(const UIDataMediumDetails &other) const { return equal(other); }
|
---|
120 | /** Returns whether the @a other passed data is different from this one. */
|
---|
121 | bool operator!=(const UIDataMediumDetails &other) const { return !equal(other); }
|
---|
122 |
|
---|
123 | /** Holds the labels list. */
|
---|
124 | QStringList m_aLabels;
|
---|
125 | /** Holds the fields list. */
|
---|
126 | QStringList m_aFields;
|
---|
127 | };
|
---|
128 |
|
---|
129 |
|
---|
130 | /** Virtual Media Manager: Medium data structure. */
|
---|
131 | struct UIDataMedium
|
---|
132 | {
|
---|
133 | /** Constructs data. */
|
---|
134 | UIDataMedium()
|
---|
135 | : m_fValid(false)
|
---|
136 | , m_enmDeviceType(UIMediumDeviceType_Invalid)
|
---|
137 | , m_enmVariant(KMediumVariant_Max)
|
---|
138 | , m_fHasChildren(false)
|
---|
139 | , m_options(UIDataMediumOptions())
|
---|
140 | , m_details(UIDataMediumDetails())
|
---|
141 | {}
|
---|
142 |
|
---|
143 | /** Constructs data with passed @enmType. */
|
---|
144 | UIDataMedium(UIMediumDeviceType enmType)
|
---|
145 | : m_fValid(false)
|
---|
146 | , m_enmDeviceType(enmType)
|
---|
147 | , m_enmVariant(KMediumVariant_Max)
|
---|
148 | , m_fHasChildren(false)
|
---|
149 | , m_options(UIDataMediumOptions())
|
---|
150 | , m_details(UIDataMediumDetails())
|
---|
151 | {}
|
---|
152 |
|
---|
153 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
154 | bool equal(const UIDataMedium &other) const
|
---|
155 | {
|
---|
156 | return true
|
---|
157 | && (m_fValid == other.m_fValid)
|
---|
158 | && (m_enmDeviceType == other.m_enmDeviceType)
|
---|
159 | && (m_enmVariant == other.m_enmVariant)
|
---|
160 | && (m_fHasChildren == other.m_fHasChildren)
|
---|
161 | && (m_options == other.m_options)
|
---|
162 | && (m_details == other.m_details)
|
---|
163 | ;
|
---|
164 | }
|
---|
165 |
|
---|
166 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
167 | bool operator==(const UIDataMedium &other) const { return equal(other); }
|
---|
168 | /** Returns whether the @a other passed data is different from this one. */
|
---|
169 | bool operator!=(const UIDataMedium &other) const { return !equal(other); }
|
---|
170 |
|
---|
171 | /** Holds whether data is valid. */
|
---|
172 | bool m_fValid;
|
---|
173 | /** Holds the medium type. */
|
---|
174 | UIMediumDeviceType m_enmDeviceType;
|
---|
175 | /** Holds the medium variant. */
|
---|
176 | KMediumVariant m_enmVariant;
|
---|
177 | /** Holds whether medium has children. */
|
---|
178 | bool m_fHasChildren;
|
---|
179 |
|
---|
180 | /** Holds the medium options. */
|
---|
181 | UIDataMediumOptions m_options;
|
---|
182 | /** Holds the details data. */
|
---|
183 | UIDataMediumDetails m_details;
|
---|
184 | };
|
---|
185 |
|
---|
186 |
|
---|
187 | /** Virtual Media Manager: Virtual Media Manager details-widget. */
|
---|
188 | class UIMediumDetailsWidget : public QIWithRetranslateUI<QWidget>
|
---|
189 | {
|
---|
190 | Q_OBJECT;
|
---|
191 |
|
---|
192 | signals:
|
---|
193 |
|
---|
194 | /** Notifies listeners about accept is allowed. */
|
---|
195 | void sigAcceptAllowed(bool fAllowed);
|
---|
196 | /** Notifies listeners about reject is allowed. */
|
---|
197 | void sigRejectAllowed(bool fAllowed);
|
---|
198 |
|
---|
199 | /** Notifies listeners about data change rejected and should be reseted. */
|
---|
200 | void sigDataChangeRejected();
|
---|
201 | /** Notifies listeners about data change accepted and should be applied. */
|
---|
202 | void sigDataChangeAccepted();
|
---|
203 |
|
---|
204 | public:
|
---|
205 |
|
---|
206 | /** Constructs medium details dialog passing @a pParent to the base-class.
|
---|
207 | * @param enmEmbedding Brings embedding type. */
|
---|
208 | UIMediumDetailsWidget(UIMediumManagerWidget *pParent, EmbedTo enmEmbedding);
|
---|
209 |
|
---|
210 | /** Defines the raised details @a enmType. */
|
---|
211 | void setCurrentType(UIMediumDeviceType enmType);
|
---|
212 |
|
---|
213 | /** Returns the medium data. */
|
---|
214 | const UIDataMedium &data() const { return m_newData; }
|
---|
215 | /** Defines the @a data for passed @a enmType. */
|
---|
216 | void setData(const UIDataMedium &data);
|
---|
217 | /** Enables/disables some of the medium editing widgets of the details tab. */
|
---|
218 | void enableDisableMediumModificationWidgets(bool fMediumIsModifiable);
|
---|
219 |
|
---|
220 | public slots:
|
---|
221 |
|
---|
222 | /** Defines whether the options tab is @a fEnabled. */
|
---|
223 | void setOptionsEnabled(bool fEnabled);
|
---|
224 |
|
---|
225 | protected:
|
---|
226 |
|
---|
227 | /** Handles translation event. */
|
---|
228 | virtual void retranslateUi() RT_OVERRIDE;
|
---|
229 |
|
---|
230 | private slots:
|
---|
231 |
|
---|
232 | /** @name Options stuff.
|
---|
233 | * @{ */
|
---|
234 | /** Handles type change. */
|
---|
235 | void sltTypeIndexChanged(int iIndex);
|
---|
236 | /** Handles location change. */
|
---|
237 | void sltLocationPathChanged(const QString &strPath);
|
---|
238 | /** Handles request to choose location. */
|
---|
239 | void sltChooseLocationPath();
|
---|
240 | /** Handles description text change. */
|
---|
241 | void sltDescriptionTextChanged();
|
---|
242 | /** Handles size editor change. */
|
---|
243 | void sltSizeValueChanged(qulonglong uSize);
|
---|
244 |
|
---|
245 | /** Handles button-box button click. */
|
---|
246 | void sltHandleButtonBoxClick(QAbstractButton *pButton);
|
---|
247 | /** @} */
|
---|
248 |
|
---|
249 | private:
|
---|
250 |
|
---|
251 | /** @name Prepare/cleanup cascade.
|
---|
252 | * @{ */
|
---|
253 | /** Prepares all. */
|
---|
254 | void prepare();
|
---|
255 | /** Prepares this. */
|
---|
256 | void prepareThis();
|
---|
257 | /** Prepares tab-widget. */
|
---|
258 | void prepareTabWidget();
|
---|
259 | /** Prepares 'Options' tab. */
|
---|
260 | void prepareTabOptions();
|
---|
261 | /** Prepares 'Details' tab. */
|
---|
262 | void prepareTabDetails();
|
---|
263 | /** Prepares information-container. */
|
---|
264 | void prepareInformationContainer(UIMediumDeviceType enmType, int cFields);
|
---|
265 | /** @} */
|
---|
266 |
|
---|
267 | /** @name Loading stuff.
|
---|
268 | * @{ */
|
---|
269 | /** Load options data. */
|
---|
270 | void loadDataForOptions();
|
---|
271 | /** Load details data. */
|
---|
272 | void loadDataForDetails();
|
---|
273 | /** @} */
|
---|
274 |
|
---|
275 | /** @name Options stuff.
|
---|
276 | * @{ */
|
---|
277 | /** Revalidates changes for passed @a pWidget. */
|
---|
278 | void revalidate(QWidget *pWidget = 0);
|
---|
279 | /** Retranslates validation for passed @a pWidget. */
|
---|
280 | void retranslateValidation(QWidget *pWidget = 0);
|
---|
281 | /** Updates button states. */
|
---|
282 | void updateButtonStates();
|
---|
283 |
|
---|
284 | /** Returns tool-tip for passed medium @a enmType. */
|
---|
285 | static QString mediumTypeTip(KMediumType enmType);
|
---|
286 | /** @} */
|
---|
287 |
|
---|
288 | /** @name Details stuff.
|
---|
289 | * @{ */
|
---|
290 | /** Returns information-container for passed medium @a enmType. */
|
---|
291 | QWidget *infoContainer(UIMediumDeviceType enmType) const;
|
---|
292 | /** Returns information-label for passed medium @a enmType and @a iIndex. */
|
---|
293 | QLabel *infoLabel(UIMediumDeviceType enmType, int iIndex) const;
|
---|
294 | /** Returns information-field for passed medium @a enmType and @a iIndex. */
|
---|
295 | QILabel *infoField(UIMediumDeviceType enmType, int iIndex) const;
|
---|
296 | /** @} */
|
---|
297 |
|
---|
298 | /** @name General variables.
|
---|
299 | * @{ */
|
---|
300 | /** Holds the parent reference. */
|
---|
301 | UIMediumManagerWidget *m_pParent;
|
---|
302 | /** Holds the parent widget embedding type. */
|
---|
303 | const EmbedTo m_enmEmbedding;
|
---|
304 |
|
---|
305 | /** Holds the old data copy. */
|
---|
306 | UIDataMedium m_oldData;
|
---|
307 | /** Holds the new data copy. */
|
---|
308 | UIDataMedium m_newData;
|
---|
309 |
|
---|
310 | /** Holds the tab-widget. */
|
---|
311 | QITabWidget *m_pTabWidget;
|
---|
312 | /** @} */
|
---|
313 |
|
---|
314 | /** @name Options variables.
|
---|
315 | * @{ */
|
---|
316 | /** Holds the type label. */
|
---|
317 | QLabel *m_pLabelType;
|
---|
318 | /** Holds the type combo-box. */
|
---|
319 | QComboBox *m_pComboBoxType;
|
---|
320 | /** Holds the type error pane. */
|
---|
321 | QLabel *m_pErrorPaneType;
|
---|
322 |
|
---|
323 | /** Holds the location label. */
|
---|
324 | QLabel *m_pLabelLocation;
|
---|
325 | /** Holds the location editor. */
|
---|
326 | QLineEdit *m_pEditorLocation;
|
---|
327 | /** Holds the location error pane. */
|
---|
328 | QLabel *m_pErrorPaneLocation;
|
---|
329 | /** Holds the location button. */
|
---|
330 | QIToolButton *m_pButtonLocation;
|
---|
331 |
|
---|
332 | /** Holds the description label. */
|
---|
333 | QLabel *m_pLabelDescription;
|
---|
334 | /** Holds the description editor. */
|
---|
335 | QTextEdit *m_pEditorDescription;
|
---|
336 | /** Holds the description error pane. */
|
---|
337 | QLabel *m_pErrorPaneDescription;
|
---|
338 |
|
---|
339 | /** Holds the size label. */
|
---|
340 | QLabel *m_pLabelSize;
|
---|
341 | /** Holds the size editor. */
|
---|
342 | UIMediumSizeEditor *m_pEditorSize;
|
---|
343 | /** Holds the size error pane. */
|
---|
344 | QLabel *m_pErrorPaneSize;
|
---|
345 |
|
---|
346 | /** Holds the button-box instance. */
|
---|
347 | QIDialogButtonBox *m_pButtonBox;
|
---|
348 | /** Holds the progress-bar widget instance. */
|
---|
349 | UIEnumerationProgressBar *m_pProgressBar;
|
---|
350 |
|
---|
351 | /** Holds whether options are valid. */
|
---|
352 | bool m_fValid;
|
---|
353 | /** @} */
|
---|
354 |
|
---|
355 | /** @name Details variables.
|
---|
356 | * @{ */
|
---|
357 | /** Holds the details layout: */
|
---|
358 | QStackedLayout *m_pLayoutDetails;
|
---|
359 |
|
---|
360 | /** Holds the map of information-container instances. */
|
---|
361 | QMap<UIMediumDeviceType, QWidget*> m_aContainers;
|
---|
362 | /** Holds the map of information-container label instances. */
|
---|
363 | QMap<UIMediumDeviceType, QList<QLabel*> > m_aLabels;
|
---|
364 | /** Holds the information-container field instances. */
|
---|
365 | QMap<UIMediumDeviceType, QList<QILabel*> > m_aFields;
|
---|
366 | /** @} */
|
---|
367 | };
|
---|
368 |
|
---|
369 | #endif /* !FEQT_INCLUDED_SRC_medium_UIMediumDetailsWidget_h */
|
---|