VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMainDialog.h

Last change on this file was 103977, checked in by vboxsync, 2 months ago

Apply RT_OVERRIDE/NS_OVERRIDE where required to shut up clang.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: QIMainDialog.h 103977 2024-03-21 02:04:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt extensions: QIMainDialog class declaration.
4 */
5
6/*
7 * Copyright (C) 2008-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_QIMainDialog_h
29#define FEQT_INCLUDED_SRC_extensions_QIMainDialog_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QDialog>
36#include <QMainWindow>
37#include <QPointer>
38
39/* GUI includes: */
40#include "UILibraryDefs.h"
41
42/* Forward declarations: */
43class QPushButton;
44class QEventLoop;
45class QSizeGrip;
46
47/** QDialog analog based on QMainWindow. */
48class SHARED_LIBRARY_STUFF QIMainDialog : public QMainWindow
49{
50 Q_OBJECT;
51
52public:
53
54 /** Constructs main-dialog passing @a pParent and @a enmFlags to the base-class.
55 * @param fIsAutoCentering Brigs whether this dialog should be centered according it's parent. */
56 QIMainDialog(QWidget *pParent = 0,
57 Qt::WindowFlags enmFlags = Qt::Dialog,
58 bool fIsAutoCentering = true);
59
60 /** Returns the dialog's result code. */
61 int result() const { return m_iResult; }
62
63 /** Executes the dialog, launching local event-loop.
64 * @param fApplicationModal defines whether this dialog should be modal to application or window. */
65 int exec(bool fApplicationModal = true);
66
67 /** Returns dialog's default button. */
68 QPushButton *defaultButton() const;
69 /** Defines dialog's default @a pButton. */
70 void setDefaultButton(QPushButton *pButton);
71
72 /** Returns whether size-grip was enabled for that dialog. */
73 bool isSizeGripEnabled() const;
74 /** Defines whether size-grip should be @a fEnabled for that dialog. */
75 void setSizeGripEnabled(bool fEnabled);
76
77public slots:
78
79 /** Defines whether the dialog is @a fVisible. */
80 virtual void setVisible(bool fVisible) RT_OVERRIDE;
81
82protected:
83
84 /** Preprocesses any Qt @a pEvent for passed @a pObject. */
85 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
86 /** Handles any Qt @a pEvent. */
87 virtual bool event(QEvent *pEvent) RT_OVERRIDE;
88
89 /** Handles show @a pEvent. */
90 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
91 /** Handles first show @a pEvent. */
92 virtual void polishEvent(QShowEvent *pEvent);
93
94 /** Handles resize @a pEvent. */
95 virtual void resizeEvent(QResizeEvent *pEvent) RT_OVERRIDE;
96
97 /** Handles key-press @a pEvent. */
98 virtual void keyPressEvent(QKeyEvent *pEvent) RT_OVERRIDE;
99
100 /** Searches for dialog's default button. */
101 QPushButton *searchDefaultButton() const;
102
103 /** Sets reject-by-escape-key flag. */
104 void setRejectByEscape(bool fRejectByEscape);
105
106protected slots:
107
108 /** Sets the modal dialog's result code to @a iResult. */
109 void setResult(int iResult) { m_iResult = iResult; }
110
111 /** Closes the modal dialog and sets its result code to @a iResult.
112 * If this dialog is shown with exec(), done() causes the local
113 * event-loop to finish, and exec() to return @a iResult. */
114 virtual void done(int iResult);
115 /** Hides the modal dialog and sets the result code to Accepted. */
116 virtual void accept() { done(QDialog::Accepted); }
117 /** Hides the modal dialog and sets the result code to Rejected. */
118 virtual void reject() { done(QDialog::Rejected); }
119
120private:
121
122 /** Holds whether this dialog should be centered according it's parent. */
123 const bool m_fIsAutoCentering;
124 /** Holds whether this dialog is polished. */
125 bool m_fPolished;
126
127 /** Holds modal dialog's result code. */
128 int m_iResult;
129 /** Holds modal dialog's event-loop. */
130 QPointer<QEventLoop> m_pEventLoop;
131
132 /** Holds dialog's default button. */
133 QPointer<QPushButton> m_pDefaultButton;
134 /** Holds dialog's size-grip. */
135 QPointer<QSizeGrip> m_pSizeGrip;
136 /** Holds reject by escape flag. When true pressing escape rejects the dialog. Default is true.*/
137 bool m_fRejectByEscape;
138};
139
140#endif /* !FEQT_INCLUDED_SRC_extensions_QIMainDialog_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use