drumstick 2.7.2
pianopalette.h
Go to the documentation of this file.
1/*
2 MIDI Virtual Piano Keyboard
3 Copyright (C) 2008-2022, 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
33namespace drumstick { namespace widgets {
34
52 PAL_HISCALE = 6
53};
54
60class DRUMSTICK_EXPORT PianoPalette
61{
62 Q_GADGET
63 Q_DECLARE_TR_FUNCTIONS(PianoPalette)
64 Q_ENUM(PalettePolicy)
65
66public:
67 explicit PianoPalette(const int id);
68 virtual ~PianoPalette() = default;
69
70 void resetColors();
71 void retranslateStrings();
72
73 int paletteId() const;
74 int getNumColors() const;
75 bool isHighLight() const;
76 bool isBackground() const;
77 bool isForeground() const;
78
79 QString paletteName() const;
80 void setPaletteName(const QString& name);
81
82 QString paletteText() const;
83 void setPaletteText(const QString& text);
84
85 QColor getColor(const int i) const;
86 void setColor(const int n, const QString& s, const QColor& c);
87 void setColor(const int n, const QColor& c);
88
89 QString getColorName(const int i) const;
90 void setColorName(const int n, const QString& s);
91
92 void saveColors() const;
93 void loadColors();
94
95 bool operator==(const PianoPalette& other) const;
96 bool operator!=(const PianoPalette& other) const;
97
98 static const QString QSTR_PALETTEPREFIX;
99
100 friend QDataStream &operator<<(QDataStream& stream, const PianoPalette& palette);
101 friend QDataStream &operator>>(QDataStream& stream, PianoPalette& palette);
102
103protected:
104 void initialize();
105 void resetPaletteSingle();
106 void resetPaletteDouble();
107 void resetPaletteChannels();
108 void resetPaletteScale();
109 void resetPaletteKeys();
110 void resetPaletteFont();
111 void retranslatePaletteSingle();
112 void retranslatePaletteDouble();
113 void retranslatePaletteChannels();
114 void retranslatePaletteScale();
115 void retranslatePaletteKeys();
116 void retranslatePaletteFont();
117
118 int m_paletteId;
119 QList<QColor> m_colors;
120 QList<QString> m_names;
121 QString m_paletteName;
122 QString m_paletteText;
123};
124
127}} // namespace drumstick::widgets
128
129#endif // PIANOPALETTE_H
The PianoPalette class.
Definition: pianopalette.h:61
static const QString QSTR_PALETTEPREFIX
PianoPalette::QSTR_PALETTEPREFIX is the string prefix for all the settings stored as persisting setti...
Definition: pianopalette.h:98
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_HISCALE
Highlighting colors for each chromatic scale note.
Definition: pianopalette.h:52
@ 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.
QDataStream & operator>>(QDataStream &stream, PianoPalette &palette)
Deserialize a PianoPalette instance from a QDataStream.
QDataStream & operator<<(QDataStream &stream, const PianoPalette &palette)
Serialize a PianoPalette instance into a QDataStream.
Drumstick common.
Definition: alsaclient.cpp:68