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 :
23 : #ifndef MUSE_UI_UIARRANGEMENT_H
24 : #define MUSE_UI_UIARRANGEMENT_H
25 :
26 : #include <QString>
27 : #include <QByteArray>
28 : #include <QList>
29 : #include <QJsonObject>
30 : #include <QMap>
31 :
32 : #include "global/async/asyncable.h"
33 : #include "modularity/ioc.h"
34 : #include "workspace/iworkspacesdataprovider.h"
35 : #include "toolconfig.h"
36 :
37 : namespace muse::ui {
38 : class UiArrangement : public Contextable, public async::Asyncable
39 : {
40 : ContextInject<workspace::IWorkspacesDataProvider> workspacesDataProvider = { this };
41 : public:
42 0 : UiArrangement(const modularity::ContextPtr& iocCtx)
43 0 : : Contextable(iocCtx) {}
44 :
45 : void load();
46 :
47 : QString value(const QString& key) const;
48 : void setValue(const QString& key, const QString& val);
49 : async::Notification valueChanged(const QString& key) const;
50 :
51 : QByteArray state(const QString& key) const;
52 : void setState(const QString& key, const QByteArray& data);
53 : async::Notification stateChanged(const QString& key) const;
54 :
55 : ToolConfig toolConfig(const QString& toolName) const;
56 : void setToolConfig(const QString& toolName, const ToolConfig& config);
57 : async::Notification toolConfigChanged(const QString& toolName) const;
58 :
59 : private:
60 :
61 : using Notifications = QMap<QString, async::Notification>;
62 :
63 : void updateData(workspace::DataKey key, QJsonObject& obj, Notifications& notifications) const;
64 : void saveData(workspace::DataKey key, const QJsonObject& obj);
65 :
66 : QJsonObject m_settings;
67 : mutable Notifications m_valuesNotifications;
68 :
69 : QJsonObject m_states;
70 : mutable Notifications m_statesNotifications;
71 :
72 : QJsonObject m_toolconfigs;
73 : mutable Notifications m_toolconfigsNotifications;
74 : };
75 : }
76 :
77 : #endif // MUSE_UI_UIARRANGEMENT_H
|