VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h@ 102493

Last change on this file since 102493 was 99390, checked in by vboxsync, 18 months ago

FE/Qt: bugref:6669: VirtualBox Manager: Move New VD wizard onto non-modal rails; This is only for the case used in Media Manager, while Media Selector still using modal case, which is Ok.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.1 KB
Line 
1/* $Id: UIMediumManager.h 99390 2023-04-13 15:46:10Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMediumManager 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_UIMediumManager_h
29#define FEQT_INCLUDED_SRC_medium_UIMediumManager_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QUuid>
36
37/* GUI includes: */
38#include "QIManagerDialog.h"
39#include "QIWithRetranslateUI.h"
40#include "UIMediumDefs.h"
41
42/* Forward declarations: */
43class QAbstractButton;
44class QLabel;
45class QProgressBar;
46class QTabWidget;
47class QTreeWidgetItem;
48class QIDialogButtonBox;
49class QILabel;
50class QITreeWidget;
51class UIActionPool;
52class UIMedium;
53class UIMediumDetailsWidget;
54class UIMediumItem;
55class UIMediumSearchWidget;
56class QIToolBar;
57
58
59/** Functor interface allowing to check if passed UIMediumItem is suitable. */
60class CheckIfSuitableBy
61{
62public:
63
64 /** Destructs functor. */
65 virtual ~CheckIfSuitableBy() { /* Makes MSC happy. */ }
66
67 /** Determines whether passed @a pItem is suitable. */
68 virtual bool isItSuitable(UIMediumItem *pItem) const = 0;
69};
70
71
72/** Medium manager progress-bar.
73 * Reflects medium-enumeration progress, stays hidden otherwise. */
74class UIEnumerationProgressBar : public QWidget
75{
76 Q_OBJECT;
77
78public:
79
80 /** Constructor on the basis of passed @a pParent. */
81 UIEnumerationProgressBar(QWidget *pParent = 0);
82
83 /** Defines progress-bar label-text. */
84 void setText(const QString &strText);
85
86 /** Returns progress-bar current-value. */
87 int value() const;
88 /** Defines progress-bar current-value. */
89 void setValue(int iValue);
90 /** Defines progress-bar maximum-value. */
91 void setMaximum(int iValue);
92
93private:
94
95 /** Prepares progress-bar content. */
96 void prepare();
97
98 /** Progress-bar label. */
99 QLabel *m_pLabel;
100 /** Progress-bar itself. */
101 QProgressBar *m_pProgressBar;
102};
103
104
105/** QWidget extension providing GUI with the pane to control media related functionality. */
106class UIMediumManagerWidget : public QIWithRetranslateUI<QWidget>
107{
108 Q_OBJECT;
109
110 /** Item action types. */
111 enum Action { Action_Add, Action_Edit, Action_Copy, Action_Remove, Action_Release };
112
113signals:
114
115 /** Notifies listeners about creation procedure was requested. */
116 void sigCreateMedium();
117 /** Notifies listeners about copy procedure was requested for medium with specified @a uMediumId. */
118 void sigCopyMedium(const QUuid &uMediumId);
119
120 /** Notifies listeners about medium details-widget @a fVisible. */
121 void sigMediumDetailsVisibilityChanged(bool fVisible);
122 /** Notifies listeners about accept is @a fAllowed. */
123 void sigAcceptAllowed(bool fAllowed);
124 /** Notifies listeners about reject is @a fAllowed. */
125 void sigRejectAllowed(bool fAllowed);
126
127public:
128
129 /** Constructs Virtual Media Manager widget.
130 * @param enmEmbedding Brings the type of widget embedding.
131 * @param pActionPool Brings the action-pool reference.
132 * @param fShowToolbar Brings whether we should create/show toolbar. */
133 UIMediumManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool, bool fShowToolbar = true, QWidget *pParent = 0);
134
135 /** Returns the menu. */
136 QMenu *menu() const;
137
138#ifdef VBOX_WS_MAC
139 /** Returns the toolbar. */
140 QIToolBar *toolbar() const { return m_pToolBar; }
141#endif
142
143 /** Defines @a pProgressBar reference. */
144 void setProgressBar(UIEnumerationProgressBar *pProgressBar);
145
146protected:
147
148 /** @name Event-handling stuff.
149 * @{ */
150 /** Handles translation event. */
151 virtual void retranslateUi() RT_OVERRIDE;
152 /** @} */
153
154public slots:
155
156 /** @name Details-widget stuff.
157 * @{ */
158 /** Handles command to reset medium details changes. */
159 void sltResetMediumDetailsChanges();
160 /** Handles command to apply medium details changes. */
161 void sltApplyMediumDetailsChanges();
162 /** @} */
163
164private slots:
165
166 /** @name Medium operation stuff.
167 * @{ */
168 /** Handles UICommon::sigMediumCreated signal. */
169 void sltHandleMediumCreated(const QUuid &uMediumID);
170 /** Handles UICommon::sigMediumDeleted signal. */
171 void sltHandleMediumDeleted(const QUuid &uMediumID);
172 /** @} */
173
174 /** @name Medium enumeration stuff.
175 * @{ */
176 /** Handles UICommon::sigMediumEnumerationStarted signal. */
177 void sltHandleMediumEnumerationStart();
178 /** Handles UICommon::sigMediumEnumerated signal. */
179 void sltHandleMediumEnumerated(const QUuid &uMediumID);
180 /** Handles UICommon::sigMediumEnumerationFinished signal. */
181 void sltHandleMediumEnumerationFinish();
182 void sltHandleMachineStateChange(const QUuid &uId, const KMachineState state);
183 /** @} */
184
185 /** @name Menu/action stuff.
186 * @{ */
187 /** Handles command to add medium. */
188 void sltAddMedium();
189 /** Handles command to create medium. */
190 void sltCreateMedium();
191 /** Handles command to copy medium. */
192 void sltCopyMedium();
193 /** Handles command to move medium. */
194 void sltMoveMedium();
195 /** Handles command to remove medium. */
196 void sltRemoveMedium();
197 /** Handles command to release medium. */
198 void sltReleaseMedium();
199 /** Removes all inaccessible media. */
200 void sltClear();
201 /** Handles command to make medium details @a fVisible. */
202 void sltToggleMediumDetailsVisibility(bool fVisible);
203 /** Handles command to make medium search pane @a fVisible. */
204 void sltToggleMediumSearchVisibility(bool fVisible);
205 /** Handles command to refresh medium. */
206 void sltRefreshAll();
207 /** @} */
208
209 /** @name Menu/action handler stuff.
210 * @{ */
211 /** Handles medium move progress finished signal. */
212 void sltHandleMoveProgressFinished();
213 /** Handles medium resize progress finished signal. */
214 void sltHandleResizeProgressFinished();
215 /** @} */
216
217 /** @name Tab-widget stuff.
218 * @{ */
219 /** Handles tab change case. */
220 void sltHandleCurrentTabChanged();
221 /** Handles item change case. */
222 void sltHandleCurrentItemChanged();
223 /** Handles item context-menu-call case. */
224 void sltHandleContextMenuRequest(const QPoint &position);
225 /** @} */
226
227 /** @name Tree-widget stuff.
228 * @{ */
229 /** Adjusts tree-widgets according content. */
230 void sltPerformTablesAdjustment();
231 /** @} */
232
233 /** @name Medium search stuff.
234 * @{ */
235 /** Adjusts tree-widgets according content. */
236 void sltHandlePerformSearch();
237 /** @} */
238
239 /** @name Medium search stuff.
240 * @{ */
241 /** Handles command to detach COM stuff. */
242 void sltDetachCOM();
243 /** @} */
244
245private:
246
247 /** @name Prepare/cleanup cascade.
248 * @{ */
249 /** Prepares all. */
250 void prepare();
251 /** Prepares connections. */
252 void prepareConnections();
253 /** Prepares actions. */
254 void prepareActions();
255 /** Prepares widgets. */
256 void prepareWidgets();
257 /** Prepares toolbar. */
258 void prepareToolBar();
259 /** Prepares tab-widget. */
260 void prepareTabWidget();
261 /** Prepares tab-widget's tab. */
262 void prepareTab(UIMediumDeviceType type);
263 /** Prepares tab-widget's tree-widget. */
264 void prepareTreeWidget(UIMediumDeviceType type, int iColumns);
265 /** Prepares details-widget. */
266 void prepareDetailsWidget();
267 /** Prepares search-widget. */
268 void prepareSearchWidget();
269 /** Load settings: */
270 void loadSettings();
271
272 /** Repopulates tree-widgets content. */
273 void repopulateTreeWidgets();
274
275 /** Updates details according latest changes in current item of passed @a type. */
276 void refetchCurrentMediumItem(UIMediumDeviceType type);
277 /** Updates details according latest changes in current item of chosen type. */
278 void refetchCurrentChosenMediumItem();
279 /** Updates details according latest changes in all current items. */
280 void refetchCurrentMediumItems();
281
282 /** Updates actions according currently chosen item. */
283 void updateActions();
284 /** Updates action icons according currently chosen tab. */
285 void updateActionIcons();
286 /** Updates tab icons according last @a action happened with @a pItem. */
287 void updateTabIcons(UIMediumItem *pItem, Action action);
288 /** @} */
289
290 /** @name Widget operation stuff.
291 * @{ */
292 /** Creates UIMediumItem for corresponding @a medium. */
293 UIMediumItem *createMediumItem(const UIMedium &medium);
294 /** Creates UIMediumItemHD for corresponding @a medium. */
295 UIMediumItem *createHardDiskItem(const UIMedium &medium);
296 /** Updates UIMediumItem for corresponding @a medium. */
297 void updateMediumItem(const UIMedium &medium);
298 /** Deletes UIMediumItem for corresponding @a uMediumID. */
299 void deleteMediumItem(const QUuid &uMediumID);
300
301 /** Returns tab for passed medium @a type. */
302 QWidget *tab(UIMediumDeviceType type) const;
303 /** Returns tree-widget for passed medium @a type. */
304 QITreeWidget *treeWidget(UIMediumDeviceType type) const;
305 /** Returns item for passed medium @a type. */
306 UIMediumItem *mediumItem(UIMediumDeviceType type) const;
307
308 /** Returns medium type for passed @a pTreeWidget. */
309 UIMediumDeviceType mediumType(QITreeWidget *pTreeWidget) const;
310
311 /** Returns current medium type. */
312 UIMediumDeviceType currentMediumType() const;
313 /** Returns current tree-widget. */
314 QITreeWidget *currentTreeWidget() const;
315 /** Returns current item. */
316 UIMediumItem *currentMediumItem() const;
317
318 /** Defines current item for passed @a pTreeWidget as @a pItem. */
319 void setCurrentItem(QITreeWidget *pTreeWidget, QTreeWidgetItem *pItem);
320
321 void enableClearAction();
322 /** @} */
323
324 /** @name Search stuff.
325 * @{ */
326 /** Calls the UIMediumSearchWidget::search(..). */
327 void performSearch(bool fSelectNext);
328 /** @} */
329
330 /** @name Helper stuff.
331 * @{ */
332 /** Returns tab index for passed UIMediumDeviceType. */
333 static int tabIndex(UIMediumDeviceType type);
334
335 /** Performs search for the @a pTree child which corresponds to the @a condition but not @a pException. */
336 static UIMediumItem *searchItem(QITreeWidget *pTree,
337 const CheckIfSuitableBy &condition,
338 CheckIfSuitableBy *pException = 0);
339 /** Performs search for the @a pParentItem child which corresponds to the @a condition but not @a pException. */
340 static UIMediumItem *searchItem(QTreeWidgetItem *pParentItem,
341 const CheckIfSuitableBy &condition,
342 CheckIfSuitableBy *pException = 0);
343
344
345 /** Checks if @a action can be used for @a pItem. */
346 static bool checkMediumFor(UIMediumItem *pItem, Action action);
347
348 /** Casts passed QTreeWidgetItem @a pItem to UIMediumItem if possible. */
349 static UIMediumItem *toMediumItem(QTreeWidgetItem *pItem);
350 /** @} */
351
352 /** @name General variables.
353 * @{ */
354 /** Holds the widget embedding type. */
355 const EmbedTo m_enmEmbedding;
356 /** Holds the action-pool reference. */
357 UIActionPool *m_pActionPool;
358 /** Holds whether we should create/show toolbar. */
359 const bool m_fShowToolbar;
360
361 /** Holds whether Virtual Media Manager should preserve current item change. */
362 bool m_fPreventChangeCurrentItem;
363 /** @} */
364
365 /** @name Tab-widget variables.
366 * @{ */
367 /** Holds the tab-widget instance. */
368 QTabWidget *m_pTabWidget;
369 /** Holds the tab-widget tab-count. */
370 const int m_iTabCount;
371 /** Holds the map of tree-widget instances. */
372 QMap<int, QITreeWidget*> m_trees;
373 /** Holds whether hard-drive tab-widget have inaccessible item. */
374 bool m_fInaccessibleHD;
375 /** Holds whether optical-disk tab-widget have inaccessible item. */
376 bool m_fInaccessibleCD;
377 /** Holds whether floppy-disk tab-widget have inaccessible item. */
378 bool m_fInaccessibleFD;
379 /** Holds cached hard-drive tab-widget icon. */
380 const QIcon m_iconHD;
381 /** Holds cached optical-disk tab-widget icon. */
382 const QIcon m_iconCD;
383 /** Holds cached floppy-disk tab-widget icon. */
384 const QIcon m_iconFD;
385 /** Holds current hard-drive tree-view item ID. */
386 QUuid m_uCurrentIdHD;
387 /** Holds current optical-disk tree-view item ID. */
388 QUuid m_uCurrentIdCD;
389 /** Holds current floppy-disk tree-view item ID. */
390 QUuid m_uCurrentIdFD;
391 /** @} */
392
393 /** @name Details-widget variables.
394 * @{ */
395 /** Holds the medium details-widget instance. */
396 UIMediumDetailsWidget *m_pDetailsWidget;
397 /** @} */
398
399 /** @name Toolbar and menu variables.
400 * @{ */
401 /** Holds the toolbar widget instance. */
402 QIToolBar *m_pToolBar;
403 /** @} */
404
405 /** @name Progress-bar variables.
406 * @{ */
407 /** Holds the progress-bar widget reference. */
408 UIEnumerationProgressBar *m_pProgressBar;
409 /** @} */
410
411 /** @name Search-widget variables.
412 * @{ */
413 /** Holds the medium details-widget instance. */
414 UIMediumSearchWidget *m_pSearchWidget;
415 /** @} */
416
417};
418
419
420/** QIManagerDialogFactory extension used as a factory for Virtual Media Manager dialog. */
421class UIMediumManagerFactory : public QIManagerDialogFactory
422{
423public:
424
425 /** Constructs Media Manager factory acquiring additional arguments.
426 * @param pActionPool Brings the action-pool reference. */
427 UIMediumManagerFactory(UIActionPool *pActionPool = 0);
428
429protected:
430
431 /** Creates derived @a pDialog instance.
432 * @param pCenterWidget Brings the widget reference to center according to. */
433 virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) RT_OVERRIDE;
434
435 /** Holds the action-pool reference. */
436 UIActionPool *m_pActionPool;
437};
438
439
440/** QIManagerDialog extension providing GUI with the dialog to control media related functionality. */
441class UIMediumManager : public QIWithRetranslateUI<QIManagerDialog>
442{
443 Q_OBJECT;
444
445signals:
446
447 /** Notifies listeners about data change rejected and should be reseted. */
448 void sigDataChangeRejected();
449 /** Notifies listeners about data change accepted and should be applied. */
450 void sigDataChangeAccepted();
451
452private slots:
453
454 /** @name Button-box stuff.
455 * @{ */
456 /** Handles button-box button click. */
457 void sltHandleButtonBoxClick(QAbstractButton *pButton);
458 /** @} */
459
460private:
461
462 /** Constructs Medium Manager dialog.
463 * @param pCenterWidget Brings the widget reference to center according to.
464 * @param pActionPool Brings the action-pool reference. */
465 UIMediumManager(QWidget *pCenterWidget, UIActionPool *pActionPool);
466
467 /** @name Event-handling stuff.
468 * @{ */
469 /** Handles translation event. */
470 virtual void retranslateUi() RT_OVERRIDE;
471 /** @} */
472
473 /** @name Prepare/cleanup cascade.
474 * @{ */
475 /** Configures all. */
476 virtual void configure() RT_OVERRIDE;
477 /** Configures central-widget. */
478 virtual void configureCentralWidget() RT_OVERRIDE;
479 /** Configures button-box. */
480 virtual void configureButtonBox() RT_OVERRIDE;
481 /** Perform final preparations. */
482 virtual void finalize() RT_OVERRIDE;
483 /** @} */
484
485 /** @name Widget stuff.
486 * @{ */
487 /** Returns the widget. */
488 virtual UIMediumManagerWidget *widget() RT_OVERRIDE;
489 /** @} */
490
491 /** @name Action related variables.
492 * @{ */
493 /** Holds the action-pool reference. */
494 UIActionPool *m_pActionPool;
495 /** @} */
496
497 /** @name Progress-bar variables.
498 * @{ */
499 /** Holds the progress-bar widget instance. */
500 UIEnumerationProgressBar *m_pProgressBar;
501 /** @} */
502
503 /** Allow factory access to private/protected members: */
504 friend class UIMediumManagerFactory;
505};
506
507#endif /* !FEQT_INCLUDED_SRC_medium_UIMediumManager_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