summaryrefslogtreecommitdiff
path: root/src/VBox/Frontends/VirtualBox/src/extensions/QIDialog.h
blob: b7fefed40f844fe8d8529b3d622a05b10ebd7a0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* $Id$ */
/** @file
 * VBox Qt GUI - Qt extensions: QIDialog class declaration.
 */

/*
 * Copyright (C) 2008-2020 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 */

#ifndef FEQT_INCLUDED_SRC_extensions_QIDialog_h
#define FEQT_INCLUDED_SRC_extensions_QIDialog_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

/* Qt includes: */
#include <QDialog>
#include <QPointer>

/* GUI includes: */
#include "UILibraryDefs.h"

/* Forward declarations: */
class QEventLoop;

/** QDialog extension providing the GUI with
  * the advanced capabilities like delayed show. */
class SHARED_LIBRARY_STUFF QIDialog : public QDialog
{
    Q_OBJECT;

public:

    /** Constructs the dialog passing @a pParent and @a enmFlags to the base-class. */
    QIDialog(QWidget *pParent = 0, Qt::WindowFlags enmFlags = 0);

    /** Defines whether the dialog is @a fVisible. */
    void setVisible(bool fVisible);

public slots:

    /** Shows the dialog as a modal one, blocking until the user closes it.
      * @param  fShow              Brings whether the dialog should be shown instantly.
      * @param  fApplicationModal  Brings whether the dialog should be application-modal. */
    virtual int execute(bool fShow = true, bool fApplicationModal = false);

    /** Shows the dialog as a modal one, blocking until the user closes it. */
    virtual int exec() /* override */ { return execute(); }

protected:

    /** Handles show @a pEvent. */
    virtual void showEvent(QShowEvent *pEvent) /* override */;
    /** Handles show @a pEvent sent for the first time. */
    virtual void polishEvent(QShowEvent *pEvent);

private:

    /** Holds whether the dialog is polished. */
    bool m_fPolished;

    /** Holds the separate event-loop instance.
      * @note  This event-loop is only used when the dialog being executed via the execute()
      *        functionality, allowing for the delayed show and advanced modality flag. */
    QPointer<QEventLoop> m_pEventLoop;
};

/** Safe pointer to the QIDialog class. */
typedef QPointer<QIDialog> UISafePointerDialog;

#endif /* !FEQT_INCLUDED_SRC_extensions_QIDialog_h */