Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-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 <QString>
27 : #include <qqmlintegration.h>
28 :
29 : #include "ui/view/iconcodes.h"
30 :
31 : namespace mu::notation {
32 : class NoteInputBarCustomiseItem : public QObject
33 : {
34 : Q_OBJECT
35 :
36 : Q_PROPERTY(ItemType type READ type CONSTANT)
37 : Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
38 : Q_PROPERTY(int icon READ icon NOTIFY iconChanged)
39 : Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY checkedChanged)
40 :
41 : QML_ELEMENT
42 : QML_UNCREATABLE("Must be created in C++ only")
43 :
44 : public:
45 : enum ItemType {
46 : UNDEFINED = -1,
47 : ACTION,
48 : SEPARATOR
49 : };
50 0 : Q_ENUM(ItemType)
51 :
52 : explicit NoteInputBarCustomiseItem(const ItemType& type, QObject* parent = nullptr);
53 :
54 : ItemType type() const;
55 : QString title() const;
56 : int icon() const;
57 : bool checked() const;
58 :
59 : Q_INVOKABLE QString id() const;
60 : void setId(const QString& id);
61 :
62 : public slots:
63 : void setTitle(QString title);
64 : void setIcon(muse::ui::IconCode::Code icon);
65 : void setChecked(bool checked);
66 :
67 : signals:
68 : void titleChanged();
69 : void iconChanged();
70 : void checkedChanged(bool checked);
71 :
72 : private:
73 :
74 : QString m_id;
75 : ItemType m_type = ItemType::UNDEFINED;
76 : QString m_title;
77 : muse::ui::IconCode::Code m_icon = muse::ui::IconCode::Code::NONE;
78 : bool m_checked = false;
79 : };
80 : }
|