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 );
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; }
210 void setShowNull(
bool showNull,
const QString &nullString = QString() );
218 bool showNull()
const;
245 void setContext(
const QString &context ) { mContext = context; }
288 void linkToProjectColor(
const QString &name );
306 static QPixmap createMenuIcon(
const QColor &color,
bool showChecks =
true );
316 void setColor(
const QColor &color );
326 void setButtonBackground(
const QColor &color = QColor() );
344 void activatePicker();
360 void setToDefaultColor();
388 void colorChanged(
const QColor &color );
396 void colorClicked(
const QColor &color );
419 bool event( QEvent *e )
override;
420 void changeEvent( QEvent *e )
override;
421 void showEvent( QShowEvent *e )
override;
422 void resizeEvent( QResizeEvent *event )
override;
427 static const QPixmap &transparentBackground();
432 void mousePressEvent( QMouseEvent *e )
override;
437 void mouseMoveEvent( QMouseEvent *e )
override;
442 void mouseReleaseEvent( QMouseEvent *e )
override;
447 void keyPressEvent( QKeyEvent *e )
override;
452 void dragEnterEvent( QDragEnterEvent *e )
override;
457 void dragLeaveEvent( QDragLeaveEvent *e )
override;
462 void dropEvent( QDropEvent *e )
override;
467 QString mColorDialogTitle;
473 QColor mDefaultColor;
476 QColor mCurrentColor;
479 bool mAllowOpacity =
false;
480 bool mColorSet =
false;
482 bool mShowNoColorOption =
false;
483 QString mNoColorString;
484 bool mShowNull =
false;
485 QString mNullColorString;
487 QPoint mDragStartPosition;
488 bool mPickingColor =
false;
490 QMenu *mMenu =
nullptr;
493 QString mLinkedColorName;
494 bool mShowMenu =
true;
504 bool colorFromMimeData(
const QMimeData *mimeData, QColor &resultColor );
512 void stopPicking( QPoint eventPos,
bool samplingColor =
true );
514 QColor linkedProjectColor()
const;
518 void buttonClicked();
520 void showColorDialog();
525 void setValidColor(
const QColor &newColor );
531 void setValidTemporaryColor(
const QColor &newColor );
537 void addRecentColor(
const QColor &color );