QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskDialog.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_DIALOG_H
7#define QSK_DIALOG_H
8
9#include "QskGlobal.h"
10
11#include <qobject.h>
12#include <memory>
13
14class QString;
15class QWindow;
16
17#if defined( qskDialog )
18#undef qskDialog
19#endif
20
21#define qskDialog QskDialog::instance()
22
23class QSK_EXPORT QskDialog : public QObject
24{
25 Q_OBJECT
26
27 Q_PROPERTY( Policy policy READ policy
28 WRITE setPolicy NOTIFY policyChanged )
29
30 Q_PROPERTY( QWindow * transientParent READ transientParent
31 WRITE setTransientParent NOTIFY transientParentChanged )
32
33 public:
34 enum Policy
35 {
36 EmbeddedBox,
37 EmbeddedWindow, // not yet implemented, do we need it ?
38 TopLevelWindow
39 };
40
41 Q_ENUM( Policy )
42
43 // a.k.a QMessageBox::StandardButton or QPlatformDialogHelper::StandardButton
44 enum Action
45 {
46 NoAction = 0,
47 Ok = 1 << 10,
48 Save = 1 << 11,
49 SaveAll = 1 << 12,
50 Open = 1 << 13,
51 Yes = 1 << 14,
52 YesToAll = 1 << 15,
53 No = 1 << 16,
54 NoToAll = 1 << 17,
55 Abort = 1 << 18,
56 Retry = 1 << 19,
57 Ignore = 1 << 20,
58 Close = 1 << 21,
59 Cancel = 1 << 22,
60 Discard = 1 << 23,
61 Help = 1 << 24,
62 Apply = 1 << 25,
63 Reset = 1 << 26,
64 RestoreDefaults = 1 << 27
65 };
66
67 Q_ENUM( Action )
68 Q_DECLARE_FLAGS( Actions, Action )
69
70 // a.k.a QMessageBox::ButtonRole
71 enum ActionRole
72 {
73 InvalidRole = -1,
74
75 AcceptRole,
76 RejectRole,
77 DestructiveRole,
78 UserRole,
79 HelpRole,
80 YesRole,
81 NoRole,
82 ResetRole,
83 ApplyRole,
84
85 NActionRoles
86 };
87
88 Q_ENUM( ActionRole )
89
90 // for building the mask in QskSkin::dialogButtonLayout
91 enum ButtonLayoutFlag
92 {
93 // from QPlatformDialogHelper::ButtonRole
94 ActionMask = 0x0FFFFFFF,
95
96 AlternateRole = 1 << 28,
97 Stretch = 1 << 29,
98 Reverse = 1 << 30
99 };
100
101 enum DialogCode
102 {
103 Rejected = 0,
104 Accepted
105 };
106
107 Q_ENUM( DialogCode )
108
109 static QskDialog* instance();
110
111 void setPolicy( Policy );
112 Policy policy() const;
113
114 Q_INVOKABLE void setTransientParent( QWindow* );
115 Q_INVOKABLE QWindow* transientParent() const;
116
117 Q_INVOKABLE Action message(
118 const QString& title, const QString& text, uint priority = 0,
119 Actions actions = Ok, Action defaultAction = NoAction ) const;
120
121 Q_INVOKABLE Action information(
122 const QString& title, const QString& text,
123 Actions actions = Ok, Action defaultAction = NoAction ) const;
124
125 Q_INVOKABLE Action question(
126 const QString& title, const QString& text,
127 Actions actions = Actions( Yes | No ),
128 Action defaultAction = NoAction ) const;
129
130 Q_INVOKABLE QString select( const QString& title,
131 const QStringList& entries, int selectedRow = 0 ) const;
132
133 static ActionRole actionRole( Action action );
134
135 Q_SIGNALS:
136 void transientParentChanged();
137 void policyChanged();
138
139 private:
140 QskDialog();
141 ~QskDialog() override;
142
143 class PrivateData;
144 std::unique_ptr< PrivateData > m_data;
145};
146
147Q_DECLARE_METATYPE( QskDialog::Action )
148Q_DECLARE_METATYPE( QskDialog::Actions )
149Q_DECLARE_OPERATORS_FOR_FLAGS( QskDialog::Actions )
150
151#endif