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 : #pragma once
23 :
24 : #include <qqmlintegration.h>
25 :
26 : #include "popupview.h"
27 :
28 : namespace muse::uicomponents {
29 : class MenuView : public PopupView
30 : {
31 : Q_OBJECT
32 : QML_ELEMENT
33 : Q_INTERFACES(QQmlParserStatus)
34 :
35 : Q_PROPERTY(bool isSearchable READ isSearchable WRITE setIsSearchable NOTIFY isSearchableChanged)
36 : Q_PROPERTY(bool isSearching READ isSearching WRITE setIsSearching NOTIFY isSearchingChanged)
37 :
38 : Q_PROPERTY(int viewMargins READ viewMargins CONSTANT)
39 :
40 : Q_PROPERTY(int contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
41 : Q_PROPERTY(int contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
42 :
43 : Q_PROPERTY(int desiredHeight READ desiredHeight WRITE setDesiredHeight NOTIFY desiredHeightChanged)
44 : Q_PROPERTY(int desiredWidth READ desiredWidth WRITE setDesiredWidth NOTIFY desiredWidthChanged)
45 :
46 : Q_PROPERTY(Qt::AlignmentFlag cascadeAlign READ cascadeAlign WRITE setCascadeAlign NOTIFY cascadeAlignChanged)
47 :
48 : public:
49 : explicit MenuView(QQuickItem* parent = nullptr);
50 0 : ~MenuView() override = default;
51 :
52 : bool isSearchable() const;
53 : void setIsSearchable(bool isSearchable);
54 :
55 : bool isSearching() const;
56 : void setIsSearching(bool isSearching);
57 :
58 : int viewMargins() const;
59 :
60 : int contentWidth() const;
61 : void setContentWidth(int newContentWidth);
62 :
63 : int contentHeight() const;
64 : void setContentHeight(int newContentHeight);
65 :
66 : int desiredHeight() const;
67 : void setDesiredHeight(int desiredHeight);
68 :
69 : int desiredWidth() const;
70 : void setDesiredWidth(int desiredWidth);
71 :
72 : Qt::AlignmentFlag cascadeAlign() const;
73 :
74 : public slots:
75 : void setCascadeAlign(Qt::AlignmentFlag cascadeAlign);
76 :
77 : signals:
78 : void isSearchableChanged();
79 : void isSearchingChanged();
80 :
81 : void desiredHeightChanged();
82 : void desiredWidthChanged();
83 :
84 : void cascadeAlignChanged(Qt::AlignmentFlag cascadeAlign);
85 :
86 : private:
87 : void componentComplete() override;
88 :
89 : void updateGeometry() override;
90 : void updateContentPosition() override;
91 :
92 : QRect viewGeometry() const override;
93 :
94 : Qt::AlignmentFlag parentCascadeAlign(const QQuickItem* parent) const;
95 :
96 : QQuickItem* parentMenuContentItem() const;
97 :
98 : private:
99 : bool m_isSearchable = false;
100 : bool m_isSearching = false;
101 :
102 : int m_contentWidth = -1;
103 : int m_contentHeight = -1;
104 :
105 : int m_desiredHeight = -1;
106 : int m_desiredWidth = -1;
107 :
108 : Qt::AlignmentFlag m_cascadeAlign = Qt::AlignmentFlag::AlignRight;
109 : };
110 : }
|