Colour-picker combo box with swatches, optionally including "Add New Colour..." entry to invoke a QColorDialog/ColourNameDialog. More...

#include <ColourComboBox.h>

Inheritance diagram for ColourComboBox:
Inheritance graph
Collaboration diagram for ColourComboBox:
Collaboration graph

Signals

void colourChanged (int colourIndex)
 Emitted when the current index is changed. More...
 
void mouseEntered ()
 
void mouseLeft ()
 

Public Member Functions

 ColourComboBox (bool withAddNewColourEntry, QWidget *parent=0)
 
void includeUnsetEntry (QString label)
 Add an entry at the top of the combo for "no colour selected", with the given label. More...
 
int getCurrentColourIndex () const
 Get the current colour index. More...
 

Protected Member Functions

void enterEvent (QEvent *) override
 
void leaveEvent (QEvent *) override
 

Private Slots

void rebuild ()
 
void comboActivated (int)
 

Private Attributes

bool m_withAddNewColourEntry
 
QString m_unsetEntry
 

Detailed Description

Colour-picker combo box with swatches, optionally including "Add New Colour..." entry to invoke a QColorDialog/ColourNameDialog.

Definition at line 25 of file ColourComboBox.h.

Constructor & Destructor Documentation

ColourComboBox::ColourComboBox ( bool  withAddNewColourEntry,
QWidget *  parent = 0 
)

Definition at line 31 of file ColourComboBox.cpp.

References comboActivated(), ColourDatabase::getInstance(), and rebuild().

Member Function Documentation

void ColourComboBox::includeUnsetEntry ( QString  label)

Add an entry at the top of the combo for "no colour selected", with the given label.

Definition at line 44 of file ColourComboBox.cpp.

References m_unsetEntry, and rebuild().

int ColourComboBox::getCurrentColourIndex ( ) const
inline

Get the current colour index.

This is the same as QComboBox::currentIndex() if there is no unset entry, or 1 less than it if includeUnsetEntry() has been used. So if there is an unset entry, and it is selected, this returns -1.

Definition at line 44 of file ColourComboBox.h.

References colourChanged(), comboActivated(), m_unsetEntry, and rebuild().

void ColourComboBox::colourChanged ( int  colourIndex)
signal

Emitted when the current index is changed.

The argument is the value returned by getCurrentColourIndex()

Referenced by comboActivated(), and getCurrentColourIndex().

void NotifyingComboBox::mouseEntered ( )
signalinherited
void NotifyingComboBox::mouseLeft ( )
signalinherited
void NotifyingComboBox::enterEvent ( QEvent *  e)
overrideprotectedinherited
void NotifyingComboBox::leaveEvent ( QEvent *  e)
overrideprotectedinherited

Member Data Documentation

bool ColourComboBox::m_withAddNewColourEntry
private

Definition at line 65 of file ColourComboBox.h.

Referenced by comboActivated(), and rebuild().

QString ColourComboBox::m_unsetEntry
private

Definition at line 66 of file ColourComboBox.h.

Referenced by comboActivated(), getCurrentColourIndex(), includeUnsetEntry(), and rebuild().


The documentation for this class was generated from the following files: