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 "api/apiobject.h"
26 :
27 : #include "modularity/ioc.h"
28 : #include "interactive/iinteractive.h"
29 : #include "interactive/iplatforminteractive.h"
30 :
31 : namespace muse::interactive {
32 : class InteractiveApi : public api::ApiObject
33 : {
34 : Q_OBJECT
35 :
36 : GlobalInject<IPlatformInteractive> platformInteractive;
37 : ContextInject<IInteractive> interactive = { this };
38 :
39 : public:
40 : explicit InteractiveApi(api::IApiEngine* e);
41 :
42 : /** APIDOC
43 : * Question buttons
44 : * @global
45 : * @enum
46 : */
47 : enum ButtonCode {
48 : Ok = int(IInteractive::Button::Ok),
49 : Continue = int(IInteractive::Button::Continue),
50 : RestoreDefaults = int(IInteractive::Button::RestoreDefaults),
51 : Reset = int(IInteractive::Button::Reset),
52 : Apply = int(IInteractive::Button::Apply),
53 : Help = int(IInteractive::Button::Help),
54 : Discard = int(IInteractive::Button::Discard),
55 : Cancel = int(IInteractive::Button::Cancel),
56 : Close = int(IInteractive::Button::Close),
57 : Ignore = int(IInteractive::Button::Ignore),
58 : Retry = int(IInteractive::Button::Retry),
59 : Abort = int(IInteractive::Button::Abort),
60 : NoToAll = int(IInteractive::Button::NoToAll),
61 : No = int(IInteractive::Button::No),
62 : YesToAll = int(IInteractive::Button::YesToAll),
63 : Yes = int(IInteractive::Button::Yes),
64 : Open = int(IInteractive::Button::Open),
65 : DontSave = int(IInteractive::Button::DontSave),
66 : SaveAll = int(IInteractive::Button::SaveAll),
67 : Save = int(IInteractive::Button::Save),
68 : Next = int(IInteractive::Button::Next),
69 : Back = int(IInteractive::Button::Back),
70 : Select = int(IInteractive::Button::Select),
71 : Clear = int(IInteractive::Button::Clear),
72 : Done = int(IInteractive::Button::Done),
73 : };
74 0 : Q_ENUM(ButtonCode);
75 :
76 : Q_INVOKABLE void info(const QString& contentTitle, const QString& text);
77 : Q_INVOKABLE void warning(const QString& contentTitle, const QString& text);
78 : Q_INVOKABLE void error(const QString& contentTitle, const QString& text);
79 :
80 : Q_INVOKABLE QString question(const QString& contentTitle, const QString& text, const QJSValueList& buttons);
81 :
82 : Q_INVOKABLE void openUrl(const QString& url);
83 :
84 : private:
85 : std::vector<muse::IInteractive::Button> buttons(const QJSValueList& buttons) const;
86 : };
87 : }
|