Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYToolButton.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program 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.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
23 #include <qcolordialog.h>
24 #include <QPainter>
25 #include <QStyle>
26 #include "TYToolButton.h"
27 
28 using namespace Qt;
29 
30 TYToolButton::TYToolButton(QWidget* parent, const char* name) : QToolButton(parent)
31 {
32  setAutoFillBackground(true);
33  setObjectName(name);
34  setToolButtonStyle(Qt::ToolButtonTextOnly);
35  _color = white;
36  QObject::connect(this, &TYToolButton::clicked, this, &TYToolButton::selectColor);
37 }
38 
40 
42 {
43  QColor c = QColorDialog::getColor(_color);
44 
45  if (c.isValid())
46  {
47  _color = c;
48  updateColor();
49 
50  emit colorAccepted(_color);
51  }
52  else
53  {
54  emit colorRejected();
55  }
56 }
57 
59 {
60  setStyleSheet(QString("background-color: %1;").arg(_color.name()));
61 }
NxReal c
Definition: NxVec3.cpp:317
const char * name
outil IHM pour la gestion de la couleur des ToolButton (fichier header)
QColor _color
Couleur du bouton.
Definition: TYToolButton.h:83
void colorAccepted(QColor c)
virtual void updateColor()
virtual ~TYToolButton()
virtual void selectColor()
void colorRejected()
TYToolButton(QWidget *parent=0, const char *name=0)