1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_ColorWidget.h"
21 #include <QApplication>
22 #include <QColorDialog>
24 HYDROGUI_ColorWidget::HYDROGUI_ColorWidget( QWidget* parent )
27 setFrameShape( QFrame::Box );
28 //setFixedSize( 40, 20 );
29 //commented for correct layout management
30 //(otherwise the column with color widget can not be resized
31 //and all free space is arranged on sides
34 HYDROGUI_ColorWidget::~HYDROGUI_ColorWidget()
38 QColor HYDROGUI_ColorWidget::color() const
40 QPalette aPalette = palette();
41 return aPalette.color( QPalette::Window );
44 void HYDROGUI_ColorWidget::setColor( const QColor& c )
46 QPalette aPalette = palette();
47 aPalette.setColor( QPalette::Window, c );
48 setAutoFillBackground( true );
49 setPalette( aPalette );
52 void HYDROGUI_ColorWidget::resetColor()
54 QPalette aDefPalette = QApplication::palette();
55 QColor aColor = aDefPalette.color( QPalette::Window );
59 void HYDROGUI_ColorWidget::mouseDoubleClickEvent( QMouseEvent* )
61 QColor c = QColorDialog::getColor( color(), this );
65 emit colorChanged( c );
69 int HYDROGUI_ColorWidget::intColor() const
71 return HYDROGUI_Tools::color2int( color() );
74 void HYDROGUI_ColorWidget::setColor( const int col )
76 setColor( HYDROGUI_Tools::int2color( col ) );
79 /*void HYDROGUI_ColorWidget::setRandColor()
81 setColor( HYDROGUI_Tools::randColor() );