QGIS API Documentation  3.2.0-Bonn (bc43194)
Public Slots | Signals | Public Member Functions | Protected Member Functions | List of all members
QgsColorSchemeList Class Reference

An editable list of color swatches, taken from an associated QgsColorScheme. More...

#include <qgscolorschemelist.h>

Inheritance diagram for QgsColorSchemeList:
Inheritance graph
[legend]

Public Slots

void addColor (const QColor &color, const QString &label=QString(), bool allowDuplicate=false)
 Adds a color to the list. More...
 
void copyColors ()
 Copies colors from the list to the clipboard. More...
 
void pasteColors ()
 Pastes colors from clipboard to the list. More...
 
void removeSelection ()
 Removes any selected colors from the list. More...
 
void setScheme (QgsColorScheme *scheme, const QString &context=QString(), const QColor &baseColor=QColor())
 Sets the color scheme to show in the list. More...
 
void showExportColorsDialog ()
 Displays a file picker dialog allowing users to export colors from the list into a file. More...
 
void showImportColorsDialog ()
 Displays a file picker dialog allowing users to import colors into the list from a file. More...
 

Signals

void colorSelected (const QColor &color)
 Emitted when a color is selected from the list. More...
 

Public Member Functions

 QgsColorSchemeList (QWidget *parent=nullptr, QgsColorScheme *scheme=nullptr, const QString &context=QString(), const QColor &baseColor=QColor())
 Construct a new color swatch grid. More...
 
bool exportColorsToGpl (QFile &file)
 Export colors to a GPL palette file from the list. More...
 
bool importColorsFromGpl (QFile &file)
 Import colors from a GPL palette file to the list. More...
 
bool isDirty () const
 Returns whether the color scheme list has been modified. More...
 
bool saveColorsToScheme ()
 Saves the current colors shown in the list back to a color scheme, if supported by the color scheme. More...
 
QgsColorSchemescheme ()
 Returns the scheme currently selected in the list. More...
 

Protected Member Functions

void keyPressEvent (QKeyEvent *event) override
 
void mousePressEvent (QMouseEvent *event) override
 
void mouseReleaseEvent (QMouseEvent *event) override
 

Detailed Description

An editable list of color swatches, taken from an associated QgsColorScheme.

See also
QgsColorSchemeList
Since
QGIS 2.5

Definition at line 163 of file qgscolorschemelist.h.

Constructor & Destructor Documentation

◆ QgsColorSchemeList()

QgsColorSchemeList::QgsColorSchemeList ( QWidget *  parent = nullptr,
QgsColorScheme scheme = nullptr,
const QString &  context = QString(),
const QColor &  baseColor = QColor() 
)

Construct a new color swatch grid.

Parameters
parentparent widget
schemeQgsColorScheme for colors to show in the list
contextcontext string provided to color scheme
baseColorbase color for color scheme

Definition at line 35 of file qgscolorschemelist.cpp.

Member Function Documentation

◆ addColor

void QgsColorSchemeList::addColor ( const QColor &  color,
const QString &  label = QString(),
bool  allowDuplicate = false 
)
slot

Adds a color to the list.

Parameters
colorcolor to add
labeloptional label for color
allowDuplicateset to true to allow duplicate colors to be added, ie colors which already exist in the list

Definition at line 93 of file qgscolorschemelist.cpp.

◆ colorSelected

void QgsColorSchemeList::colorSelected ( const QColor &  color)
signal

Emitted when a color is selected from the list.

Parameters
colorcolor selected

◆ copyColors

void QgsColorSchemeList::copyColors ( )
slot

Copies colors from the list to the clipboard.

See also
pasteColors

Definition at line 116 of file qgscolorschemelist.cpp.

◆ exportColorsToGpl()

bool QgsColorSchemeList::exportColorsToGpl ( QFile &  file)

Export colors to a GPL palette file from the list.

Parameters
filedestination file
See also
importColorsFromGpl

Definition at line 276 of file qgscolorschemelist.cpp.

◆ importColorsFromGpl()

bool QgsColorSchemeList::importColorsFromGpl ( QFile &  file)

Import colors from a GPL palette file to the list.

Parameters
filefile to import
See also
exportColorsToGpl

Definition at line 249 of file qgscolorschemelist.cpp.

◆ isDirty()

bool QgsColorSchemeList::isDirty ( ) const

Returns whether the color scheme list has been modified.

Returns
true if colors have been modified

Definition at line 281 of file qgscolorschemelist.cpp.

◆ keyPressEvent()

void QgsColorSchemeList::keyPressEvent ( QKeyEvent *  event)
overrideprotected

Definition at line 195 of file qgscolorschemelist.cpp.

◆ mousePressEvent()

void QgsColorSchemeList::mousePressEvent ( QMouseEvent *  event)
overrideprotected

Definition at line 220 of file qgscolorschemelist.cpp.

◆ mouseReleaseEvent()

void QgsColorSchemeList::mouseReleaseEvent ( QMouseEvent *  event)
overrideprotected

Definition at line 230 of file qgscolorschemelist.cpp.

◆ pasteColors

void QgsColorSchemeList::pasteColors ( )
slot

Pastes colors from clipboard to the list.

See also
copyColors

Definition at line 98 of file qgscolorschemelist.cpp.

◆ removeSelection

void QgsColorSchemeList::removeSelection ( )
slot

Removes any selected colors from the list.

Definition at line 75 of file qgscolorschemelist.cpp.

◆ saveColorsToScheme()

bool QgsColorSchemeList::saveColorsToScheme ( )

Saves the current colors shown in the list back to a color scheme, if supported by the color scheme.

Note
this method is only effective if the color scheme is editable

Definition at line 64 of file qgscolorschemelist.cpp.

◆ scheme()

QgsColorScheme * QgsColorSchemeList::scheme ( )

Returns the scheme currently selected in the list.

See also
setScheme()
Since
QGIS 3.0

Definition at line 291 of file qgscolorschemelist.cpp.

◆ setScheme

void QgsColorSchemeList::setScheme ( QgsColorScheme scheme,
const QString &  context = QString(),
const QColor &  baseColor = QColor() 
)
slot

Sets the color scheme to show in the list.

Parameters
schemeQgsColorScheme for colors to show in the list
contextcontext string provided to color scheme
baseColorbase color for color scheme
See also
scheme()

Definition at line 58 of file qgscolorschemelist.cpp.

◆ showExportColorsDialog

void QgsColorSchemeList::showExportColorsDialog ( )
slot

Displays a file picker dialog allowing users to export colors from the list into a file.

See also
showImportColorsDialog()
Since
QGIS 3.0

Definition at line 166 of file qgscolorschemelist.cpp.

◆ showImportColorsDialog

void QgsColorSchemeList::showImportColorsDialog ( )
slot

Displays a file picker dialog allowing users to import colors into the list from a file.

See also
showExportColorsDialog()
Since
QGIS 3.0

Definition at line 137 of file qgscolorschemelist.cpp.


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