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) 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 : #include "audioactionscontroller.h"
23 :
24 : #include "../audiocommands.h"
25 : #include "types/ret.h"
26 :
27 : using namespace muse;
28 : using namespace muse::audio;
29 :
30 0 : void AudioActionsController::init()
31 : {
32 0 : dispatcher()->onRequest(this, AUDIO_DEV_USE_DRIVER_MODE_COMMAND, [this]() { setMode(workmode::DriverMode); return muse::make_ok(); });
33 0 : dispatcher()->onRequest(this, AUDIO_DEV_USE_HYBRID_MODE_COMMAND, [this]() { setMode(workmode::HybridMode); return muse::make_ok(); });
34 0 : }
35 :
36 0 : void AudioActionsController::setMode(workmode::Mode m)
37 : {
38 0 : workmode::setMode(m);
39 0 : m_modeChanged.notify();
40 :
41 0 : auto promise = interactive()->question("Changing the audio mode",
42 : "Restart required, do you want to perform it?",
43 0 : { IInteractive::Button::Yes, IInteractive::Button::No });
44 :
45 0 : promise.onResolve(nullptr, [this](const IInteractive::Result& res) {
46 0 : if (res.isButton(IInteractive::Button::Yes)) {
47 0 : application()->restart();
48 : }
49 0 : });
50 0 : }
51 :
52 0 : workmode::Mode AudioActionsController::mode() const
53 : {
54 0 : return workmode::desiredMode();
55 : }
56 :
57 0 : async::Notification AudioActionsController:: modeChanged() const
58 : {
59 0 : return m_modeChanged;
60 : }
|