1 | /* $Id: UIExtensionPackManager.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIExtensionPackManager class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-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_extensionpackmanager_UIExtensionPackManager_h
|
---|
29 | #define FEQT_INCLUDED_SRC_extensionpackmanager_UIExtensionPackManager_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* GUI includes: */
|
---|
35 | #include "QIManagerDialog.h"
|
---|
36 | #include "QIWithRetranslateUI.h"
|
---|
37 |
|
---|
38 | /* Forward declarations: */
|
---|
39 | class QIToolBar;
|
---|
40 | class QITreeWidget;
|
---|
41 | class UIActionPool;
|
---|
42 | struct UIDataExtensionPack;
|
---|
43 | class CExtPack;
|
---|
44 |
|
---|
45 |
|
---|
46 | /** QWidget extension providing GUI with the pane to control extension pack related functionality. */
|
---|
47 | class UIExtensionPackManagerWidget : public QIWithRetranslateUI<QWidget>
|
---|
48 | {
|
---|
49 | Q_OBJECT;
|
---|
50 |
|
---|
51 | public:
|
---|
52 |
|
---|
53 | /** Constructs Extension Pack Manager widget.
|
---|
54 | * @param enmEmbedding Brings the type of widget embedding.
|
---|
55 | * @param pActionPool Brings the action-pool reference.
|
---|
56 | * @param fShowToolbar Brings whether we should create/show toolbar. */
|
---|
57 | UIExtensionPackManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool,
|
---|
58 | bool fShowToolbar = true, QWidget *pParent = 0);
|
---|
59 |
|
---|
60 | /** Returns the menu. */
|
---|
61 | QMenu *menu() const;
|
---|
62 |
|
---|
63 | #ifdef VBOX_WS_MAC
|
---|
64 | /** Returns the toolbar. */
|
---|
65 | QIToolBar *toolbar() const { return m_pToolBar; }
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | protected:
|
---|
69 |
|
---|
70 | /** @name Event-handling stuff.
|
---|
71 | * @{ */
|
---|
72 | /** Handles translation event. */
|
---|
73 | virtual void retranslateUi() RT_OVERRIDE;
|
---|
74 | /** @} */
|
---|
75 |
|
---|
76 | private slots:
|
---|
77 |
|
---|
78 | /** @name Menu/action stuff.
|
---|
79 | * @{ */
|
---|
80 | /** Handles command to install extension pack. */
|
---|
81 | void sltInstallExtensionPack();
|
---|
82 | /** Handles command to uninstall extension pack. */
|
---|
83 | void sltUninstallExtensionPack();
|
---|
84 | /** @} */
|
---|
85 |
|
---|
86 | /** @name Tree-widget stuff.
|
---|
87 | * @{ */
|
---|
88 | /** Handles command to adjust tree-widget. */
|
---|
89 | void sltAdjustTreeWidget();
|
---|
90 |
|
---|
91 | /** Handles tree-widget current item change. */
|
---|
92 | void sltHandleCurrentItemChange();
|
---|
93 | /** Handles context-menu request for tree-widget @a position. */
|
---|
94 | void sltHandleContextMenuRequest(const QPoint &position);
|
---|
95 |
|
---|
96 | /** Handles signal about extension pack @a strName installed. */
|
---|
97 | void sltHandleExtensionPackInstalled(const QString &strName);
|
---|
98 | /** Handles signal about extension pack @a strName uninstalled. */
|
---|
99 | void sltHandleExtensionPackUninstalled(const QString &strName);
|
---|
100 | /** @} */
|
---|
101 |
|
---|
102 | private:
|
---|
103 |
|
---|
104 | /** @name Prepare/cleanup cascade.
|
---|
105 | * @{ */
|
---|
106 | /** Prepares all. */
|
---|
107 | void prepare();
|
---|
108 | /** Prepares actions. */
|
---|
109 | void prepareActions();
|
---|
110 | /** Prepares widgets. */
|
---|
111 | void prepareWidgets();
|
---|
112 | /** Prepares toolbar. */
|
---|
113 | void prepareToolBar();
|
---|
114 | /** Prepares tree-widget. */
|
---|
115 | void prepareTreeWidget();
|
---|
116 | /** @} */
|
---|
117 |
|
---|
118 | /** @name Loading stuff.
|
---|
119 | * @{ */
|
---|
120 | /** Loads extension pack stuff. */
|
---|
121 | void loadExtensionPacks();
|
---|
122 | /** Loads extention @a comPackage data to passed @a extensionPackData container. */
|
---|
123 | void loadExtensionPack(const CExtPack &comPackage, UIDataExtensionPack &extensionPackData);
|
---|
124 | /** @} */
|
---|
125 |
|
---|
126 | /** @name Tree-widget stuff.
|
---|
127 | * @{ */
|
---|
128 | /** Creates a new tree-widget item
|
---|
129 | * on the basis of passed @a extensionPackData, @a fChooseItem if requested. */
|
---|
130 | void createItemForExtensionPack(const UIDataExtensionPack &extensionPackData, bool fChooseItem);
|
---|
131 | /** @} */
|
---|
132 |
|
---|
133 | /** @name General variables.
|
---|
134 | * @{ */
|
---|
135 | /** Holds the widget embedding type. */
|
---|
136 | const EmbedTo m_enmEmbedding;
|
---|
137 | /** Holds the action-pool reference. */
|
---|
138 | UIActionPool *m_pActionPool;
|
---|
139 | /** Holds whether we should create/show toolbar. */
|
---|
140 | const bool m_fShowToolbar;
|
---|
141 | /** @} */
|
---|
142 |
|
---|
143 | /** @name Toolbar and menu variables.
|
---|
144 | * @{ */
|
---|
145 | /** Holds the toolbar instance. */
|
---|
146 | QIToolBar *m_pToolBar;
|
---|
147 | /** @} */
|
---|
148 |
|
---|
149 | /** @name Widget variables.
|
---|
150 | * @{ */
|
---|
151 | /** Holds the tree-widget instance. */
|
---|
152 | QITreeWidget *m_pTreeWidget;
|
---|
153 | /** @} */
|
---|
154 | };
|
---|
155 |
|
---|
156 |
|
---|
157 | /** QIManagerDialogFactory extension used as a factory for Extension Pack Manager dialog. */
|
---|
158 | class UIExtensionPackManagerFactory : public QIManagerDialogFactory
|
---|
159 | {
|
---|
160 | public:
|
---|
161 |
|
---|
162 | /** Constructs Extension Pack Manager factory acquiring additional arguments.
|
---|
163 | * @param pActionPool Brings the action-pool reference. */
|
---|
164 | UIExtensionPackManagerFactory(UIActionPool *pActionPool = 0);
|
---|
165 |
|
---|
166 | protected:
|
---|
167 |
|
---|
168 | /** Creates derived @a pDialog instance.
|
---|
169 | * @param pCenterWidget Brings the widget reference to center according to. */
|
---|
170 | virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) RT_OVERRIDE;
|
---|
171 |
|
---|
172 | /** Holds the action-pool reference. */
|
---|
173 | UIActionPool *m_pActionPool;
|
---|
174 | };
|
---|
175 |
|
---|
176 |
|
---|
177 | /** QIManagerDialog extension providing GUI with the dialog to control extension pack related functionality. */
|
---|
178 | class UIExtensionPackManager : public QIWithRetranslateUI<QIManagerDialog>
|
---|
179 | {
|
---|
180 | Q_OBJECT;
|
---|
181 |
|
---|
182 | private:
|
---|
183 |
|
---|
184 | /** Constructs Extension Pack Manager dialog.
|
---|
185 | * @param pCenterWidget Brings the widget reference to center according to.
|
---|
186 | * @param pActionPool Brings the action-pool reference. */
|
---|
187 | UIExtensionPackManager(QWidget *pCenterWidget, UIActionPool *pActionPool);
|
---|
188 |
|
---|
189 | /** @name Event-handling stuff.
|
---|
190 | * @{ */
|
---|
191 | /** Handles translation event. */
|
---|
192 | virtual void retranslateUi() RT_OVERRIDE;
|
---|
193 | /** @} */
|
---|
194 |
|
---|
195 | /** @name Prepare/cleanup cascade.
|
---|
196 | * @{ */
|
---|
197 | /** Configures all. */
|
---|
198 | virtual void configure() RT_OVERRIDE;
|
---|
199 | /** Configures central-widget. */
|
---|
200 | virtual void configureCentralWidget() RT_OVERRIDE;
|
---|
201 | /** Perform final preparations. */
|
---|
202 | virtual void finalize() RT_OVERRIDE;
|
---|
203 | /** @} */
|
---|
204 |
|
---|
205 | /** @name Widget stuff.
|
---|
206 | * @{ */
|
---|
207 | /** Returns the widget. */
|
---|
208 | virtual UIExtensionPackManagerWidget *widget() RT_OVERRIDE;
|
---|
209 | /** @} */
|
---|
210 |
|
---|
211 | /** @name Action related variables.
|
---|
212 | * @{ */
|
---|
213 | /** Holds the action-pool reference. */
|
---|
214 | UIActionPool *m_pActionPool;
|
---|
215 | /** @} */
|
---|
216 |
|
---|
217 | /** Allow factory access to private/protected members: */
|
---|
218 | friend class UIExtensionPackManagerFactory;
|
---|
219 | };
|
---|
220 |
|
---|
221 | #endif /* !FEQT_INCLUDED_SRC_extensionpackmanager_UIExtensionPackManager_h */
|
---|