15#ifndef QGSCOLORSWATCHGRID_H
16#define QGSCOLORSWATCHGRID_H
20#include <QWidgetAction>
46 QSize minimumSizeHint()
const override;
49 QSize sizeHint()
const override;
56 QString
context()
const {
return mContext; }
63 void setContext(
const QString &context );
77 void setBaseColor(
const QColor &baseColor );
107 void paintEvent( QPaintEvent *event )
override;
108 void mouseMoveEvent( QMouseEvent *event )
override;
109 void mousePressEvent( QMouseEvent *event )
override;
110 void mouseReleaseEvent( QMouseEvent *event )
override;
111 void keyPressEvent( QKeyEvent *event )
override;
112 void focusInEvent( QFocusEvent *event )
override;
113 void focusOutEvent( QFocusEvent *event )
override;
121 bool mDrawBoxDepressed;
122 int mCurrentHoverBox;
125 int mCurrentFocusBox;
129 int mLabelHeight = 0;
131 int mLabelMargin = 0;
136 int mSwatchOutlineSize = 0;
139 int mSwatchMargin = 0;
142 int mSwatchSpacing = 0;
144 bool mPressedOnWidget;
150 int calculateHeight()
const;
156 void draw( QPainter &painter );
163 int swatchForPosition( QPoint position )
const;
169 void updateTooltip(
int colorIdx );
175 QPixmap transparentBackground();
207 void setBaseColor(
const QColor &baseColor );
214 QColor baseColor()
const;
221 QString context()
const;
228 void setContext(
const QString &context );
252 void refreshColors();
263 QMenu *mMenu =
nullptr;
267 bool mSuppressRecurse;
268 bool mDismissOnColorSelection;
275 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.