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 : #pragma once
24 :
25 : #include <QObject>
26 : #include <QList>
27 :
28 : #include <qqmlintegration.h>
29 :
30 : #include "abstractnavigation.h"
31 : #include "navigationpanel.h"
32 :
33 : #include "modularity/ioc.h"
34 : #include "global/iapplication.h"
35 : #include "ui/inavigationcontroller.h"
36 :
37 : namespace muse::ui {
38 : class NavigationSection : public AbstractNavigation, public INavigationSection
39 : {
40 : Q_OBJECT
41 : Q_PROPERTY(QmlType type READ type_property WRITE setType NOTIFY typeChanged)
42 : QML_ELEMENT
43 :
44 : public:
45 : GlobalInject<IApplication> application;
46 : ContextInject<INavigationController> navigationController = { this };
47 :
48 : public:
49 : explicit NavigationSection(QObject* parent = nullptr);
50 : explicit NavigationSection(const muse::modularity::ContextPtr& iocCtx, QObject* parent = nullptr);
51 : ~NavigationSection() override;
52 :
53 : //! NOTE Please sync with INavigationSection::Type
54 : enum QmlType {
55 : Regular = 0,
56 : Exclusive,
57 : Ignore
58 : };
59 0 : Q_ENUM(QmlType)
60 :
61 : QmlType type_property() const;
62 : INavigationSection::Type type() const override;
63 : QString name() const override;
64 :
65 : const Index& index() const override;
66 : void setIndex(const INavigation::Index& index) override;
67 : async::Channel<Index> indexChanged() const override;
68 :
69 : bool enabled() const override;
70 : async::Channel<bool> enabledChanged() const override;
71 :
72 : bool active() const override;
73 : void setActive(bool arg) override;
74 : async::Channel<bool> activeChanged() const override;
75 :
76 : void onEvent(EventPtr e) override;
77 :
78 : QWindow* window() const override;
79 : QQuickItem* visualItem() const override;
80 :
81 : const std::set<INavigationPanel*>& panels() const override;
82 : async::Notification panelsListChanged() const override;
83 :
84 : void componentComplete() override;
85 :
86 : void addPanel(NavigationPanel* panel);
87 : void removePanel(NavigationPanel* panel);
88 :
89 : void setOnActiveRequested(const OnActiveRequested& func) override;
90 :
91 : //! NOTE Can be called from QML without args
92 : Q_INVOKABLE void requestActive(INavigationPanel* panel = nullptr, INavigationControl* control = nullptr, bool enableHighlight = false,
93 : ActivationType activationType = ActivationType::None) override;
94 :
95 : Q_INVOKABLE void requestPriority();
96 :
97 : public slots:
98 : void setType(QmlType type);
99 :
100 : signals:
101 : void typeChanged(QmlType type);
102 :
103 : private:
104 : std::set<INavigationPanel*> m_panels;
105 : async::Notification m_panelsListChanged;
106 : QmlType m_type = Regular;
107 : OnActiveRequested m_onActiveRequested;
108 : };
109 : }
|