mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-22 09:40:52 +01:00
Il est desormais possible de choisir la couleur de chaque conducteur.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@755 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -45,7 +45,7 @@ ConductorPropertiesWidget::ConductorPropertiesWidget(const ConductorProperties &
|
||||
/// construit l'interface du widget
|
||||
void ConductorPropertiesWidget::buildInterface() {
|
||||
|
||||
setMinimumSize(380, 280);
|
||||
setMinimumSize(380, 320);
|
||||
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout -> setContentsMargins(0, 0, 0, 0);
|
||||
@@ -93,12 +93,28 @@ void ConductorPropertiesWidget::buildInterface() {
|
||||
singleline_layout1 -> addWidget(preview);
|
||||
singleline_layout1 -> addLayout(singleline_layout2);
|
||||
|
||||
QGroupBox *groupbox2 = new QGroupBox(tr("Apparence du conducteur"));
|
||||
main_layout -> addWidget(groupbox2);
|
||||
|
||||
QVBoxLayout *groupbox2_layout = new QVBoxLayout();
|
||||
groupbox2 -> setLayout(groupbox2_layout);
|
||||
|
||||
QHBoxLayout *color_layout = new QHBoxLayout();
|
||||
QLabel *text1 = new QLabel(tr("Couleur :"));
|
||||
color_button = new QPushButton("");
|
||||
|
||||
color_layout -> addWidget(text1);
|
||||
color_layout -> addWidget(color_button);
|
||||
setColorButton(properties_.color);
|
||||
|
||||
groupbox_layout -> addWidget(simple);
|
||||
groupbox_layout -> addWidget(multiline);
|
||||
groupbox_layout -> addLayout(multiline_layout);
|
||||
groupbox_layout -> addWidget(singleline);
|
||||
groupbox_layout -> addLayout(singleline_layout1);
|
||||
|
||||
groupbox2_layout -> addLayout(color_layout);
|
||||
|
||||
radio_buttons = new QButtonGroup(this);
|
||||
radio_buttons -> addButton(simple, ConductorProperties::Simple);
|
||||
radio_buttons -> addButton(multiline, ConductorProperties::Multi);
|
||||
@@ -118,6 +134,36 @@ void ConductorPropertiesWidget::buildConnections() {
|
||||
connect(phase_slider, SIGNAL(valueChanged(int)), this, SLOT(updateConfig()));
|
||||
connect(radio_buttons, SIGNAL(buttonClicked(int)), this, SLOT(updateConfig()));
|
||||
connect(text_field, SIGNAL(textChanged(const QString &)), this, SLOT(updateConfig()));
|
||||
connect(color_button, SIGNAL(clicked()), this, SLOT(chooseColor()));
|
||||
}
|
||||
|
||||
/**
|
||||
Demande a l'utilisateur de choisir une couleur via un dialogue approprie.
|
||||
*/
|
||||
void ConductorPropertiesWidget::chooseColor() {
|
||||
QColor user_chosen_color = QColorDialog::getColor(properties_.color);
|
||||
if (user_chosen_color.isValid()) {
|
||||
setColorButton(user_chosen_color);
|
||||
updateConfig();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@return la couleur actuelle du bouton permettant de choisir la couleur du
|
||||
conducteur
|
||||
*/
|
||||
QColor ConductorPropertiesWidget::colorButton() const {
|
||||
return(color_button -> palette().color(QPalette::Button));
|
||||
}
|
||||
|
||||
/**
|
||||
Change la couleur du bouton permettant de choisir la couleur du conducteur
|
||||
@param color Nouvelle couleur a afficher
|
||||
*/
|
||||
void ConductorPropertiesWidget::setColorButton(const QColor &color) {
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Button, color);
|
||||
color_button -> setPalette(palette);
|
||||
}
|
||||
|
||||
/// Enleve les connexions signaux/slots
|
||||
@@ -130,6 +176,7 @@ void ConductorPropertiesWidget::destroyConnections() {
|
||||
disconnect(phase_slider, SIGNAL(valueChanged(int)), this, SLOT(updateConfig()));
|
||||
disconnect(radio_buttons, SIGNAL(buttonClicked(int)), this, SLOT(updateConfig()));
|
||||
disconnect(text_field, SIGNAL(textChanged(const QString &)), this, SLOT(updateConfig()));
|
||||
disconnect(color_button, SIGNAL(clicked()), this, SLOT(chooseColor()));
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
@@ -139,6 +186,7 @@ ConductorPropertiesWidget::~ConductorPropertiesWidget() {
|
||||
/// Met a jour les proprietes
|
||||
void ConductorPropertiesWidget::updateConfig() {
|
||||
properties_.type = static_cast<ConductorProperties::ConductorType>(radio_buttons -> checkedId());
|
||||
properties_.color = colorButton();
|
||||
properties_.text = text_field -> text();
|
||||
properties_.singleLineProperties.hasGround = ground_checkbox -> isChecked();
|
||||
properties_.singleLineProperties.hasNeutral = neutral_checkbox -> isChecked();
|
||||
@@ -152,6 +200,7 @@ void ConductorPropertiesWidget::updateDisplay() {
|
||||
destroyConnections();
|
||||
|
||||
setConductorType(properties_.type);
|
||||
setColorButton(properties_.color);
|
||||
text_field -> setText(properties_.text);
|
||||
ground_checkbox -> setChecked(properties_.singleLineProperties.hasGround);
|
||||
neutral_checkbox -> setChecked(properties_.singleLineProperties.hasNeutral);
|
||||
|
||||
Reference in New Issue
Block a user