VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIManagerDialog.h@ 102731

Last change on this file since 102731 was 102731, checked in by vboxsync, 5 months ago

FE/Qt: Extend QIManagerDialog facility with stuff to embed manager dialog to UIVirtualBoxManager tool stack.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 KB
Line 
1/* $Id: QIManagerDialog.h 102731 2023-12-29 16:30:17Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt extensions: QIManagerDialog 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_extensions_QIManagerDialog_h
29#define FEQT_INCLUDED_SRC_extensions_QIManagerDialog_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QMainWindow>
36#include <QMap>
37
38/* GUI includes: */
39#include "QIWithRestorableGeometry.h"
40#include "UILibraryDefs.h"
41
42/* Other VBox includes: */
43#include <iprt/cdefs.h>
44
45/* Forward declarations: */
46class QPushButton;
47class QIDialogButtonBox;
48class QIManagerDialog;
49#ifdef VBOX_WS_MAC
50class QIToolBar;
51#endif
52
53
54/** Widget embedding type. */
55enum EmbedTo
56{
57 EmbedTo_Dialog,
58 EmbedTo_Stack
59};
60
61
62/** Dialog button types. */
63enum ButtonType
64{
65 ButtonType_Invalid = 0,
66 ButtonType_Reset = RT_BIT(0),
67 ButtonType_Apply = RT_BIT(1),
68 ButtonType_Embed = RT_BIT(2),
69 ButtonType_Close = RT_BIT(3),
70 ButtonType_Help = RT_BIT(4),
71};
72
73
74/** Manager dialog factory insterface. */
75class SHARED_LIBRARY_STUFF QIManagerDialogFactory
76{
77
78public:
79
80 /** Constructs Manager dialog factory. */
81 QIManagerDialogFactory() {}
82 /** Destructs Manager dialog factory. */
83 virtual ~QIManagerDialogFactory() {}
84
85 /** Prepares Manager dialog @a pDialog instance.
86 * @param pCenterWidget Brings the widget reference to center according to. */
87 virtual void prepare(QIManagerDialog *&pDialog, QWidget *pCenterWidget = 0);
88 /** Cleanups Manager dialog @a pDialog instance. */
89 virtual void cleanup(QIManagerDialog *&pDialog);
90
91protected:
92
93 /** Creates derived @a pDialog instance.
94 * @param pCenterWidget Brings the widget reference to center according to. */
95 virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) = 0;
96};
97
98
99/** QMainWindow sub-class used as various manager dialogs. */
100class SHARED_LIBRARY_STUFF QIManagerDialog : public QIWithRestorableGeometry<QMainWindow>
101{
102 Q_OBJECT;
103
104signals:
105
106 /** Notifies listeners about dialog should be embedded. */
107 void sigEmbed();
108 /** Notifies listeners about dialog should be closed. */
109 void sigClose();
110
111protected:
112
113 /** Constructs Manager dialog.
114 * @param pCenterWidget Brings the widget reference to center according to. */
115 QIManagerDialog(QWidget *pCenterWidget);
116
117 /** @name Virtual prepare/cleanup cascade.
118 * @{ */
119 /** Configures all.
120 * @note Injected into prepare(), reimplement to configure all there. */
121 virtual void configure() {}
122 /** Configures central-widget.
123 * @note Injected into prepareCentralWidget(), reimplement to configure central-widget there. */
124 virtual void configureCentralWidget() {}
125 /** Configures button-box.
126 * @note Injected into prepareButtonBox(), reimplement to configure button-box there. */
127 virtual void configureButtonBox() {}
128 /** Performs final preparations.
129 * @note Injected into prepare(), reimplement to postprocess all there. */
130 virtual void finalize() {}
131 /** Loads dialog setting from extradata. */
132 virtual void loadSettings() {}
133
134 /** Saves dialog setting into extradata. */
135 virtual void saveSettings() {}
136 /** @} */
137
138 /** @name Widget stuff.
139 * @{ */
140 /** Defines the @a pWidget instance. */
141 void setWidget(QWidget *pWidget) { m_pWidget = pWidget; }
142 /** Defines the reference to widget menu, replacing current one. */
143 void setWidgetMenu(QMenu *pWidgetMenu) { m_widgetMenus = QList<QMenu*>() << pWidgetMenu; }
144 /** Defines the list of references to widget menus, replacing current one. */
145 void setWidgetMenus(QList<QMenu*> widgetMenus) { m_widgetMenus = widgetMenus; }
146#ifdef VBOX_WS_MAC
147 /** Defines the @a pWidgetToolbar instance. */
148 void setWidgetToolbar(QIToolBar *pWidgetToolbar) { m_pWidgetToolbar = pWidgetToolbar; }
149#endif
150
151 /** Returns the widget. */
152 virtual QWidget *widget() { return m_pWidget; }
153 /** Returns the button-box instance. */
154 QIDialogButtonBox *buttonBox() { return m_pButtonBox; }
155 /** Returns button of passed @a enmType. */
156 QPushButton *button(ButtonType enmType) { return m_buttons.value(enmType); }
157 /** Returns the widget reference to center manager dialog according. */
158 QWidget *centerWidget() const { return m_pCenterWidget; }
159 /** @} */
160
161 /** @name Event-handling stuff.
162 * @{ */
163 /** Handles close @a pEvent. */
164 virtual void closeEvent(QCloseEvent *pEvent) RT_OVERRIDE;
165
166 /** Returns whether the manager had emitted command to be closed. */
167 bool closeEmitted() const { return m_fCloseEmitted; }
168 /** @} */
169
170private slots:
171
172 /** Handles help request. */
173 void sltHandleHelpRequested();
174
175private:
176
177 /** @name Private prepare/cleanup cascade.
178 * @{ */
179 /** Prepares all. */
180 void prepare();
181 /** Prepares central-widget. */
182 void prepareCentralWidget();
183 /** Prepares button-box. */
184 void prepareButtonBox();
185 /** Prepares menu-bar. */
186 void prepareMenuBar();
187#ifdef VBOX_WS_MAC
188 /** Prepares toolbar. */
189 void prepareToolBar();
190#endif
191
192 /** Cleanup menu-bar. */
193 void cleanupMenuBar();
194 /** Cleanups all. */
195 void cleanup();
196 /** @} */
197
198 /** @name General stuff.
199 * @{ */
200 /** Holds the widget reference to center manager dialog according. */
201 QWidget *m_pCenterWidget;
202
203 /** Holds whether the manager had emitted command to be closed. */
204 bool m_fCloseEmitted;
205 /** @} */
206
207 /** @name Widget stuff.
208 * @{ */
209 /** Holds the widget instance. */
210 QWidget *m_pWidget;
211
212 /** Holds a list of widget menu references. */
213 QList<QMenu*> m_widgetMenus;
214
215#ifdef VBOX_WS_MAC
216 /** Holds the widget toolbar instance. */
217 QIToolBar *m_pWidgetToolbar;
218#endif
219 /** @} */
220
221 /** @name Button-box stuff.
222 * @{ */
223 /** Holds the dialog button-box instance. */
224 QIDialogButtonBox *m_pButtonBox;
225
226 /** Holds the button-box button references. */
227 QMap<ButtonType, QPushButton*> m_buttons;
228 /** @} */
229
230 /** Allow factory access to private/protected members: */
231 friend class QIManagerDialogFactory;
232};
233
234
235#endif /* !FEQT_INCLUDED_SRC_extensions_QIManagerDialog_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use