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 : #pragma once
23 :
24 : #include <QQmlParserStatus>
25 : #include <qqmlintegration.h>
26 :
27 : #include "rcommand/commandtypes.h"
28 : #include "uicomponents/qml/Muse/UiComponents/abstractmenumodel.h"
29 :
30 : #include "modularity/ioc.h"
31 : #include "rcommand/icommandsregister.h"
32 : #include "project/iprojectsession.h"
33 : #include "ui/iuistate.h"
34 : #include "notationscene/inotationcommandscontroller.h"
35 :
36 : namespace mu::notation {
37 : class NoteInputBarModel : public muse::uicomponents::AbstractMenuModel, public QQmlParserStatus
38 : {
39 : Q_OBJECT
40 : Q_INTERFACES(QQmlParserStatus);
41 : QML_ELEMENT;
42 :
43 : Q_PROPERTY(bool isInputAllowed READ isInputAllowed NOTIFY isInputAllowedChanged)
44 :
45 : muse::GlobalInject<muse::rcommand::ICommandsRegister> commandsRegister;
46 : muse::ContextInject<muse::ui::IUiState> uiState = { this };
47 : muse::ContextInject<INotationCommandsController> commandsController = { this };
48 :
49 : public:
50 : explicit NoteInputBarModel(QObject* parent = nullptr);
51 :
52 : QVariant data(const QModelIndex& index, int role) const override;
53 : QHash<int, QByteArray> roleNames() const override;
54 :
55 : bool isInputAllowed() const;
56 :
57 : static const muse::ui::ToolConfig& defaultNoteInputConfig();
58 :
59 : static const std::string CROSS_STAFF_BEAMING_SUBITEMS;
60 : static const std::string TUPLET_SUBITEMS;
61 :
62 : struct ServiceItemInfo {
63 : muse::MnemonicString title;
64 : muse::ui::IconCode::Code icon = muse::ui::IconCode::Code::NONE;
65 : };
66 : static ServiceItemInfo serviceItemInfo(const std::string& intent);
67 :
68 : signals:
69 : void isInputAllowedChanged();
70 :
71 : private:
72 : enum NoteInputRoles {
73 : OrderRole = AbstractMenuModel::Roles::UserRole + 1,
74 : SectionRole
75 : };
76 :
77 : void classBegin() override;
78 0 : void componentComplete() override {}
79 : void init();
80 : void load() override;
81 :
82 : muse::uicomponents::MenuItem* makeServiceItem(const std::string& intent, const QString& section);
83 : muse::uicomponents::MenuItem* makeCommandItem(const muse::rcommand::Command& command, const QString& section);
84 : muse::uicomponents::MenuItem* makeAddItem(const QString& section);
85 :
86 : muse::uicomponents::MenuItemList makeCrossStaffBeamingItems();
87 : muse::uicomponents::MenuItemList makeTupletItems();
88 : muse::uicomponents::MenuItemList makeAddItems();
89 : muse::uicomponents::MenuItemList makeNotesItems();
90 : muse::uicomponents::MenuItemList makeIntervalsItems();
91 : muse::uicomponents::MenuItemList makeMeasuresItems();
92 : muse::uicomponents::MenuItemList makeFramesItems();
93 : muse::uicomponents::MenuItemList makeTextItems();
94 : muse::uicomponents::MenuItemList makeLinesItems();
95 : muse::uicomponents::MenuItemList makeChordAndFretboardDiagramsItems();
96 : };
97 : }
|