Classes | Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
color_widgets::ColorPalette Class Reference

#include <color_palette.hpp>

Inheritance diagram for color_widgets::ColorPalette:
Inheritance graph
[legend]

Classes

class  Private
 

Public Types

typedef QPair< QColor, QString > value_type
 

Public Slots

void appendColor (const QColor &color, const QString &name=QString())
 Append a color at the end. More...
 
void eraseColor (int index)
 Remove the color at the given index. More...
 
void insertColor (int index, const QColor &color, const QString &name=QString())
 Insert a color in an arbitrary location. More...
 
bool save (const QString &filename)
 Change file name and save. More...
 
bool save ()
 save to file, the filename is fileName or determined automatically More...
 
void setColorAt (int index, const QColor &color)
 Change the color at the given index. More...
 
void setColorAt (int index, const QColor &color, const QString &name)
 Change the color at the given index. More...
 
void setColors (const QVector< QColor > &colors)
 
void setColors (const QVector< QPair< QColor, QString > > &colors)
 
void setColumns (int columns)
 
void setDirty (bool dirty)
 
void setFileName (const QString &name)
 
void setName (const QString &name)
 
void setNameAt (int index, const QString &name=QString())
 Change the name of a color. More...
 

Signals

void colorAdded (int index)
 Emitted when a single color has been added. More...
 
void colorChanged (int index)
 Emitted when the color or the name at the given index has been modified. More...
 
void colorRemoved (int index)
 Emitted when the color at the given index has been removed. More...
 
void colorsChanged (const QVector< QPair< QColor, QString > > &)
 Emitted when all the colors have changed. More...
 
void colorsUpdated (const QVector< QPair< QColor, QString >> &)
 Emitted when the colors have been modified with a simple operation (set, append etc.) More...
 
void columnsChanged (int)
 
void dirtyChanged (bool)
 
void fileNameChanged (const QString &)
 
void nameChanged (const QString &)
 

Public Member Functions

Q_INVOKABLE QColor colorAt (int index) const
 Color at the given index. More...
 
 ColorPalette (const QVector< QColor > &colors, const QString &name=QString(), int columns=0)
 
 ColorPalette (const QVector< QPair< QColor, QString > > &colors, const QString &name=QString(), int columns=0)
 
 ColorPalette (const QString &name=QString())
 
 ColorPalette (const ColorPalette &other)
 
 ColorPalette (ColorPalette &&other)
 
QVector< QPair< QColor, QString > > colors () const
 
Q_INVOKABLE QVector< QRgb > colorTable () const
 Convert to a color table. More...
 
int columns ()
 
int count () const
 
bool dirty () const
 
QString fileName () const
 
Q_INVOKABLE bool load (const QString &name)
 Load contents from a Gimp palette (gpl) file. More...
 
Q_INVOKABLE void loadColorTable (const QVector< QRgb > &color_table)
 Use a color table to set the colors. More...
 
Q_INVOKABLE bool loadImage (const QImage &image)
 Use the pixels on an image to set the palette colors. More...
 
QString name () const
 
Q_INVOKABLE QString nameAt (int index) const
 Color name at the given index. More...
 
QVector< QColor > onlyColors () const
 
ColorPaletteoperator= (const ColorPalette &other)
 
ColorPaletteoperator= (ColorPalette &&other)
 
QPixmap preview (const QSize &size, const QColor &background=Qt::transparent) const
 Returns a preview image of the colors in the palette. More...
 
 ~ColorPalette ()
 

Static Public Member Functions

static ColorPalette fromColorTable (const QVector< QRgb > &table)
 Creates a ColorPalette from a color table. More...
 
static ColorPalette fromFile (const QString &name)
 Creates a ColorPalette from a Gimp palette (gpl) file. More...
 
static ColorPalette fromImage (const QImage &image)
 Creates a ColorPalette from a Gimp palette (gpl) file. More...
 

Properties

QVector< value_typecolors
 The list of colors. More...
 
int columns
 Number of colors to display in a row, if 0 unspecified. More...
 
int count
 Number of colors. More...
 
bool dirty
 Whether it has been modified and it might be advisable to save it. More...
 
QString fileName
 Name of the file the palette has been read from. More...
 
QString name
 Name of the palette. More...
 

Private Member Functions

void emitUpdate ()
 Emit all the necessary signals when the palette has been completely overwritten. More...
 
QString unnamed (const QString &name=QString()) const
 Returns name if it isn't null, otherwise a default value. More...
 

Private Attributes

Privatep
 

Detailed Description

Definition at line 34 of file color_palette.hpp.

Member Typedef Documentation

typedef QPair<QColor,QString> color_widgets::ColorPalette::value_type

Definition at line 64 of file color_palette.hpp.

Constructor & Destructor Documentation

color_widgets::ColorPalette::ColorPalette ( const QVector< QColor > &  colors,
const QString &  name = QString(),
int  columns = 0 
)

Definition at line 47 of file color_palette.cpp.

color_widgets::ColorPalette::ColorPalette ( const QVector< QPair< QColor, QString > > &  colors,
const QString &  name = QString(),
int  columns = 0 
)

Definition at line 65 of file color_palette.cpp.

color_widgets::ColorPalette::ColorPalette ( const QString &  name = QString())
explicit

Definition at line 57 of file color_palette.cpp.

color_widgets::ColorPalette::ColorPalette ( const ColorPalette other)

Definition at line 75 of file color_palette.cpp.

color_widgets::ColorPalette::~ColorPalette ( )

Definition at line 87 of file color_palette.cpp.

color_widgets::ColorPalette::ColorPalette ( ColorPalette &&  other)

Definition at line 92 of file color_palette.cpp.

Member Function Documentation

void color_widgets::ColorPalette::appendColor ( const QColor &  color,
const QString &  name = QString() 
)
slot

Append a color at the end.

Definition at line 382 of file color_palette.cpp.

void color_widgets::ColorPalette::colorAdded ( int  index)
signal

Emitted when a single color has been added.

QColor color_widgets::ColorPalette::colorAt ( int  index) const

Color at the given index.

Definition at line 113 of file color_palette.cpp.

void color_widgets::ColorPalette::colorChanged ( int  index)
signal

Emitted when the color or the name at the given index has been modified.

void color_widgets::ColorPalette::colorRemoved ( int  index)
signal

Emitted when the color at the given index has been removed.

QVector<QPair<QColor,QString> > color_widgets::ColorPalette::colors ( ) const
void color_widgets::ColorPalette::colorsChanged ( const QVector< QPair< QColor, QString > > &  )
signal

Emitted when all the colors have changed.

void color_widgets::ColorPalette::colorsUpdated ( const QVector< QPair< QColor, QString >> &  )
signal

Emitted when the colors have been modified with a simple operation (set, append etc.)

QVector< QRgb > color_widgets::ColorPalette::colorTable ( ) const

Convert to a color table.

Definition at line 482 of file color_palette.cpp.

int color_widgets::ColorPalette::columns ( )
void color_widgets::ColorPalette::columnsChanged ( int  )
signal
int color_widgets::ColorPalette::count ( ) const
bool color_widgets::ColorPalette::dirty ( ) const
void color_widgets::ColorPalette::dirtyChanged ( bool  )
signal
void color_widgets::ColorPalette::emitUpdate ( )
private

Emit all the necessary signals when the palette has been completely overwritten.

Definition at line 104 of file color_palette.cpp.

void color_widgets::ColorPalette::eraseColor ( int  index)
slot

Remove the color at the given index.

Definition at line 402 of file color_palette.cpp.

QString color_widgets::ColorPalette::fileName ( ) const
void color_widgets::ColorPalette::fileNameChanged ( const QString &  )
signal
ColorPalette color_widgets::ColorPalette::fromColorTable ( const QVector< QRgb > &  table)
static

Creates a ColorPalette from a color table.

Definition at line 491 of file color_palette.cpp.

ColorPalette color_widgets::ColorPalette::fromFile ( const QString &  name)
static

Creates a ColorPalette from a Gimp palette (gpl) file.

Definition at line 258 of file color_palette.cpp.

ColorPalette color_widgets::ColorPalette::fromImage ( const QImage &  image)
static

Creates a ColorPalette from a Gimp palette (gpl) file.

Definition at line 179 of file color_palette.cpp.

void color_widgets::ColorPalette::insertColor ( int  index,
const QColor &  color,
const QString &  name = QString() 
)
slot

Insert a color in an arbitrary location.

Definition at line 390 of file color_palette.cpp.

bool color_widgets::ColorPalette::load ( const QString &  name)

Load contents from a Gimp palette (gpl) file.

Returns
true On Success
Note
If this function returns false, the palette will become empty
Todo:
Store extra properties in the palette object

Definition at line 186 of file color_palette.cpp.

void color_widgets::ColorPalette::loadColorTable ( const QVector< QRgb > &  color_table)

Use a color table to set the colors.

Definition at line 143 of file color_palette.cpp.

bool color_widgets::ColorPalette::loadImage ( const QImage &  image)

Use the pixels on an image to set the palette colors.

Definition at line 157 of file color_palette.cpp.

QString color_widgets::ColorPalette::name ( ) const
QString color_widgets::ColorPalette::nameAt ( int  index) const

Color name at the given index.

Definition at line 118 of file color_palette.cpp.

void color_widgets::ColorPalette::nameChanged ( const QString &  )
signal
QVector< QColor > color_widgets::ColorPalette::onlyColors ( ) const

Definition at line 473 of file color_palette.cpp.

ColorPalette & color_widgets::ColorPalette::operator= ( const ColorPalette other)

Definition at line 80 of file color_palette.cpp.

ColorPalette & color_widgets::ColorPalette::operator= ( ColorPalette &&  other)

Definition at line 97 of file color_palette.cpp.

QPixmap color_widgets::ColorPalette::preview ( const QSize &  size,
const QColor &  background = Qt::transparent 
) const

Returns a preview image of the colors in the palette.

Definition at line 432 of file color_palette.cpp.

bool color_widgets::ColorPalette::save ( const QString &  filename)
slot

Change file name and save.

Returns
true on success

Definition at line 265 of file color_palette.cpp.

bool color_widgets::ColorPalette::save ( )
slot

save to file, the filename is fileName or determined automatically

Returns
true on success
Todo:
Options to add comments

Definition at line 271 of file color_palette.cpp.

void color_widgets::ColorPalette::setColorAt ( int  index,
const QColor &  color 
)
slot

Change the color at the given index.

Definition at line 345 of file color_palette.cpp.

void color_widgets::ColorPalette::setColorAt ( int  index,
const QColor &  color,
const QString &  name 
)
slot

Change the color at the given index.

Definition at line 357 of file color_palette.cpp.

void color_widgets::ColorPalette::setColors ( const QVector< QColor > &  colors)
slot

Definition at line 328 of file color_palette.cpp.

void color_widgets::ColorPalette::setColors ( const QVector< QPair< QColor, QString > > &  colors)
slot

Definition at line 337 of file color_palette.cpp.

void color_widgets::ColorPalette::setColumns ( int  columns)
slot

Definition at line 316 of file color_palette.cpp.

void color_widgets::ColorPalette::setDirty ( bool  dirty)
slot

Definition at line 467 of file color_palette.cpp.

void color_widgets::ColorPalette::setFileName ( const QString &  name)
slot

Definition at line 420 of file color_palette.cpp.

void color_widgets::ColorPalette::setName ( const QString &  name)
slot

Definition at line 414 of file color_palette.cpp.

void color_widgets::ColorPalette::setNameAt ( int  index,
const QString &  name = QString() 
)
slot

Change the name of a color.

Definition at line 369 of file color_palette.cpp.

QString color_widgets::ColorPalette::unnamed ( const QString &  name = QString()) const
private

Returns name if it isn't null, otherwise a default value.

Definition at line 426 of file color_palette.cpp.

Member Data Documentation

Private* color_widgets::ColorPalette::p
private

Definition at line 222 of file color_palette.hpp.

Property Documentation

QVector< QPair< QColor, QString > > color_widgets::ColorPalette::colors
readwrite

The list of colors.

Definition at line 41 of file color_palette.hpp.

int color_widgets::ColorPalette::columns
readwrite

Number of colors to display in a row, if 0 unspecified.

Definition at line 49 of file color_palette.hpp.

int color_widgets::ColorPalette::count
read

Number of colors.

Definition at line 53 of file color_palette.hpp.

bool color_widgets::ColorPalette::dirty
readwrite

Whether it has been modified and it might be advisable to save it.

Definition at line 61 of file color_palette.hpp.

QString color_widgets::ColorPalette::fileName
readwrite

Name of the file the palette has been read from.

Definition at line 57 of file color_palette.hpp.

QString color_widgets::ColorPalette::name
readwrite

Name of the palette.

Definition at line 45 of file color_palette.hpp.


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


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:19