15 #ifndef QGSCOLORBUTTONV2_H
16 #define QGSCOLORBUTTONV2_H
18 #include <QColorDialog>
19 #include <QToolButton>
20 #include <QTemporaryFile>
37 Q_PROPERTY( QString colorDialogTitle READ colorDialogTitle WRITE setColorDialogTitle )
38 Q_PROPERTY(
bool acceptLiveUpdates READ acceptLiveUpdates WRITE setAcceptLiveUpdates )
39 Q_PROPERTY( QColor color READ color WRITE setColor )
40 Q_PROPERTY(
bool allowAlpha READ allowAlpha WRITE setAllowAlpha )
41 Q_PROPERTY(
bool showMenu READ showMenu WRITE setShowMenu )
42 Q_PROPERTY(
Behaviour behaviour READ behaviour WRITE setBehaviour )
43 Q_PROPERTY( QColor defaultColor READ defaultColor WRITE setDefaultColor )
44 Q_PROPERTY(
bool showNoColor READ showNoColor WRITE setShowNoColor )
45 Q_PROPERTY( QString noColorString READ noColorString WRITE setNoColorString )
46 Q_PROPERTY( QString context READ context WRITE setContext )
68 virtual QSize sizeHint()
const override;
81 void setAllowAlpha(
const bool allowAlpha );
94 void setColorDialogTitle(
const QString title );
100 QString colorDialogTitle()
const;
120 void setShowMenu(
const bool showMenu );
126 bool showMenu()
const {
return menu() ?
true :
false; }
133 void setBehaviour(
const Behaviour behaviour );
147 void setDefaultColor(
const QColor color );
165 void setShowNoColor(
const bool showNoColorOption ) { mShowNoColorOption = showNoColorOption; }
201 void setContext(
const QString context ) { mContext = context; }
234 void setColor(
const QColor &color );
243 void setButtonBackground(
const QColor &color = QColor() );
258 void activatePicker();
270 void setToDefaultColor();
278 void colorChanged(
const QColor &color );
285 void colorClicked(
const QColor &color );
289 void changeEvent( QEvent* e )
override;
290 void showEvent( QShowEvent* e )
override;
291 void resizeEvent( QResizeEvent *event )
override;
295 static const QPixmap& transparentBackground();
300 void mousePressEvent( QMouseEvent* e )
override;
305 void mouseMoveEvent( QMouseEvent *e )
override;
310 void mouseReleaseEvent( QMouseEvent *e )
override;
315 void keyPressEvent( QKeyEvent *e )
override;
320 void dragEnterEvent( QDragEnterEvent * e )
override;
325 void dragLeaveEvent( QDragLeaveEvent *e )
override;
330 void dropEvent( QDropEvent *e )
override;
334 Behaviour mBehaviour;
335 QString mColorDialogTitle;
340 QColor mDefaultColor;
343 bool mAcceptLiveUpdates;
346 bool mShowNoColorOption;
347 QString mNoColorString;
349 QPoint mDragStartPosition;
363 bool colorFromMimeData(
const QMimeData *mimeData, QColor &resultColor );
370 void stopPicking( QPointF eventPos,
bool sampleColor =
true );
377 QPixmap createMenuIcon(
const QColor &color,
const bool showChecks =
true );
381 void buttonClicked();
383 void showColorDialog();
387 void setValidColor(
const QColor& newColor );
392 void addRecentColor(
const QColor& color );