Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2026 MuseScore Limited
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 : #pragma once
23 :
24 : #include <chrono>
25 : #include <string>
26 : #include <vector>
27 :
28 : #include "global/modularity/imoduleinterface.h"
29 : #include "ui/view/iconcodes.h"
30 : #include "global/progress.h"
31 : #include "global/async/promise.h"
32 :
33 : #include "toasttypes.h"
34 :
35 : namespace muse::toast {
36 : class IToastService : MODULE_GLOBAL_INTERFACE
37 : {
38 0 : INTERFACE_ID(IToast)
39 : public:
40 89 : virtual ~IToastService() = default;
41 : virtual muse::async::Promise<ToastResult> show(const std::string& title, const std::string& message,
42 : muse::ui::IconCode::Code iconCode = muse::ui::IconCode::Code::NONE,
43 : bool dismissible = true, const std::vector<ToastAction>& actions = {}) = 0;
44 : virtual muse::async::Promise<ToastResult> showWithTimeout(const std::string& title, const std::string& message,
45 : std::chrono::seconds timeout,
46 : muse::ui::IconCode::Code iconCode = muse::ui::IconCode::Code::NONE,
47 : bool dismissible = true, const std::vector<ToastAction>& actions = {}) = 0;
48 : virtual void showSuccess(const std::string& title, const std::string& message) = 0;
49 : virtual void showError(const std::string& title, const std::string& message) = 0;
50 : virtual void showInfo(const std::string& title, const std::string& message) = 0;
51 : virtual void showWarning(const std::string& title, const std::string& message) = 0;
52 : virtual muse::async::Promise<ToastResult> showWithProgress(const std::string& title, const std::string& message,
53 : std::shared_ptr<muse::Progress> progress,
54 : muse::ui::IconCode::Code iconCode = muse::ui::IconCode::Code::NONE,
55 : bool dismissible = false, const std::vector<ToastAction>& actions = {},
56 : bool showProgressInfo = false) = 0;
57 : };
58 : }
|