drumstick  2.0.0
pianopalette.h
Go to the documentation of this file.
1 /*
2  MIDI Virtual Piano Keyboard
3  Copyright (C) 2008-2020, Pedro Lopez-Cabanillas <plcl@users.sf.net>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef PIANOPALETTE_H
20 #define PIANOPALETTE_H
21 
22 #include <QGuiApplication>
23 #include <QString>
24 #include <QColor>
25 #include <QList>
26 #include "macros.h"
27 
33 namespace drumstick { namespace widgets {
34 
46  PAL_SINGLE = 0,
47  PAL_DOUBLE = 1,
49  PAL_SCALE = 3,
50  PAL_KEYS = 4,
51  PAL_FONT = 5
52 };
53 
59 class DRUMSTICK_EXPORT PianoPalette
60 {
61  Q_GADGET
62  Q_DECLARE_TR_FUNCTIONS(PianoPalette)
63  Q_ENUM(PalettePolicy)
64 
65 public:
66  explicit PianoPalette(const int id);
67  virtual ~PianoPalette() = default;
68 
69  void resetColors();
70  void retranslateStrings();
71 
72  int paletteId() const;
73  int getNumColors() const;
74  bool isHighLight() const;
75  bool isBackground() const;
76  bool isForeground() const;
77 
78  QString paletteName() const;
79  void setPaletteName(const QString& name);
80 
81  QString paletteText() const;
82  void setPaletteText(const QString& text);
83 
84  QColor getColor(const int i) const;
85  void setColor(const int n, const QString& s, const QColor& c);
86  void setColor(const int n, const QColor& c);
87 
88  QString getColorName(const int i) const;
89  void setColorName(const int n, const QString& s);
90 
91  void saveColors() const;
92  void loadColors();
93 
94  bool operator==(const PianoPalette& other) const;
95  bool operator!=(const PianoPalette& other) const;
96 
97  static const QString QSTR_PALETTEPREFIX;
98 
99 protected:
100  void initialize();
101  void resetPaletteSingle();
102  void resetPaletteDouble();
103  void resetPaletteChannels();
104  void resetPaletteScale();
105  void resetPaletteKeys();
106  void resetPaletteFont();
107  void retranslatePaletteSingle();
108  void retranslatePaletteDouble();
109  void retranslatePaletteChannels();
110  void retranslatePaletteScale();
111  void retranslatePaletteKeys();
112  void retranslatePaletteFont();
113 
114  int m_paletteId;
115  QList<QColor> m_colors;
116  QList<QString> m_names;
117  QString m_paletteName;
118  QString m_paletteText;
119 };
120 
123 }} // namespace drumstick::widgets
124 
125 #endif // PIANOPALETTE_H
The PianoPalette class.
Definition: pianopalette.h:60
static const QString QSTR_PALETTEPREFIX
PianoPalette::QSTR_PALETTEPREFIX is the string prefix for all the settings stored as persisting setti...
Definition: pianopalette.h:97
PalettePolicy
The PalettePolicy enumeration.
Definition: pianopalette.h:45
@ PAL_SCALE
Background colors for each chromatic scale note.
Definition: pianopalette.h:49
@ PAL_SINGLE
Single highlihgting color for all keys.
Definition: pianopalette.h:46
@ PAL_CHANNELS
Different highlihgting colors for each channel.
Definition: pianopalette.h:48
@ PAL_KEYS
Two background colors (naturals/alterations)
Definition: pianopalette.h:50
@ PAL_DOUBLE
Two highlihgting colors (naturals/alterations)
Definition: pianopalette.h:47
@ PAL_FONT
Foreground font colors for names.
Definition: pianopalette.h:51
Drumstick visibility macros.
Drumstick common.
Definition: alsaclient.cpp:68