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) 2025 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 : #include <qqmlintegration.h>
28 :
29 : #include "async/asyncable.h"
30 :
31 : #include "modularity/ioc.h"
32 : #include "playback/iplaybackcontroller.h"
33 : #include "audio/main/iaudioconfiguration.h"
34 : #include "rcommand/icommanddispatcher.h"
35 : #include "project/iprojectsession.h"
36 : #include "tours/itoursservice.h"
37 :
38 : namespace mu::playback {
39 : class OnlineSoundsStatusModel : public QObject, public muse::async::Asyncable, public muse::Contextable
40 : {
41 : Q_OBJECT
42 :
43 : Q_PROPERTY(bool hasOnlineSounds READ hasOnlineSounds NOTIFY hasOnlineSoundsChanged)
44 : Q_PROPERTY(bool manualProcessingAllowed READ manualProcessingAllowed NOTIFY manualProcessingAllowedChanged)
45 :
46 : Q_PROPERTY(int status READ status NOTIFY statusChanged)
47 : Q_PROPERTY(QString errorTitle READ errorTitle NOTIFY statusChanged)
48 : Q_PROPERTY(QString errorDescription READ errorDescription NOTIFY statusChanged)
49 :
50 : QML_ELEMENT
51 :
52 : muse::GlobalInject<muse::audio::IAudioConfiguration> audioConfiguration;
53 : muse::ContextInject<IPlaybackController> playbackController = { this };
54 : muse::ContextInject<project::IProjectSession> projectSession = { this };
55 : muse::ContextInject<muse::rcommand::ICommandDispatcher> commandsDispatcher = { this };
56 : muse::ContextInject<muse::tours::IToursService> tours = { this };
57 :
58 : public:
59 : enum class Status {
60 : Processing,
61 : Success,
62 : Error,
63 : };
64 :
65 0 : Q_ENUM(Status);
66 :
67 : explicit OnlineSoundsStatusModel(QObject* parent = nullptr);
68 :
69 : Q_INVOKABLE void load();
70 : Q_INVOKABLE void processOnlineSounds();
71 :
72 : bool hasOnlineSounds() const;
73 : bool manualProcessingAllowed() const;
74 :
75 : int status() const;
76 : QString errorTitle() const;
77 : QString errorDescription() const;
78 :
79 : signals:
80 : void hasOnlineSoundsChanged();
81 : void manualProcessingAllowedChanged();
82 : void statusChanged();
83 :
84 : private:
85 : void onOnlineSoundsChanged();
86 : void updateManualProcessingAllowed(bool enableByDefault = true);
87 :
88 : void setManualProcessingAllowed(bool allowed);
89 : void setStatus(Status status);
90 :
91 : engraving::InstrumentTrackIdSet m_onlineTrackIdSet;
92 : bool m_manualProcessingAllowed = false;
93 : bool m_shouldNotifyToursThatManualProcessingAllowed = true;
94 : Status m_status = Status::Success;
95 : muse::Ret m_ret;
96 : muse::async::Channel<engraving::InstrumentTrackIdSet> m_tracksDataChanged;
97 : };
98 : }
|