CuteLogger
Fast and simple logging solution for Qt based applications
messagedialog.h
1/*
2 * Copyright (c) 2023 Meltytech, LLC
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17#ifndef MESSAGEDIALOG_H
18#define MESSAGEDIALOG_H
19
20#include <QMessageBox>
21
22class MessageDialog : public QObject
23{
24 Q_OBJECT
25 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
26 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
27 Q_PROPERTY(int buttons READ buttons WRITE setButtons NOTIFY buttonsChanged)
28
29public:
30 enum StandardButtons {
31 Ok = QMessageBox::Ok,
32 Yes = QMessageBox::Yes,
33 No = QMessageBox::No,
34 Cancel = QMessageBox::Cancel
35 };
36 Q_ENUM(StandardButtons)
37 explicit MessageDialog(QObject *parent = nullptr);
38
39 Q_INVOKABLE void open();
40
41signals:
42 void titleChanged(const QString &title);
43 void textChanged(const QString &text);
44 void buttonsChanged(int buttons);
45 void accepted();
46 void rejected();
47
48private:
49 QString m_title;
50 QString m_text;
51 int m_buttons;
52
53 QString title() const
54 {
55 return m_title;
56 }
57 void setTitle(const QString &title);
58 QString text() const
59 {
60 return m_text;
61 }
62 void setText(const QString &text);
63 int buttons() const
64 {
65 return m_buttons;
66 }
67 void setButtons(int buttons);
68};
69
70#endif // MESSAGEDIALOG_H