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 : #ifndef __KEYEDIT_H__
24 : #define __KEYEDIT_H__
25 :
26 : #include "ui/view/widgetdialog.h"
27 :
28 : #include "ui_keyedit.h"
29 :
30 : #include "modularity/ioc.h"
31 : #include "ipaletteconfiguration.h"
32 : #include "internal/ipaletteprovider.h"
33 : #include "engraving/ipalettescoreprovider.h"
34 :
35 : namespace mu::palette {
36 : class PaletteWidget;
37 : class PaletteScrollArea;
38 :
39 : class KeyEditor : public QWidget, Ui::KeyEdit, public muse::Contextable
40 : {
41 : Q_OBJECT
42 :
43 : Q_PROPERTY(bool showKeyPalette READ showKeyPalette WRITE setShowKeyPalette)
44 :
45 : muse::GlobalInject<IPaletteConfiguration> configuration;
46 : muse::ContextInject<IPaletteProvider> paletteProvider = { this };
47 : muse::ContextInject<engraving::IPaletteScoreProvider> paletteScoreProvider = { this };
48 :
49 : public:
50 : KeyEditor(QWidget* parent = nullptr);
51 :
52 0 : bool dirty() const { return m_dirty; }
53 : void save();
54 :
55 : bool showKeyPalette() const;
56 :
57 : public slots:
58 : void setShowKeyPalette(bool showKeyPalette);
59 :
60 : private slots:
61 : void addClicked();
62 : void clearClicked();
63 0 : void setDirty() { m_dirty = true; }
64 :
65 : private:
66 : PaletteScrollArea* m_keySigArea = nullptr;
67 : PaletteWidget* m_keySigPaletteWidget = nullptr;
68 : PaletteWidget* m_accidentalsPaletteWidget = nullptr;
69 :
70 : bool m_dirty = false;
71 : };
72 :
73 : static const int KEYEDIT_ACC_ZERO_POINT = 3;
74 :
75 : class KeyEditorDialog : public muse::ui::WidgetDialog
76 : {
77 : Q_OBJECT
78 :
79 : Q_PROPERTY(bool showKeyPalette READ showKeyPalette WRITE setShowKeyPalette)
80 :
81 : public:
82 : KeyEditorDialog(QWidget* parent = nullptr);
83 :
84 : void classBegin() override;
85 :
86 : bool showKeyPalette() const;
87 : void setShowKeyPalette(bool showKeyPalette);
88 :
89 : private:
90 : KeyEditor* m_keyEditor = nullptr;
91 : };
92 : }
93 :
94 : #endif
|