VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h

Last change on this file was 104226, checked in by vboxsync, 6 weeks ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in medium manager related classes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1/* $Id: UIMediumSelector.h 104226 2024-04-08 12:07:43Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMediumSelector 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_UIMediumSelector_h
29#define FEQT_INCLUDED_SRC_medium_UIMediumSelector_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* GUI includes: */
35#include "QIMainDialog.h"
36#include "QIWithRestorableGeometry.h"
37#include "UIMedium.h"
38#include "UIMediumDefs.h"
39
40
41/* Forward declarations: */
42class QAction;
43class QTreeWidgetItem;
44class QITreeWidget;
45class QITreeWidgetItem;
46class QVBoxLayout;
47class QIDialogButtonBox;
48class QIToolBar;
49class UIActionPool;
50class UIMediumItem;
51class UIMediumSearchWidget;
52
53/** QIDialog extension providing GUI with a dialog to select an existing medium. */
54class SHARED_LIBRARY_STUFF UIMediumSelector : public QIWithRestorableGeometry<QIMainDialog>
55{
56
57 Q_OBJECT;
58
59signals:
60
61public:
62
63 UIMediumSelector(const QUuid &uCurrentMediumId, UIMediumDeviceType enmMediumType, const QString &machineName,
64 const QString &machineSettingsFilePath, const QString &strMachineGuestOSTypeId,
65 const QUuid &uMachineID, QWidget *pParent, UIActionPool *pActionPool);
66 /** Disables/enables the create action and controls its visibility. */
67 void setEnableCreateAction(bool fEnable);
68 QList<QUuid> selectedMediumIds() const;
69
70 enum ReturnCode
71 {
72 ReturnCode_Rejected = 0,
73 ReturnCode_Accepted,
74 ReturnCode_LeftEmpty,
75 ReturnCode_Max
76 };
77
78 /** Creates and shows a UIMediumSelector dialog.
79 * @param parent Passes the parent of the dialog,
80 * @param enmMediumType Passes the medium type,
81 * @param uCurrentMediumId Passes the id of the currently selected medium,
82 * @param uSelectedMediumUuid Gets the selected medium id from selection dialog,
83 * @param strMachineFolder Passes the machine folder,
84 * @param strMachineName Passes the name of the machine,
85 * @param strMachineGuestOSTypeId Passes the type ID of machine's guest os,
86 * @param fEnableCreate Passes whether to show/enable create action in the medium selector dialog,
87 * @param uMachineID Passes the machine UUID,
88 * @param pActionPool Passes the action pool instance pointer,
89 * returns the return code of the UIMediumSelector::ReturnCode as int. In case of a medium selection
90 * UUID of the selected medium is returned in @param uSelectedMediumUuid.*/
91 static int openMediumSelectorDialog(QWidget *pParent, UIMediumDeviceType enmMediumType, const QUuid &uCurrentMediumId,
92 QUuid &uSelectedMediumUuid, const QString &strMachineFolder, const QString &strMachineName,
93 const QString &strMachineGuestOSTypeId, bool fEnableCreate, const QUuid &uMachineID,
94 UIActionPool *pActionPool);
95
96protected:
97
98 /** @name Event-handling stuff.
99 * @{ */
100 void showEvent(QShowEvent *pEvent) RT_OVERRIDE RT_FINAL;
101 bool event(QEvent *pEvent) RT_OVERRIDE RT_FINAL;
102 /** @} */
103
104private slots:
105
106 void sltButtonLeaveEmpty();
107 void sltButtonCancel();
108 void sltButtonChoose();
109 void sltAddMedium();
110 void sltCreateMedium();
111 void sltHandleItemSelectionChanged();
112 void sltHandleTreeWidgetDoubleClick(QTreeWidgetItem * item, int column);
113 void sltHandleMediumCreated(const QUuid &uMediumId);
114 void sltHandleMediumEnumerationStart();
115 void sltHandleMediumEnumerated();
116 void sltHandleMediumEnumerationFinish();
117 void sltHandleRefresh();
118 void sltHandlePerformSearch();
119 void sltHandleTreeContextMenuRequest(const QPoint &point);
120 void sltHandleTreeExpandAllSignal();
121 void sltHandleTreeCollapseAllSignal();
122 /** Handles translation event. */
123 void sltRetranslateUI();
124
125private:
126
127 /** @name Prepare/cleanup cascade.
128 * @{ */
129 /** Configures all. */
130 void configure();
131 void prepareWidgets();
132 void prepareActions();
133 void prepareMenuAndToolBar();
134 void prepareConnections();
135 /** Perform final preparations. */
136 void finalize();
137 /** @} */
138
139 void repopulateTreeWidget();
140 /** Disable/enable 'ok' button on the basis of having a selected item */
141 void updateChooseButton();
142 UIMediumItem* addTreeItem(const UIMedium &medium, QITreeWidgetItem *pParent);
143 void restoreSelection(const QList<QUuid> &selectedMediums, QVector<UIMediumItem*> &mediumList);
144 /** Recursively create the hard disk hierarchy under the tree widget */
145 UIMediumItem* createHardDiskItem(const UIMedium &medium, QITreeWidgetItem *pParent);
146 UIMediumItem* searchItem(const QTreeWidgetItem *pParent, const QUuid &mediumId);
147 /** Remember the default foreground brush of the tree so that we can reset tree items' foreground later */
148 void saveDefaultForeground();
149 void selectMedium(const QUuid &uMediumID);
150 void setTitle();
151 void saveDialogGeometry();
152 void loadSettings();
153 QWidget *m_pCentralWidget;
154 QVBoxLayout *m_pMainLayout;
155 QITreeWidget *m_pTreeWidget;
156 UIMediumDeviceType m_enmMediumType;
157 QIDialogButtonBox *m_pButtonBox;
158 QPushButton *m_pCancelButton;
159 QPushButton *m_pChooseButton;
160 QPushButton *m_pLeaveEmptyButton;
161 QMenu *m_pMainMenu;
162 QIToolBar *m_pToolBar;
163 QAction *m_pActionAdd;
164 QAction *m_pActionCreate;
165 QAction *m_pActionRefresh;
166 /** All the known media that are already attached to some vm are added under the following top level tree item */
167 QITreeWidgetItem *m_pAttachedSubTreeRoot;
168 /** All the known media that are not attached to any vm are added under the following top level tree item */
169 QITreeWidgetItem *m_pNotAttachedSubTreeRoot;
170 QWidget *m_pParent;
171 UIMediumSearchWidget *m_pSearchWidget;
172 /** The list all items added to tree. kept in sync. with tree to make searching easier (faster). */
173 QList<UIMediumItem*> m_mediumItemList;
174 /** List of items that are matching to the search. */
175 QList<UIMediumItem*> m_mathingItemList;
176 /** Index of the currently shown (scrolled) item in the m_mathingItemList. */
177 int m_iCurrentShownIndex;
178 QBrush m_defaultItemForeground;
179 QString m_strMachineFolder;
180 QString m_strMachineName;
181 QString m_strMachineGuestOSTypeId;
182 QUuid m_uMachineID;
183 QUuid m_uCurrentMediumId;
184 UIActionPool *m_pActionPool;
185 int m_iGeometrySaveTimerId;
186};
187
188#endif /* !FEQT_INCLUDED_SRC_medium_UIMediumSelector_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use