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