comparison widgets/ColourComboBox.h @ 1580:a2ff9c01889e

Merge from branch background-mode
author Chris Cannam
date Fri, 24 Jan 2020 15:11:08 +0000
parents 85f04c956f03
children
comparison
equal deleted inserted replaced
1572:5f6fdd525158 1580:a2ff9c01889e
27 Q_OBJECT 27 Q_OBJECT
28 28
29 public: 29 public:
30 ColourComboBox(bool withAddNewColourEntry, QWidget *parent = 0); 30 ColourComboBox(bool withAddNewColourEntry, QWidget *parent = 0);
31 31
32 /**
33 * Add an entry at the top of the combo for "no colour selected",
34 * with the given label.
35 */
36 void includeUnsetEntry(QString label);
37
38 /**
39 * Get the current colour index. This is the same as
40 * QComboBox::currentIndex() if there is no unset entry, or 1 less
41 * than it if includeUnsetEntry() has been used. So if there is an
42 * unset entry, and it is selected, this returns -1.
43 */
44 int getCurrentColourIndex() const {
45 int index = currentIndex();
46 if (m_unsetEntry == "") {
47 return index;
48 } else {
49 return index - 1;
50 }
51 }
52
32 signals: 53 signals:
54 /**
55 * Emitted when the current index is changed. The argument is the
56 * value returned by getCurrentColourIndex()
57 */
33 void colourChanged(int colourIndex); 58 void colourChanged(int colourIndex);
34 59
35 private slots: 60 private slots:
36 void rebuild(); 61 void rebuild();
37 void comboActivated(int); 62 void comboActivated(int);
38 63
39 private: 64 private:
40 bool m_withAddNewColourEntry; 65 bool m_withAddNewColourEntry;
66 QString m_unsetEntry;
41 }; 67 };
42 68
43 #endif 69 #endif
44 70