VirtualBox

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

Last change on this file since 82781 was 81356, checked in by vboxsync, 5 years ago

FE/Qt: QIManagerDialog: Fix bug and coding-style of r119699.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 KB
Line 
1/* $Id: QIManagerDialog.h 81356 2019-10-18 14:07:02Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt extensions: QIManagerDialog class declaration.
4 */
5
6/*
7 * Copyright (C) 2009-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef FEQT_INCLUDED_SRC_extensions_QIManagerDialog_h
19#define FEQT_INCLUDED_SRC_extensions_QIManagerDialog_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* Qt includes: */
25#include <QMainWindow>
26#include <QMap>
27
28/* GUI includes: */
29#include "QIWithRestorableGeometry.h"
30#include "UILibraryDefs.h"
31
32/* Other VBox includes: */
33#include <iprt/cdefs.h>
34
35/* Forward declarations: */
36class QPushButton;
37class QIDialogButtonBox;
38class QIManagerDialog;
39#ifdef VBOX_WS_MAC
40class UIToolBar;
41#endif
42
43
44/** Widget embedding type. */
45enum EmbedTo
46{
47 EmbedTo_Dialog,
48 EmbedTo_Stack
49};
50
51
52/** Dialog button types. */
53enum ButtonType
54{
55 ButtonType_Invalid = 0,
56 ButtonType_Reset = RT_BIT(0),
57 ButtonType_Apply = RT_BIT(1),
58 ButtonType_Close = RT_BIT(2),
59};
60
61
62/** Manager dialog factory insterface. */
63class SHARED_LIBRARY_STUFF QIManagerDialogFactory
64{
65
66public:
67
68 /** Constructs Manager dialog factory. */
69 QIManagerDialogFactory() {}
70 /** Destructs Manager dialog factory. */
71 virtual ~QIManagerDialogFactory() {}
72
73 /** Prepares Manager dialog @a pDialog instance.
74 * @param pCenterWidget Brings the widget reference to center according to. */
75 virtual void prepare(QIManagerDialog *&pDialog, QWidget *pCenterWidget = 0);
76 /** Cleanups Manager dialog @a pDialog instance. */
77 virtual void cleanup(QIManagerDialog *&pDialog);
78
79protected:
80
81 /** Creates derived @a pDialog instance.
82 * @param pCenterWidget Brings the widget reference to center according to. */
83 virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) = 0;
84};
85
86
87/** QMainWindow sub-class used as various manager dialogs. */
88class SHARED_LIBRARY_STUFF QIManagerDialog : public QIWithRestorableGeometry<QMainWindow>
89{
90 Q_OBJECT;
91
92signals:
93
94 /** Notifies listeners about dialog change. */
95 void sigChange();
96
97 /** Notifies listeners about dialog should be closed. */
98 void sigClose();
99
100protected:
101
102 /** Constructs Manager dialog.
103 * @param pCenterWidget Brings the widget reference to center according to. */
104 QIManagerDialog(QWidget *pCenterWidget);
105
106 /** @name Prepare/cleanup cascade.
107 * @{ */
108 /** Prepares all.
109 * @note Normally you don't need to reimplement it. */
110 void prepare();
111 /** Configures all.
112 * @note Injected into prepare(), reimplement to configure all there. */
113 virtual void configure() {}
114 /** Prepares central-widget.
115 * @note Injected into prepare(), normally you don't need to reimplement it. */
116 void prepareCentralWidget();
117 /** Configures central-widget.
118 * @note Injected into prepareCentralWidget(), reimplement to configure central-widget there. */
119 virtual void configureCentralWidget() {}
120 /** Prepares button-box.
121 * @note Injected into prepareCentralWidget(), normally you don't need to reimplement it. */
122 void prepareButtonBox();
123 /** Configures button-box.
124 * @note Injected into prepareButtonBox(), reimplement to configure button-box there. */
125 virtual void configureButtonBox() {}
126 /** Prepares menu-bar.
127 * @note Injected into prepare(), normally you don't need to reimplement it. */
128 void prepareMenuBar();
129#ifdef VBOX_WS_MAC
130 /** Prepares toolbar.
131 * @note Injected into prepare(), normally you don't need to reimplement it. */
132 void prepareToolBar();
133#endif
134 /** Performs final preparations.
135 * @note Injected into prepare(), reimplement to postprocess all there. */
136 virtual void finalize() {}
137 /** Loads dialog setting such as geometry from extradata. */
138 virtual void loadSettings() {}
139
140 /** Saves dialog setting into extradata. */
141 virtual void saveSettings() const {}
142 /** Cleanup menu-bar.
143 * @note Injected into cleanup(), normally you don't need to reimplement it. */
144 void cleanupMenuBar();
145 /** Cleanups all.
146 * @note Normally you don't need to reimplement it. */
147 void cleanup();
148 /** @} */
149
150 /** @name Widget stuff.
151 * @{ */
152 /** Defines the @a pWidget instance. */
153 void setWidget(QWidget *pWidget) { m_pWidget = pWidget; }
154 /** Defines the @a pWidgetMenu instance. */
155 void setWidgetMenu(QMenu *pWidgetMenu) { m_pWidgetMenu = pWidgetMenu; }
156#ifdef VBOX_WS_MAC
157 /** Defines the @a pWidgetToolbar instance. */
158 void setWidgetToolbar(UIToolBar *pWidgetToolbar) { m_pWidgetToolbar = pWidgetToolbar; }
159#endif
160
161 /** Returns the widget. */
162 virtual QWidget *widget() { return m_pWidget; }
163 /** Returns the button-box instance. */
164 QIDialogButtonBox *buttonBox() { return m_pButtonBox; }
165 /** Returns button of passed @a enmType. */
166 QPushButton *button(ButtonType enmType) { return m_buttons.value(enmType); }
167 /** Returns the widget reference to center manager dialog according. */
168 QWidget *centerWidget() const { return m_pCenterWidget; }
169 /** @} */
170
171 /** @name Event-handling stuff.
172 * @{ */
173 /** Handles close @a pEvent. */
174 void closeEvent(QCloseEvent *pEvent);
175 /** @} */
176
177private:
178
179 /** @name General stuff.
180 * @{ */
181 /** Holds the widget reference to center manager dialog according. */
182 QWidget *m_pCenterWidget;
183
184 /** Holds whether the manager had emitted command to be closed. */
185 bool m_fCloseEmitted;
186 /** @} */
187
188 /** @name Widget stuff.
189 * @{ */
190 /** Holds the widget instance. */
191 QWidget *m_pWidget;
192
193 /** Holds the widget menu instance. */
194 QMenu *m_pWidgetMenu;
195#ifdef VBOX_WS_MAC
196 /** Holds the widget toolbar instance. */
197 UIToolBar *m_pWidgetToolbar;
198#endif
199 /** @} */
200
201 /** @name Button-box stuff.
202 * @{ */
203 /** Holds the dialog button-box instance. */
204 QIDialogButtonBox *m_pButtonBox;
205
206 /** Holds the button-box button references. */
207 QMap<ButtonType, QPushButton*> m_buttons;
208 /** @} */
209
210 /** Allow factory access to private/protected members: */
211 friend class QIManagerDialogFactory;
212};
213
214
215#endif /* !FEQT_INCLUDED_SRC_extensions_QIManagerDialog_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use