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 "navigationcontrol.h"
32 :
33 : Q_MOC_INCLUDE("ui/qml/Muse/Ui/navigationsection.h")
34 :
35 : namespace muse::ui {
36 : class NavigationSection;
37 : class NavigationPanel : public AbstractNavigation, public INavigationPanel
38 : {
39 : Q_OBJECT
40 : Q_PROPERTY(muse::ui::NavigationSection * section READ section_property WRITE setSection_property NOTIFY sectionChanged)
41 : Q_PROPERTY(QmlDirection direction READ direction_property WRITE setDirection NOTIFY directionChanged)
42 : Q_PROPERTY(QString directionInfo READ directionInfo NOTIFY directionChanged)
43 : QML_ELEMENT
44 :
45 : public:
46 : explicit NavigationPanel(QObject* parent = nullptr);
47 : explicit NavigationPanel(const muse::modularity::ContextPtr& iocCtx, QObject* parent = nullptr);
48 : ~NavigationPanel() override;
49 :
50 : //! NOTE Please sync with INavigationPanel::Direction
51 : enum QmlDirection {
52 : Horizontal = 0,
53 : Vertical,
54 : Both
55 : };
56 0 : Q_ENUM(QmlDirection)
57 :
58 : QString name() const override;
59 :
60 : const Index& index() const override;
61 : void setIndex(const INavigation::Index& index) override;
62 : async::Channel<Index> indexChanged() const override;
63 :
64 : bool enabled() const override;
65 : async::Channel<bool> enabledChanged() const override;
66 :
67 : bool active() const override;
68 : void setActive(bool arg) override;
69 : async::Channel<bool> activeChanged() const override;
70 :
71 : void onEvent(EventPtr e) override;
72 :
73 : QWindow* window() const override;
74 : QQuickItem* visualItem() const override;
75 :
76 : QmlDirection direction_property() const;
77 : QString directionInfo() const;
78 : Direction direction() const override;
79 :
80 : const std::set<INavigationControl*>& controls() const override;
81 : async::Notification controlsListChanged() const override;
82 :
83 : INavigationSection* section() const override;
84 : NavigationSection* section_property() const;
85 :
86 : void addControl(NavigationControl* control);
87 : void removeControl(NavigationControl* control);
88 :
89 : //! NOTE Can be called from QML without args
90 : Q_INVOKABLE void requestActive(INavigationControl* control = nullptr, bool enableHighlight = false,
91 : ActivationType activationType = ActivationType::None) override;
92 :
93 : void componentComplete() override;
94 :
95 : public slots:
96 : void setSection_property(NavigationSection* section);
97 : void setSection(INavigationSection* section);
98 : void setDirection(QmlDirection direction);
99 :
100 : signals:
101 : void sectionChanged(NavigationSection* section);
102 : void directionChanged();
103 :
104 : private slots:
105 : void onSectionDestroyed();
106 :
107 : private:
108 : NavigationSection* m_section = nullptr;
109 : std::set<INavigationControl*> m_controls;
110 : async::Notification m_controlsListChanged;
111 : QmlDirection m_direction = QmlDirection::Horizontal;
112 : };
113 : }
|