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) 2023 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 "saveandpublishpreferencesmodel.h"
23 :
24 : using namespace mu::preferences;
25 :
26 0 : SaveAndPublishPreferencesModel::SaveAndPublishPreferencesModel(QObject* parent)
27 0 : : QObject(parent), muse::Contextable(muse::iocCtxForQmlObject(this))
28 : {
29 0 : }
30 :
31 0 : void SaveAndPublishPreferencesModel::load()
32 : {
33 0 : projectConfiguration()->autoSaveEnabledChanged().onReceive(this, [this](bool enabled) {
34 0 : emit autoSaveEnabledChanged(enabled);
35 0 : });
36 :
37 0 : projectConfiguration()->autoSaveIntervalChanged().onReceive(this, [this](int minutes) {
38 0 : emit autoSaveIntervalChanged(minutes);
39 0 : });
40 :
41 0 : projectConfiguration()->alsoShareAudioComChanged().onReceive(this, [this](bool share) {
42 0 : emit alsoShareAudioComChanged(share);
43 0 : });
44 0 : }
45 :
46 0 : bool SaveAndPublishPreferencesModel::isAutoSaveEnabled() const
47 : {
48 0 : return projectConfiguration()->isAutoSaveEnabled();
49 : }
50 :
51 0 : int SaveAndPublishPreferencesModel::autoSaveInterval() const
52 : {
53 0 : return projectConfiguration()->autoSaveIntervalMinutes();
54 : }
55 :
56 0 : bool SaveAndPublishPreferencesModel::alsoShareAudioCom() const
57 : {
58 0 : return projectConfiguration()->alsoShareAudioCom();
59 : }
60 :
61 0 : void SaveAndPublishPreferencesModel::setAutoSaveEnabled(bool enabled)
62 : {
63 0 : if (enabled == isAutoSaveEnabled()) {
64 0 : return;
65 : }
66 :
67 0 : projectConfiguration()->setAutoSaveEnabled(enabled);
68 : }
69 :
70 0 : void SaveAndPublishPreferencesModel::setAutoSaveInterval(int minutes)
71 : {
72 0 : if (minutes == autoSaveInterval()) {
73 0 : return;
74 : }
75 :
76 0 : projectConfiguration()->setAutoSaveInterval(minutes);
77 : }
78 :
79 0 : void SaveAndPublishPreferencesModel::setAlsoShareAudioCom(bool share)
80 : {
81 0 : if (share == alsoShareAudioCom()) {
82 0 : return;
83 : }
84 :
85 0 : projectConfiguration()->setAlsoShareAudioCom(share);
86 : }
|