15#ifndef QGSCOLORSWATCHGRID_H
16#define QGSCOLORSWATCHGRID_H
20#include <QWidgetAction>
45 QSize minimumSizeHint()
const override;
48 QSize sizeHint()
const override;
55 QString
context()
const {
return mContext; }
62 void setContext(
const QString &context );
76 void setBaseColor(
const QColor &baseColor );
106 void paintEvent( QPaintEvent *event )
override;
107 void mouseMoveEvent( QMouseEvent *event )
override;
108 void mousePressEvent( QMouseEvent *event )
override;
109 void mouseReleaseEvent( QMouseEvent *event )
override;
110 void keyPressEvent( QKeyEvent *event )
override;
111 void focusInEvent( QFocusEvent *event )
override;
112 void focusOutEvent( QFocusEvent *event )
override;
120 bool mDrawBoxDepressed;
121 int mCurrentHoverBox;
124 int mCurrentFocusBox;
128 int mLabelHeight = 0;
130 int mLabelMargin = 0;
135 int mSwatchOutlineSize = 0;
138 int mSwatchMargin = 0;
141 int mSwatchSpacing = 0;
143 bool mPressedOnWidget;
149 int calculateHeight()
const;
155 void draw( QPainter &painter );
162 int swatchForPosition( QPoint position )
const;
168 void updateTooltip(
int colorIdx );
174 QPixmap transparentBackground();
206 void setBaseColor(
const QColor &baseColor );
213 QColor baseColor()
const;
220 QString context()
const;
227 void setContext(
const QString &context );
251 void refreshColors();
262 QMenu *mMenu =
nullptr;
266 bool mSuppressRecurse;
267 bool mDismissOnColorSelection;
274 void setColor(
const QColor &color );
Abstract base class for color schemes.
A color swatch grid which can be embedded into a menu.
void setDismissOnColorSelection(bool dismiss)
Sets whether the parent menu should be dismissed and closed when a color is selected from the action'...
void colorChanged(const QColor &color)
Emitted when a color has been selected from the widget.
bool dismissOnColorSelection() const
Returns whether the parent menu will be dismissed after a color is selected from the action's color w...
A grid of color swatches, which allows for user selection.
QColor baseColor() const
Gets the base color for the widget.
QgsNamedColorList * colors()
Gets the list of colors shown in the grid.
void colorChanged(const QColor &color)
Emitted when a color has been selected from the widget.
void hovered()
Emitted when mouse hovers over widget.
QString context() const
Gets the current context for the grid.
QList< QPair< QColor, QString > > QgsNamedColorList
List of colors paired with a friendly display name identifying the color.