drumstick 2.9.0
C++ MIDI libraries using Qt objects, idioms, and style.
pianopalette.h
Go to the documentation of this file.
1/*
2 MIDI Virtual Piano Keyboard
3 Copyright (C) 2008-2023, 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#if defined(DRUMSTICK_STATIC)
34#define DRUMSTICK_WIDGETS_EXPORT
35#else
36#if defined(drumstick_widgets_EXPORTS)
37#define DRUMSTICK_WIDGETS_EXPORT Q_DECL_EXPORT
38#else
39#define DRUMSTICK_WIDGETS_EXPORT Q_DECL_IMPORT
40#endif
41#endif
42
43namespace drumstick { namespace widgets {
44
62 PAL_HISCALE = 6
63};
64
70class DRUMSTICK_WIDGETS_EXPORT PianoPalette
71{
72 Q_GADGET
73 Q_DECLARE_TR_FUNCTIONS(PianoPalette)
74 Q_ENUM(PalettePolicy)
75
76public:
77 explicit PianoPalette(const int id);
78 virtual ~PianoPalette() = default;
79
80 void resetColors();
81 void retranslateStrings();
82
83 int paletteId() const;
84 int getNumColors() const;
85 bool isHighLight() const;
86 bool isBackground() const;
87 bool isForeground() const;
88
89 QString paletteName() const;
90 void setPaletteName(const QString& name);
91
92 QString paletteText() const;
93 void setPaletteText(const QString& text);
94
95 QColor getColor(const int i) const;
96 void setColor(const int n, const QString& s, const QColor& c);
97 void setColor(const int n, const QColor& c);
98
99 QString getColorName(const int i) const;
100 void setColorName(const int n, const QString& s);
101
102 void saveColors() const;
103 void loadColors();
104
105 bool operator==(const PianoPalette& other) const;
106 bool operator!=(const PianoPalette& other) const;
107
108 static const QString QSTR_PALETTEPREFIX;
109
110 friend QDataStream &operator<<(QDataStream& stream, const PianoPalette& palette);
111 friend QDataStream &operator>>(QDataStream& stream, PianoPalette& palette);
112
113protected:
114 void initialize();
115 void resetPaletteSingle();
116 void resetPaletteDouble();
117 void resetPaletteChannels();
118 void resetPaletteScale();
119 void resetPaletteKeys();
120 void resetPaletteFont();
121 void retranslatePaletteSingle();
122 void retranslatePaletteDouble();
123 void retranslatePaletteChannels();
124 void retranslatePaletteScale();
125 void retranslatePaletteKeys();
126 void retranslatePaletteFont();
127
128 int m_paletteId;
129 QList<QColor> m_colors;
130 QList<QString> m_names;
131 QString m_paletteName;
132 QString m_paletteText;
133};
134
137}} // namespace drumstick::widgets
138
139#endif // PIANOPALETTE_H
The PianoPalette class.
Definition: pianopalette.h:71
static const QString QSTR_PALETTEPREFIX
PianoPalette::QSTR_PALETTEPREFIX is the string prefix for all the settings stored as persisting setti...
Definition: pianopalette.h:108
PalettePolicy
The PalettePolicy enumeration.
Definition: pianopalette.h:55
@ PAL_SCALE
Background colors for each chromatic scale note.
Definition: pianopalette.h:59
@ PAL_SINGLE
Single highlihgting color for all keys.
Definition: pianopalette.h:56
@ PAL_HISCALE
Highlighting colors for each chromatic scale note.
Definition: pianopalette.h:62
@ PAL_CHANNELS
Different highlihgting colors for each channel.
Definition: pianopalette.h:58
@ PAL_KEYS
Two background colors (naturals/alterations)
Definition: pianopalette.h:60
@ PAL_DOUBLE
Two highlihgting colors (naturals/alterations)
Definition: pianopalette.h:57
@ PAL_FONT
Foreground font colors for names.
Definition: pianopalette.h:61
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