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 <QPointer>
26 : #include <QQuickItem>
27 : #include <qqmlintegration.h>
28 :
29 : #include "modularity/ioc.h"
30 : #include "actions/iactionsdispatcher.h"
31 :
32 : #include "docktabsmodel.h"
33 :
34 : namespace KDDockWidgets {
35 : namespace QtQuick {
36 : class Group;
37 : class DockWidget;
38 : }
39 : }
40 :
41 : namespace muse::dock {
42 : class DockFrameModel : public QObject, public muse::Contextable
43 : {
44 : Q_OBJECT
45 :
46 : Q_PROPERTY(QQuickItem * frame READ frame WRITE setFrame NOTIFY frameChanged)
47 : Q_PROPERTY(muse::dock::DockTabsModel * tabsModel READ tabsModel CONSTANT)
48 :
49 : Q_PROPERTY(QQmlComponent * titleBar READ titleBar NOTIFY titleBarChanged)
50 : Q_PROPERTY(bool titleBarAllowed READ titleBarAllowed NOTIFY titleBarAllowedChanged)
51 : Q_PROPERTY(bool isHorizontalPanel READ isHorizontalPanel NOTIFY isHorizontalPanelChanged)
52 : Q_PROPERTY(QObject * navigationSection READ navigationSection NOTIFY navigationSectionChanged)
53 : Q_PROPERTY(QString currentDockUniqueName READ currentDockUniqueName NOTIFY currentDockChanged)
54 :
55 : Q_PROPERTY(bool highlightingVisible READ highlightingVisible NOTIFY highlightingVisibleChanged)
56 : Q_PROPERTY(QRect highlightingRect READ highlightingRect NOTIFY highlightingVisibleChanged)
57 :
58 : QML_ELEMENT
59 :
60 : muse::ContextInject<muse::actions::IActionsDispatcher> dispatcher = { this };
61 :
62 : public:
63 : explicit DockFrameModel(QObject* parent = nullptr);
64 :
65 : QQuickItem* frame() const;
66 0 : DockTabsModel* tabsModel() const { return m_tabsModel; }
67 :
68 : QQmlComponent* titleBar() const;
69 : bool titleBarAllowed() const;
70 : bool isHorizontalPanel() const;
71 : QObject* navigationSection() const;
72 : QString currentDockUniqueName() const;
73 :
74 : bool highlightingVisible() const;
75 : QRect highlightingRect() const;
76 :
77 : Q_INVOKABLE void handleMenuItem(const QString& itemId) const;
78 :
79 : public slots:
80 : void setFrame(QQuickItem* item);
81 :
82 : signals:
83 : void frameChanged(QQuickItem* frame);
84 : void titleBarChanged();
85 : void titleBarAllowedChanged(bool visible);
86 : void isHorizontalPanelChanged();
87 : void navigationSectionChanged();
88 : void currentDockChanged();
89 : void highlightingVisibleChanged();
90 :
91 : private:
92 : bool eventFilter(QObject* watched, QEvent* event);
93 :
94 : QVariant currentDockContextMenuModel() const;
95 : QVariant currentDockToolbarComponent() const;
96 :
97 : void onContextMenuChanged(QObject* obj);
98 : void onToolBarComponentChanged(QObject* obj);
99 :
100 : void listenChangesInFrame();
101 : void setTitleBarAllowed(bool allowed);
102 : void setIsHorizontalPanel(bool is);
103 :
104 : KDDockWidgets::QtQuick::DockWidget* currentDockWidget() const;
105 : QVariant currentDockProperty(const char* propertyName) const;
106 :
107 : QObject* currentNavigationSection() const;
108 : void updateNavigationSection();
109 :
110 : QQmlComponent* currentTitleBar() const;
111 : void updateTitleBar();
112 :
113 : QPointer<KDDockWidgets::QtQuick::Group> m_frame;
114 : QQmlComponent* m_titleBar = nullptr;
115 : bool m_titleBarAllowed = false;
116 : bool m_isHorizontalPanel = false;
117 : QObject* m_navigationSection = nullptr;
118 :
119 : DockTabsModel* m_tabsModel = nullptr;
120 : };
121 : }
|