All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Slots | Signals | Public Member Functions
QGpGuiTools::ColorButton Class Reference

A pushbutton to select a color. More...

#include <ColorButton.h>

List of all members.

Public Slots

void setColor ()
void setColor (const QColor &c)

Signals

void colorChanged (QColor c)

Public Member Functions

QColor color ()
 ColorButton (QWidget *parent=0)
void disconnect ()
 ~ColorButton ()

Detailed Description

A pushbutton to select a color.

By default a click displays a QColorDialog. Whenever the color is changed, signal colorChanged() is emited. If exec() exits with Rejected, the original color is restored by emitting signal with the original color.


Constructor & Destructor Documentation

QGpGuiTools::ColorButton::ColorButton ( QWidget *  parent = 0)

Description of constructor still missing

References setColor(), and TRACE.

    : QPushButton(parent)
{
  TRACE;
  setColor(Qt::gray);
  connect(this, SIGNAL(clicked()), this, SLOT(setColor()));
}

References TRACE.

{
  TRACE;
}

Member Function Documentation

QColor QGpGuiTools::ColorButton::color ( ) [inline]

Referenced by setColor(), and SciFigs::PaletteTable::setColorCount().

{return _color;}
void QGpGuiTools::ColorButton::colorChanged ( QColor  c) [signal]

Referenced by setColor().

References setColor(), and TRACE.

{
  TRACE;
  QPushButton::disconnect(this, SIGNAL(clicked()), this, SLOT(setColor()));
}

Creates a QColorDialog that may delete this object (observed for a delegate in a QTableView). If using a ColorButton in a delegate, call disconnect() after creation and re-implement setColor().

References color(), colorChanged(), and TRACE.

Referenced by ColorButton(), disconnect(), and SciFigs::PaletteTable::setColorCount().

{
  TRACE;
  QColorDialog * d=new QColorDialog(qApp->activeWindow());
  QColor originalColor=color();
  d->setCurrentColor(originalColor);
  connect(d, SIGNAL(currentColorChanged(QColor)), this, SLOT(setColor(const QColor&)));
  connect(d, SIGNAL(currentColorChanged(QColor)), this, SIGNAL(colorChanged(QColor)));
  if(d->exec()!=QDialog::Accepted) {
    setColor(originalColor);
    emit colorChanged(originalColor);
  }
  delete d;
}
void QGpGuiTools::ColorButton::setColor ( const QColor &  c) [slot]

References TRACE.

{
  TRACE;
  _color=c;
  QPixmap pm(iconSize());
  QPainter p;
  p.begin(&pm);
  p.fillRect(0, 0, iconSize().width(), iconSize().height(), _color);
  p.end();
  setIcon(pm);
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines