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 : #include "ui/view/iconcodes.h"
23 : #include "toast/toastitem.h"
24 :
25 : #include "toastservice.h"
26 :
27 : using namespace muse::ui;
28 : using namespace muse::toast;
29 :
30 0 : muse::async::Promise<ToastResult> ToastService::show(const std::string& title, const std::string& message,
31 : muse::ui::IconCode::Code iconCode, bool dismissible,
32 : const std::vector<ToastAction>& actions)
33 : {
34 0 : return toastProvider()->show(ToastItem(title, message, iconCode, dismissible, std::chrono::seconds(0), actions));
35 : }
36 :
37 0 : muse::async::Promise<ToastResult> ToastService::showWithTimeout(const std::string& title, const std::string& message,
38 : std::chrono::seconds timeout,
39 : muse::ui::IconCode::Code iconCode, bool dismissible,
40 : const std::vector<ToastAction>& actions)
41 : {
42 0 : return toastProvider()->show(ToastItem(title, message, iconCode, dismissible, timeout, actions));
43 : }
44 :
45 0 : void ToastService::showSuccess(const std::string& title, const std::string& message)
46 : {
47 0 : show(title, message, IconCode::Code::TICK, true, {});
48 0 : }
49 :
50 0 : void ToastService::showError(const std::string& title, const std::string& message)
51 : {
52 0 : show(title, message, IconCode::Code::ERROR, true, {});
53 0 : }
54 :
55 0 : void ToastService::showInfo(const std::string& title, const std::string& message)
56 : {
57 0 : show(title, message, IconCode::Code::INFO, true, {});
58 0 : }
59 :
60 0 : void ToastService::showWarning(const std::string& title, const std::string& message)
61 : {
62 0 : show(title, message, IconCode::Code::WARNING, true, {});
63 0 : }
64 :
65 0 : muse::async::Promise<ToastResult> ToastService::showWithProgress(const std::string& title, const std::string& message,
66 : std::shared_ptr<muse::Progress> progress,
67 : muse::ui::IconCode::Code iconCode, bool dismissible,
68 : const std::vector<ToastAction>& actions, bool showProgressInfo)
69 : {
70 0 : return toastProvider()->show(ToastItem(title, message, iconCode, dismissible, actions, progress, showProgressInfo));
71 : }
|