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) 2021 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 "learnconfiguration.h"
23 : #include "global/configreader.h"
24 :
25 : #include "settings.h"
26 :
27 : using namespace muse;
28 : using namespace muse::learn;
29 : using namespace muse::network;
30 :
31 : static const std::string module_name("learn");
32 : static const Settings::Key GET_PLAYLISTS_TEST_MODE_KEY(module_name, "learn/getPlaylistsTestMode");
33 :
34 0 : void LearnConfiguration::init()
35 : {
36 0 : m_config = ConfigReader::read(":/configs/learn.cfg");
37 :
38 0 : settings()->setDefaultValue(GET_PLAYLISTS_TEST_MODE_KEY, Val(false));
39 0 : }
40 :
41 0 : RequestHeaders LearnConfiguration::headers() const
42 : {
43 0 : RequestHeaders headers;
44 0 : headers.rawHeaders["Accept"] = "application/json";
45 0 : return headers;
46 0 : }
47 :
48 0 : QUrl LearnConfiguration::startedPlaylistUrl() const
49 : {
50 0 : return !isTestMode() ? QUrl(m_config.value("started_playlist_url").toQString())
51 0 : : QUrl(m_config.value("started_playlist_url.test").toQString());
52 : }
53 :
54 0 : QUrl LearnConfiguration::advancedPlaylistUrl() const
55 : {
56 0 : return !isTestMode() ? QUrl(m_config.value("advanced_playlist_url").toQString())
57 0 : : QUrl(m_config.value("advanced_playlist_url.test").toQString());
58 : }
59 :
60 0 : bool LearnConfiguration::classesEnabled() const
61 : {
62 0 : return m_config.value("classes_enabled", Val(true)).toBool();
63 : }
64 :
65 0 : bool LearnConfiguration::isTestMode() const
66 : {
67 0 : return settings()->value(GET_PLAYLISTS_TEST_MODE_KEY).toBool();
68 : }
|