Chris@1196
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@1196
|
2
|
Chris@1196
|
3 /*
|
Chris@1196
|
4 Sonic Visualiser
|
Chris@1196
|
5 An audio file viewer and annotation editor.
|
Chris@1196
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@1196
|
7 This file copyright 2007-2016 QMUL.
|
Chris@1196
|
8
|
Chris@1196
|
9 This program is free software; you can redistribute it and/or
|
Chris@1196
|
10 modify it under the terms of the GNU General Public License as
|
Chris@1196
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@1196
|
12 License, or (at your option) any later version. See the file
|
Chris@1196
|
13 COPYING included with this distribution for more information.
|
Chris@1196
|
14 */
|
Chris@1196
|
15
|
Chris@1196
|
16 #ifndef SV_COLOUR_COMBO_BOX_H
|
Chris@1196
|
17 #define SV_COLOUR_COMBO_BOX_H
|
Chris@1196
|
18
|
Chris@1196
|
19 #include "NotifyingComboBox.h"
|
Chris@1196
|
20
|
Chris@1196
|
21 /**
|
Chris@1196
|
22 * Colour-picker combo box with swatches, optionally including "Add
|
Chris@1196
|
23 * New Colour..." entry to invoke a QColorDialog/ColourNameDialog
|
Chris@1196
|
24 */
|
Chris@1196
|
25 class ColourComboBox : public NotifyingComboBox
|
Chris@1196
|
26 {
|
Chris@1196
|
27 Q_OBJECT
|
Chris@1196
|
28
|
Chris@1196
|
29 public:
|
Chris@1196
|
30 ColourComboBox(bool withAddNewColourEntry, QWidget *parent = 0);
|
Chris@1196
|
31
|
Chris@1579
|
32 /**
|
Chris@1579
|
33 * Add an entry at the top of the combo for "no colour selected",
|
Chris@1579
|
34 * with the given label.
|
Chris@1579
|
35 */
|
Chris@1579
|
36 void includeUnsetEntry(QString label);
|
Chris@1579
|
37
|
Chris@1579
|
38 /**
|
Chris@1579
|
39 * Get the current colour index. This is the same as
|
Chris@1579
|
40 * QComboBox::currentIndex() if there is no unset entry, or 1 less
|
Chris@1579
|
41 * than it if includeUnsetEntry() has been used. So if there is an
|
Chris@1579
|
42 * unset entry, and it is selected, this returns -1.
|
Chris@1579
|
43 */
|
Chris@1579
|
44 int getCurrentColourIndex() const {
|
Chris@1579
|
45 int index = currentIndex();
|
Chris@1579
|
46 if (m_unsetEntry == "") {
|
Chris@1579
|
47 return index;
|
Chris@1579
|
48 } else {
|
Chris@1579
|
49 return index - 1;
|
Chris@1579
|
50 }
|
Chris@1579
|
51 }
|
Chris@1579
|
52
|
Chris@1196
|
53 signals:
|
Chris@1579
|
54 /**
|
Chris@1579
|
55 * Emitted when the current index is changed. The argument is the
|
Chris@1579
|
56 * value returned by getCurrentColourIndex()
|
Chris@1579
|
57 */
|
Chris@1196
|
58 void colourChanged(int colourIndex);
|
Chris@1196
|
59
|
Chris@1196
|
60 private slots:
|
Chris@1196
|
61 void rebuild();
|
Chris@1196
|
62 void comboActivated(int);
|
Chris@1196
|
63
|
Chris@1196
|
64 private:
|
Chris@1196
|
65 bool m_withAddNewColourEntry;
|
Chris@1579
|
66 QString m_unsetEntry;
|
Chris@1196
|
67 };
|
Chris@1196
|
68
|
Chris@1196
|
69 #endif
|
Chris@1196
|
70
|