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 ()
 save to file, the filename is fileName or determined automatically More...
 
bool save (const QString &filename)
 Change file name and save. 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 (ColorPalette &&other)
 
 ColorPalette (const ColorPalette &other)
 
 ColorPalette (const QString &name=QString())
 
 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)
 
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= (ColorPalette &&other)
 
ColorPaletteoperator= (const 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

◆ value_type

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

Definition at line 64 of file color_palette.hpp.

Constructor & Destructor Documentation

◆ ColorPalette() [1/5]

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

Definition at line 47 of file color_palette.cpp.

◆ ColorPalette() [2/5]

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.

◆ ColorPalette() [3/5]

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

Definition at line 57 of file color_palette.cpp.

◆ ColorPalette() [4/5]

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

Definition at line 75 of file color_palette.cpp.

◆ ~ColorPalette()

color_widgets::ColorPalette::~ColorPalette ( )

Definition at line 87 of file color_palette.cpp.

◆ ColorPalette() [5/5]

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

Definition at line 92 of file color_palette.cpp.

Member Function Documentation

◆ appendColor

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.

◆ colorAdded

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

Emitted when a single color has been added.

◆ colorAt()

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

Color at the given index.

Definition at line 113 of file color_palette.cpp.

◆ colorChanged

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

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

◆ colorRemoved

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

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

◆ colors()

QVector<QPair<QColor,QString> > color_widgets::ColorPalette::colors ( ) const

◆ colorsChanged

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

Emitted when all the colors have changed.

◆ colorsUpdated

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.)

◆ colorTable()

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

Convert to a color table.

Definition at line 482 of file color_palette.cpp.

◆ columns()

int color_widgets::ColorPalette::columns ( )

◆ columnsChanged

void color_widgets::ColorPalette::columnsChanged ( int  )
signal

◆ count()

int color_widgets::ColorPalette::count ( ) const

◆ dirty()

bool color_widgets::ColorPalette::dirty ( ) const

◆ dirtyChanged

void color_widgets::ColorPalette::dirtyChanged ( bool  )
signal

◆ emitUpdate()

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.

◆ eraseColor

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

Remove the color at the given index.

Definition at line 402 of file color_palette.cpp.

◆ fileName()

QString color_widgets::ColorPalette::fileName ( ) const

◆ fileNameChanged

void color_widgets::ColorPalette::fileNameChanged ( const QString &  )
signal

◆ fromColorTable()

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.

◆ fromFile()

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.

◆ fromImage()

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.

◆ insertColor

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.

◆ load()

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.

◆ loadColorTable()

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.

◆ loadImage()

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.

◆ name()

QString color_widgets::ColorPalette::name ( ) const

◆ nameAt()

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

Color name at the given index.

Definition at line 118 of file color_palette.cpp.

◆ nameChanged

void color_widgets::ColorPalette::nameChanged ( const QString &  )
signal

◆ onlyColors()

QVector< QColor > color_widgets::ColorPalette::onlyColors ( ) const

Definition at line 473 of file color_palette.cpp.

◆ operator=() [1/2]

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

Definition at line 97 of file color_palette.cpp.

◆ operator=() [2/2]

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

Definition at line 80 of file color_palette.cpp.

◆ preview()

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.

◆ save [1/2]

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.

◆ save [2/2]

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.

◆ setColorAt [1/2]

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.

◆ setColorAt [2/2]

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.

◆ setColors [1/2]

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

Definition at line 328 of file color_palette.cpp.

◆ setColors [2/2]

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

Definition at line 337 of file color_palette.cpp.

◆ setColumns

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

Definition at line 316 of file color_palette.cpp.

◆ setDirty

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

Definition at line 467 of file color_palette.cpp.

◆ setFileName

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

Definition at line 420 of file color_palette.cpp.

◆ setName

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

Definition at line 414 of file color_palette.cpp.

◆ setNameAt

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.

◆ unnamed()

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

◆ p

Private* color_widgets::ColorPalette::p
private

Definition at line 222 of file color_palette.hpp.

Property Documentation

◆ colors

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

The list of colors.

Definition at line 41 of file color_palette.hpp.

◆ columns

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.

◆ count

int color_widgets::ColorPalette::count
read

Number of colors.

Definition at line 53 of file color_palette.hpp.

◆ dirty

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.

◆ fileName

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.

◆ name

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 Mon Nov 11 2024 03:23:51