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) 2026 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 "../iuistate.h"
26 :
27 : #include "modularity/ioc.h"
28 :
29 : #include "global/async/notification.h"
30 : #include "uiarrangement.h"
31 :
32 : namespace muse::ui {
33 : class UiState : public IUiState, public async::Asyncable, public Contextable
34 : {
35 : public:
36 0 : UiState(const modularity::ContextPtr& iocCtx)
37 0 : : Contextable(iocCtx), m_uiArrangement(iocCtx) {}
38 :
39 : void init();
40 :
41 : QByteArray windowGeometry() const override;
42 : void setWindowGeometry(const QByteArray& state) override;
43 : async::Notification windowGeometryChanged() const override;
44 :
45 : ValNt<QByteArray> pageState(const QString& pageName) const override;
46 : void setPageState(const QString& pageName, const QByteArray& state) override;
47 :
48 : ToolConfig toolConfig(const QString& toolName, const ToolConfig& defaultConfig) const override;
49 : void setToolConfig(const QString& toolName, const ToolConfig& config) override;
50 : async::Notification toolConfigChanged(const QString& toolName) const override;
51 :
52 : QString uiItemState(const QString& itemName) const override;
53 : void setUiItemState(const QString& itemName, const QString& value) override;
54 : async::Notification uiItemStateChanged(const QString& itemName) const override;
55 :
56 : bool isVisible(const QString& key, bool def = true) const override;
57 : void setIsVisible(const QString& key, bool val) override;
58 : async::Notification isVisibleChanged(const QString& key) const override;
59 :
60 : private:
61 :
62 : void updateToolConfig(const QString& toolName, ToolConfig& userConfig, const ToolConfig& defaultConfig) const;
63 :
64 : UiArrangement m_uiArrangement;
65 :
66 : async::Notification m_windowGeometryChanged;
67 : };
68 : }
|