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 <QQmlParserStatus>
27 : #include <qqmlintegration.h>
28 :
29 : #include "async/asyncable.h"
30 : #include "modularity/ioc.h"
31 : #include "ui/inavigation.h"
32 : #include "ui/inavigationcontroller.h"
33 :
34 : #include "qmlaccessible.h"
35 : #include "navigationevent.h"
36 :
37 : namespace muse::ui {
38 : class AbstractNavigation : public QObject, public QQmlParserStatus, public Contextable, public async::Asyncable
39 : {
40 : Q_OBJECT
41 : QML_ELEMENT;
42 : QML_UNCREATABLE("AbstractNavigation is an abstract base class")
43 :
44 : Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
45 :
46 : // see INavigation::Index
47 : Q_PROPERTY(int order READ order WRITE setOrder NOTIFY orderChanged)
48 : Q_PROPERTY(int column READ column WRITE setColumn NOTIFY columnChanged)
49 : Q_PROPERTY(int row READ row WRITE setRow NOTIFY rowChanged)
50 :
51 : Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
52 : Q_PROPERTY(bool active READ active NOTIFY activeChanged)
53 : Q_PROPERTY(bool highlight READ highlight NOTIFY highlightChanged)
54 :
55 : Q_PROPERTY(muse::ui::AccessibleItem * accessible READ accessible WRITE setAccessible NOTIFY accessibleChanged)
56 :
57 : Q_INTERFACES(QQmlParserStatus)
58 :
59 : public:
60 : ContextInject<INavigationController> navigationController = { this };
61 :
62 : public:
63 : explicit AbstractNavigation(QObject* parent = nullptr);
64 : explicit AbstractNavigation(const muse::modularity::ContextPtr& iocCtx, QObject* parent = nullptr);
65 :
66 : int order() const;
67 : int column() const;
68 : int row() const;
69 :
70 : QString name() const;
71 :
72 : const INavigation::Index& index() const;
73 : void setIndex(const INavigation::Index& index);
74 : async::Channel<INavigation::Index> indexChanged() const;
75 :
76 : bool enabled() const;
77 : async::Channel<bool> enabledChanged() const;
78 :
79 : bool active() const;
80 : async::Channel<bool> activeChanged() const;
81 :
82 : bool highlight() const;
83 :
84 : AccessibleItem* accessible() const;
85 : void setAccessibleParent(AccessibleItem* p);
86 :
87 : void onEvent(INavigation::EventPtr e);
88 :
89 : QWindow* window() const;
90 : QQuickItem* visualItem() const;
91 :
92 : // QQmlParserStatus
93 0 : void classBegin() override {}
94 :
95 : bool isComponentCompleted() const;
96 : void componentComplete() override;
97 :
98 : public slots:
99 : void setName(QString name);
100 : void setOrder(int order);
101 : void setColumn(int column);
102 : void setRow(int row);
103 : void setEnabled(bool enabled);
104 : void setActive(bool active);
105 : void setAccessible(AccessibleItem* accessible);
106 :
107 : signals:
108 : void nameChanged(QString name);
109 : void orderChanged(int order);
110 : void columnChanged(int column);
111 : void rowChanged(int row);
112 : void enabledChanged(bool enabled);
113 : void activeChanged(bool active);
114 : void highlightChanged();
115 : void accessibleChanged();
116 :
117 : void navigationEvent(muse::ui::NavigationEvent* event);
118 :
119 : protected:
120 :
121 : QString m_name;
122 : INavigation::Index m_index;
123 : async::Channel<INavigation::Index> m_indexChanged;
124 :
125 : bool m_enabled = true;
126 : async::Channel<bool> m_enabledChanged;
127 :
128 : bool m_active = false;
129 : async::Channel<bool> m_activeChanged;
130 :
131 : NavigationEvent* m_event = nullptr;
132 :
133 : mutable AccessibleItem* m_accessible = nullptr;
134 :
135 : bool m_isComponentCompleted = false;
136 : };
137 : }
|