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 );
108 void paintEvent( QPaintEvent *event )
override;
109 void mouseMoveEvent( QMouseEvent *event )
override;
110 void mousePressEvent( QMouseEvent *event )
override;
111 void mouseReleaseEvent( QMouseEvent *event )
override;
112 void keyPressEvent( QKeyEvent *event )
override;
113 void focusInEvent( QFocusEvent *event )
override;
114 void focusOutEvent( QFocusEvent *event )
override;
122 bool mDrawBoxDepressed;
123 int mCurrentHoverBox;
126 int mCurrentFocusBox;
130 int mLabelHeight = 0;
132 int mLabelMargin = 0;
137 int mSwatchOutlineSize = 0;
140 int mSwatchMargin = 0;
143 int mSwatchSpacing = 0;
145 bool mPressedOnWidget;
151 int calculateHeight()
const;
157 void draw( QPainter &painter );
164 int swatchForPosition( QPoint position )
const;
170 void updateTooltip(
int colorIdx );
176 QPixmap transparentBackground();
209 void setBaseColor(
const QColor &baseColor );
216 QColor baseColor()
const;
223 QString context()
const;
230 void setContext(
const QString &context );
254 void refreshColors();
265 QMenu *mMenu =
nullptr;
269 bool mSuppressRecurse;
270 bool mDismissOnColorSelection;
277 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.