From: stv Date: Tue, 30 Sep 2008 13:01:45 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: V5_1_0a3~31 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d4870612ea417522b65d005b6c70358b9c35e571;p=modules%2Fgui.git *** empty log message *** --- diff --git a/src/Qtx/QtxColorButton.cxx b/src/Qtx/QtxColorButton.cxx index 3fae56101..17975ede1 100644 --- a/src/Qtx/QtxColorButton.cxx +++ b/src/Qtx/QtxColorButton.cxx @@ -1,17 +1,17 @@ // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com @@ -36,7 +36,7 @@ preference items editing. The color preference item is represented as the colored button with - assocoiated popup menu whihc is called when the user presses the small + assocoiated popup menu whihc is called when the user presses the small arrow button near it. The popup menu allows selecting of the color from the predefined set. In addition it contains the button which invokes standard "Select color" dialog box. @@ -73,8 +73,8 @@ QtxColorButton::QtxColorButton( QWidget* parent ) btn->setAutoRaise( true ); btn->setCheckable( true ); myColors.insert( btn, c ); - grid->addWidget( btn, y, x ); - + grid->addWidget( btn, y + 1, x ); + btn->installEventFilter( this ); connect( btn, SIGNAL( clicked( bool ) ), this, SLOT( onToggled( bool ) ) ); @@ -83,6 +83,13 @@ QtxColorButton::QtxColorButton( QWidget* parent ) } } + myAutoButton = new QToolButton( pm ); + myAutoButton->setText( tr( "Auto" ) ); + myAutoButton->setAutoRaise( true ); + myAutoButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + grid->addWidget( myAutoButton, 0, 0, 1, grid->columnCount() ); + connect( myAutoButton, SIGNAL( clicked( bool ) ), this, SLOT( onAutoClicked( bool ) ) ); + QToolButton* other = new QToolButton( pm ); other->setText( tr( "Other colors..." ) ); other->setAutoRaise( true ); @@ -96,6 +103,8 @@ QtxColorButton::QtxColorButton( QWidget* parent ) connect( this, SIGNAL( clicked( bool ) ), this, SLOT( onClicked( bool ) ) ); connect( pm, SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) ); + +// myAutoButton->setVisible( false ); } /*! @@ -131,6 +140,41 @@ void QtxColorButton::setColor( const QColor& c ) updateButton( this ); } +/*! + \brief Returns the status of "auto" color button in popup widget. + \return \c true if the "auto" button is enabled +*/ +bool QtxColorButton::isAutoEnabled() const +{ + return myAutoButton->isVisibleTo( myAutoButton->parentWidget() ); +} + +/*! + \brief Enable/disable the "auto" color button in popup widget. + \param on enable/disable state +*/ +void QtxColorButton::setAutoEnabled( bool on ) +{ + myAutoButton->setVisible( on ); +} + +/*! + \brief Returns text of the "auto" color button in popup widget. +*/ +QString QtxColorButton::autoText() const +{ + return myAutoButton->text(); +} + +/*! + \brief Sets text of the "auto" color button in popup widget. + \param txt new button text +*/ +void QtxColorButton::setAutoText( const QString& txt ) +{ + myAutoButton->setText( txt ); +} + /*! \brief Filter events for the child widgets. \param o event receiver object @@ -140,7 +184,7 @@ void QtxColorButton::setColor( const QColor& c ) bool QtxColorButton::eventFilter( QObject* o, QEvent* e ) { if ( e->type() == QEvent::Leave ) - updateButton( qobject_cast( o ) ); + updateButton( ::qobject_cast( o ) ); return QToolButton::eventFilter( o, e ); } @@ -161,7 +205,7 @@ void QtxColorButton::onAboutToShow() \param on button state (not used) */ -void QtxColorButton::onClicked( bool /*on*/ ) +void QtxColorButton::onClicked( bool ) { emit clicked( color() ); } @@ -198,12 +242,25 @@ void QtxColorButton::onToggled( bool on ) emit changed( color() ); } +/*! + \brief Called the "Auto" child button from popup menu + is clicked. + + Sets the undefined (auto) color as current. + + \param on (not used) +*/ +void QtxColorButton::onAutoClicked( bool ) +{ + setColor( QColor() ); +} + /*! \brief Called the "Other colors" child button from popup menu is clicked. Invokes standard "Select color" dialog box allowing user to select - custom color. If the current color is changed by the user, emits + custom color. If the current color is changed by the user, emits the signal changed( QColor ). \param on (not used) @@ -352,7 +409,7 @@ QList QtxColorButton::colorsList() const /*! \fn void QtxColorButton::clicked( QColor color ); - \brief This signal is emitted when the widget button is clicked by + \brief This signal is emitted when the widget button is clicked by the user. \param color current color */ diff --git a/src/Qtx/QtxColorButton.h b/src/Qtx/QtxColorButton.h index bb7a37eec..c34529807 100644 --- a/src/Qtx/QtxColorButton.h +++ b/src/Qtx/QtxColorButton.h @@ -1,17 +1,17 @@ // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com @@ -44,14 +44,22 @@ public: bool eventFilter( QObject*, QEvent* ); + bool isAutoEnabled() const; + void setAutoEnabled( bool ); + + QString autoText() const; + void setAutoText( const QString& ); + signals: void clicked( QColor ); void changed( QColor ); private slots: - void onAboutToShow(); void onClicked( bool ); void onToggled( bool ); + + void onAboutToShow(); + void onAutoClicked( bool ); void onDialogClicked( bool ); protected: @@ -70,6 +78,7 @@ private: private: ColorMap myColors; + QToolButton* myAutoButton; }; #endif