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<project::IProjectSession> context = { this };
48 : muse::ContextInject<INotationCommandsController> commandsController = { this };
49 :
50 : public:
51 : explicit NoteInputBarModel(QObject* parent = nullptr);
52 :
53 : QVariant data(const QModelIndex& index, int role) const override;
54 : QHash<int, QByteArray> roleNames() const override;
55 :
56 : bool isInputAllowed() const;
57 :
58 : static const muse::ui::ToolConfig& defaultNoteInputConfig();
59 :
60 : static const std::string CROSS_STAFF_BEAMING_SUBITEMS;
61 : static const std::string TUPLET_SUBITEMS;
62 :
63 : struct ServiceItemInfo {
64 : muse::MnemonicString title;
65 : muse::ui::IconCode::Code icon = muse::ui::IconCode::Code::NONE;
66 : };
67 : static ServiceItemInfo serviceItemInfo(const std::string& intent);
68 :
69 : signals:
70 : void isInputAllowedChanged();
71 :
72 : private:
73 : enum NoteInputRoles {
74 : OrderRole = AbstractMenuModel::Roles::UserRole + 1,
75 : SectionRole
76 : };
77 :
78 : void classBegin() override;
79 0 : void componentComplete() override {}
80 : void init();
81 : void load() override;
82 :
83 : muse::uicomponents::MenuItem* makeServiceItem(const std::string& intent, const QString& section);
84 : muse::uicomponents::MenuItem* makeCommandItem(const muse::rcommand::Command& command, const QString& section);
85 : muse::uicomponents::MenuItem* makeAddItem(const QString& section);
86 :
87 : muse::uicomponents::MenuItemList makeCrossStaffBeamingItems();
88 : muse::uicomponents::MenuItemList makeTupletItems();
89 : muse::uicomponents::MenuItemList makeAddItems();
90 : muse::uicomponents::MenuItemList makeNotesItems();
91 : muse::uicomponents::MenuItemList makeIntervalsItems();
92 : muse::uicomponents::MenuItemList makeMeasuresItems();
93 : muse::uicomponents::MenuItemList makeFramesItems();
94 : muse::uicomponents::MenuItemList makeTextItems();
95 : muse::uicomponents::MenuItemList makeLinesItems();
96 : muse::uicomponents::MenuItemList makeChordAndFretboardDiagramsItems();
97 : };
98 : }
|