Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #pragma once
24 :
25 : #include <QObject>
26 : #include <QString>
27 :
28 : #include "global/modularity/ioc.h"
29 : #include "global/async/asyncable.h"
30 : #include "interactive/iinteractive.h"
31 :
32 : namespace muse::extensions::apiv1 {
33 : namespace StandardButton {
34 : Q_NAMESPACE
35 :
36 : enum Button {
37 : Ok = static_cast<int>(IInteractive::Button::Ok),
38 : Cancel = static_cast<int>(IInteractive::Button::Cancel),
39 : };
40 0 : Q_ENUM_NS(Button)
41 : }
42 :
43 : class MessageDialog : public QObject, public Contextable, public muse::async::Asyncable
44 : {
45 : Q_OBJECT
46 : Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
47 : Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
48 : Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText NOTIFY detailedTextChanged FINAL)
49 : Q_PROPERTY(QVariantList standardButtons READ standardButtons WRITE setStandardButtons NOTIFY standardButtonsChanged FINAL)
50 : Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged FINAL)
51 :
52 : ContextInject<IInteractive> interactive = { this };
53 :
54 : public:
55 :
56 : MessageDialog(QObject* parent = nullptr);
57 :
58 : QString text() const;
59 : void setText(const QString& newText);
60 :
61 : bool visible() const;
62 : void setVisible(bool newVisible);
63 :
64 : QString title() const;
65 : void setTitle(const QString& newTitle);
66 :
67 : QString detailedText() const;
68 : void setDetailedText(const QString& newDetailedText);
69 :
70 : QVariantList standardButtons() const;
71 : void setStandardButtons(const QVariantList& newStandardButtons);
72 :
73 : Q_INVOKABLE void open();
74 : Q_INVOKABLE void close();
75 :
76 : signals:
77 : void textChanged();
78 : void visibleChanged();
79 : void titleChanged();
80 : void detailedTextChanged();
81 : void standardButtonsChanged();
82 :
83 : void accepted();
84 : void rejected();
85 :
86 : private:
87 :
88 : void doOpen(const QString& contentTitle, const QString& text, const QString& detailed, const QVariantList& buttons);
89 :
90 : QString m_text;
91 : bool m_visible = false;
92 : QString m_title;
93 : QString m_detailedText;
94 : QVariantList m_standardButtons;
95 : };
96 : }
|