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