15 #ifndef QGSCOLORBUTTON_H 16 #define QGSCOLORBUTTON_H 18 #include <QColorDialog> 19 #include <QToolButton> 40 if ( qobject_cast<QgsColorButton *>( sipCpp ) )
41 sipType = sipType_QgsColorButton;
49 Q_PROPERTY( QString colorDialogTitle READ colorDialogTitle WRITE setColorDialogTitle )
50 Q_PROPERTY( QColor color READ color WRITE setColor )
51 Q_PROPERTY(
bool allowOpacity READ allowOpacity WRITE setAllowOpacity )
52 Q_PROPERTY(
bool showMenu READ showMenu WRITE setShowMenu )
53 Q_PROPERTY(
Behavior behavior READ behavior WRITE setBehavior )
54 Q_PROPERTY( QColor defaultColor READ defaultColor WRITE setDefaultColor )
55 Q_PROPERTY(
bool showNoColor READ showNoColor WRITE setShowNoColor )
56 Q_PROPERTY( QString noColorString READ noColorString WRITE setNoColorString )
57 Q_PROPERTY( QString context READ context WRITE setContext )
80 QSize minimumSizeHint() const override;
81 QSize sizeHint() const override;
97 void setAllowOpacity(
bool allowOpacity );
106 bool allowOpacity()
const {
return mAllowOpacity; }
113 void setColorDialogTitle(
const QString &title );
120 QString colorDialogTitle()
const;
128 void setShowMenu(
bool showMenu );
135 bool showMenu()
const {
return menu() ?
true :
false; }
143 void setBehavior(
Behavior behavior );
159 void setDefaultColor(
const QColor &color );
179 void setShowNoColor(
const bool showNoColorOption ) { mShowNoColorOption = showNoColorOption; }
209 void setShowNull(
bool showNull );
217 bool showNull()
const;
244 void setContext(
const QString &context ) { mContext = context; }
281 void setColor(
const QColor &color );
291 void setButtonBackground(
const QColor &color = QColor() );
309 void activatePicker();
325 void setToDefaultColor();
342 void colorChanged(
const QColor &color );
350 void colorClicked(
const QColor &color );
354 bool event( QEvent *e )
override;
355 void changeEvent( QEvent *e )
override;
356 void showEvent( QShowEvent *e )
override;
357 void resizeEvent( QResizeEvent *event )
override;
362 static const QPixmap &transparentBackground();
367 void mousePressEvent( QMouseEvent *e )
override;
372 void mouseMoveEvent( QMouseEvent *e )
override;
377 void mouseReleaseEvent( QMouseEvent *e )
override;
382 void keyPressEvent( QKeyEvent *e )
override;
387 void dragEnterEvent( QDragEnterEvent *e )
override;
392 void dragLeaveEvent( QDragLeaveEvent *e )
override;
397 void dropEvent( QDropEvent *e )
override;
402 QColor sampleColor( QPoint point )
const;
404 static QScreen *findScreenAt( QPoint pos );
406 QString mColorDialogTitle;
412 QColor mDefaultColor;
415 QColor mCurrentColor;
418 bool mAllowOpacity =
false;
419 bool mColorSet =
false;
421 bool mShowNoColorOption =
false;
422 QString mNoColorString;
423 bool mShowNull =
false;
425 QPoint mDragStartPosition;
426 bool mPickingColor =
false;
428 QMenu *mMenu =
nullptr;
440 bool colorFromMimeData(
const QMimeData *mimeData, QColor &resultColor );
448 void stopPicking( QPoint eventPos,
bool samplingColor =
true );
456 QPixmap createMenuIcon(
const QColor &color,
bool showChecks =
true );
460 void buttonClicked();
462 void showColorDialog();
467 void setValidColor(
const QColor &newColor );
473 void setValidTemporaryColor(
const QColor &newColor );
479 void addRecentColor(
const QColor &color );
Registry of color schemes.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)