From 251f59939e10a46534a3a9b390ad13f0ea794874 Mon Sep 17 00:00:00 2001 From: san Date: Wed, 11 May 2011 10:53:03 +0000 Subject: [PATCH] Method setColorChooserEnabled() was added. --- src/Qtx/QtxColorButton.cxx | 24 +++++++++++++++++------- src/Qtx/QtxColorButton.h | 4 ++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/Qtx/QtxColorButton.cxx b/src/Qtx/QtxColorButton.cxx index 9b9daec17..d84752b02 100644 --- a/src/Qtx/QtxColorButton.cxx +++ b/src/Qtx/QtxColorButton.cxx @@ -83,14 +83,14 @@ QtxColorButton::QtxColorButton( QWidget* parent ) } } - QToolButton* other = new QToolButton( pm ); - other->setText( tr( "Other colors..." ) ); - other->setAutoRaise( true ); - other->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); - grid->addWidget( other, grid->rowCount(), 0, 1, grid->columnCount() ); - connect( other, SIGNAL( clicked( bool ) ), this, SLOT( onDialogClicked( bool ) ) ); + myOthers = new QToolButton( pm ); + myOthers->setText( tr( "Other colors..." ) ); + myOthers->setAutoRaise( true ); + myOthers->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + grid->addWidget( myOthers, grid->rowCount(), 0, 1, grid->columnCount() ); + connect( myOthers, SIGNAL( clicked( bool ) ), this, SLOT( onDialogClicked( bool ) ) ); - other->installEventFilter( this ); + myOthers->installEventFilter( this ); setMenu( pm ); @@ -144,6 +144,16 @@ bool QtxColorButton::eventFilter( QObject* o, QEvent* e ) return QToolButton::eventFilter( o, e ); } +bool QtxColorButton::isColorChooserEnabled() const +{ + return myOthers->isVisibleTo( myOthers->parentWidget() ); +} + +void QtxColorButton::setColorChooserEnabled( bool on ) +{ + myOthers->setVisible( on ); +} + /*! \brief Called when the popup menu is about to show. diff --git a/src/Qtx/QtxColorButton.h b/src/Qtx/QtxColorButton.h index bb7a37eec..b5733f7a1 100644 --- a/src/Qtx/QtxColorButton.h +++ b/src/Qtx/QtxColorButton.h @@ -44,6 +44,9 @@ public: bool eventFilter( QObject*, QEvent* ); + bool isColorChooserEnabled() const; + void setColorChooserEnabled( bool ); + signals: void clicked( QColor ); void changed( QColor ); @@ -70,6 +73,7 @@ private: private: ColorMap myColors; + QToolButton* myOthers; }; #endif -- 2.39.2