Code_TYMPAN
4.4.0
Industrial site acoustic simulation
Tympan
gui
widgets
TYToolButton.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3
* This file is part of Code_TYMPAN (R).
4
* Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
* Code_TYMPAN (R) is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
* See the GNU General Public License for more details.
12
* You should have received a copy of the GNU General Public License along
13
* with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
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
= Qt::white;
36
QObject::connect(
this
, &TYToolButton::clicked,
this
, &
TYToolButton::selectColor
);
37
}
38
39
TYToolButton::~TYToolButton
() {}
40
41
void
TYToolButton::selectColor
()
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
58
void
TYToolButton::updateColor
()
59
{
60
setStyleSheet(QString(
"background-color: %1;"
).arg(
_color
.name()));
61
}
c
NxReal c
Definition:
NxVec3.cpp:317
name
const char * name
Definition:
TYRouteWidget.cpp:33
TYToolButton.h
outil IHM pour la gestion de la couleur des ToolButton (fichier header)
TYToolButton::_color
QColor _color
Couleur du bouton.
Definition:
TYToolButton.h:83
TYToolButton::colorAccepted
void colorAccepted(QColor c)
TYToolButton::updateColor
virtual void updateColor()
Definition:
TYToolButton.cpp:58
TYToolButton::~TYToolButton
virtual ~TYToolButton()
Definition:
TYToolButton.cpp:39
TYToolButton::selectColor
virtual void selectColor()
Definition:
TYToolButton.cpp:41
TYToolButton::colorRejected
void colorRejected()
TYToolButton::TYToolButton
TYToolButton(QWidget *parent=0, const char *name=0)
Definition:
TYToolButton.cpp:30
Generated on Thu Feb 19 2026 09:05:52 for Code_TYMPAN by
1.9.1