ATLAS Offline Software
Loading...
Searching...
No Matches
VP1ColorSelectButton Class Reference

#include <VP1ColorSelectButton.h>

Inheritance diagram for VP1ColorSelectButton:
Collaboration diagram for VP1ColorSelectButton:

Classes

class  Imp

Public Slots

void launchColorChooser ()
void setColor (const QColor &)
void setDimension (int dim)

Signals

void colorChanged (const QColor &)
void aboutToShowColorDialog ()

Public Member Functions

 VP1ColorSelectButton (QWidget *parent=0, const QColor &initialcolor=Qt::black, int dim=24)
virtual ~VP1ColorSelectButton ()
QColor color () const
void setText (const QString &)

Static Public Member Functions

static void setColButtonProperties (QPushButton *, const QColor &col, int dim)

Protected Slots

void updateButton ()

Private Attributes

Impm_d

Detailed Description

Definition at line 20 of file VP1ColorSelectButton.h.

Constructor & Destructor Documentation

◆ VP1ColorSelectButton()

VP1ColorSelectButton::VP1ColorSelectButton ( QWidget * parent = 0,
const QColor & initialcolor = Qt::black,
int dim = 24 )

Definition at line 33 of file VP1ColorSelectButton.cxx.

34 : QPushButton(parent), m_d(new Imp(initialcolor,this,dim))
35{
36 connect (this,SIGNAL(clicked()),this,SLOT(launchColorChooser()));
37 QTimer::singleShot(0, this, SLOT(updateButton()));
38}

◆ ~VP1ColorSelectButton()

VP1ColorSelectButton::~VP1ColorSelectButton ( )
virtual

Definition at line 80 of file VP1ColorSelectButton.cxx.

81{
82 delete m_d; m_d=0;
83}

Member Function Documentation

◆ aboutToShowColorDialog

void VP1ColorSelectButton::aboutToShowColorDialog ( )
signal

◆ color()

QColor VP1ColorSelectButton::color ( ) const

Definition at line 108 of file VP1ColorSelectButton.cxx.

109{
110 return m_d->presentcolor;
111}

◆ colorChanged

void VP1ColorSelectButton::colorChanged ( const QColor & )
signal

◆ launchColorChooser

void VP1ColorSelectButton::launchColorChooser ( )
slot

Definition at line 86 of file VP1ColorSelectButton.cxx.

87{
88 VP1Msg::messageVerbose("VP1ColorSelectButton emitting aboutToShowColorDialog()");
90 QColor color = QColorDialog::getColor(m_d->presentcolor, this);
92}
void setColor(const QColor &)
static void messageVerbose(const QString &)
Definition VP1Msg.cxx:84

◆ setColButtonProperties()

void VP1ColorSelectButton::setColButtonProperties ( QPushButton * pb,
const QColor & col,
int dim )
static

Definition at line 49 of file VP1ColorSelectButton.cxx.

49 {
50
51// if (VP1Msg::verbose())
52// VP1Msg::messageVerbose("setColButtonProperties: button="+VP1Msg::str(pb)+", color="+VP1Msg::str(col));
53
54 if (pb->objectName().isEmpty()) {
55 VP1Msg::messageDebug("VP1ColorSelectButton::setColButtonProperties() WARNING: Empty objectName()!!");
56 pb->setObjectName("VP1ColorSelectButton_setColButtonProperties");
57 }
58
59 if (!pb->text().isEmpty()) {
60 VP1Msg::messageDebug("VP1ColorSelectButton::setColButtonProperties() WARNING: Noticed non-empty text field. Clearing!");
61 pb->QPushButton::setText("");
62 }
63
64 pb->setStyleSheet("QPushButton#"+pb->objectName()+" { background-color: "
65 +col.name()+"; border-color: "+col.name()+"; }");
66 pb->setFocusPolicy(Qt::NoFocus);
67 if (dim>0) {
68 QSize sz = QSize(dim,dim);
69 QSizePolicy sp(QSizePolicy::Fixed, QSizePolicy::Fixed);
70 sp.setHorizontalStretch(0);
71 sp.setVerticalStretch(0);
72 sp.setHeightForWidth(pb->sizePolicy().hasHeightForWidth());
73 pb->setSizePolicy(sp);
74 pb->setMinimumSize(sz);
75 pb->setMaximumSize(sz);
76 }
77}
static Double_t sp
static Double_t sz
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39

◆ setColor

void VP1ColorSelectButton::setColor ( const QColor & col)
slot

Definition at line 95 of file VP1ColorSelectButton.cxx.

96{
97 if (!col.isValid())
98 return;
99 if (m_d->presentcolor==col)
100 return;
101 m_d->presentcolor=col;
102 updateButton();
103 VP1Msg::messageVerbose("VP1ColorSelectButton emitting colorChanged("+col.name()+")");
104 emit colorChanged(col);
105}
void colorChanged(const QColor &)

◆ setDimension

void VP1ColorSelectButton::setDimension ( int dim)
slot

Definition at line 121 of file VP1ColorSelectButton.cxx.

122{
123 if (m_d->dim == dim)
124 return;
125 m_d->dim = dim;
126 updateButton();
127}

◆ setText()

void VP1ColorSelectButton::setText ( const QString & s)

Definition at line 114 of file VP1ColorSelectButton.cxx.

115{
116 if (!s.isEmpty())
117 VP1Msg::messageDebug("VP1ColorSelectButton::setText() called (with '"+s+"'), but not allowed!");
118}

◆ updateButton

void VP1ColorSelectButton::updateButton ( )
protectedslot

Definition at line 41 of file VP1ColorSelectButton.cxx.

42{
43 if (objectName().isEmpty())
44 setObjectName("VP1ColorSelectButton");
45 setColButtonProperties(this,m_d->presentcolor,m_d->dim);
46}
static void setColButtonProperties(QPushButton *, const QColor &col, int dim)

Member Data Documentation

◆ m_d

Imp* VP1ColorSelectButton::m_d
private

Definition at line 45 of file VP1ColorSelectButton.h.


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