From 56d25172e0220b8bbdb91a44508b997fed914fd1 Mon Sep 17 00:00:00 2001 From: Paddle Date: Mon, 3 Apr 2023 13:47:26 +0200 Subject: [PATCH] Pref: Colors: Reorganize the ui. --- src/Gui/DlgSettingsViewColor.cpp | 59 +++++++ src/Gui/DlgSettingsViewColor.h | 7 + src/Gui/DlgSettingsViewColor.ui | 269 ++++++++++--------------------- src/Gui/Icons/button_switch.svg | 195 ++++++++++++++++++++++ src/Gui/Icons/resource.qrc | 1 + 5 files changed, 344 insertions(+), 187 deletions(-) create mode 100644 src/Gui/Icons/button_switch.svg diff --git a/src/Gui/DlgSettingsViewColor.cpp b/src/Gui/DlgSettingsViewColor.cpp index ba017d9c0b..b806c1bd8a 100644 --- a/src/Gui/DlgSettingsViewColor.cpp +++ b/src/Gui/DlgSettingsViewColor.cpp @@ -46,6 +46,18 @@ DlgSettingsViewColor::DlgSettingsViewColor(QWidget* parent) ui->SelectionColor->setEnabled(ui->checkBoxSelection->isChecked()); connect(ui->SwitchGradientColors, &QPushButton::pressed, this, &DlgSettingsViewColor::onSwitchGradientColorsPressed); + + connect(ui->radioButtonSimple, &QRadioButton::toggled, this, + &DlgSettingsViewColor::onRadioButtonSimpleToggled); + + connect(ui->radioButtonGradient, &QRadioButton::toggled, this, + &DlgSettingsViewColor::onRadioButtonGradientToggled); + + connect(ui->rbRadialGradient, &QRadioButton::toggled, this, + &DlgSettingsViewColor::onRadioButtonRadialGradientToggled); + + connect(ui->checkMidColor, &QCheckBox::toggled, this, + &DlgSettingsViewColor::onCheckMidColorToggled); } /** @@ -90,6 +102,13 @@ void DlgSettingsViewColor::loadSettings() ui->SelectionColor->onRestore(); ui->TreeEditColor->onRestore(); ui->TreeActiveColor->onRestore(); + + if (ui->radioButtonSimple->isChecked()) + onRadioButtonSimpleToggled(true); + else if(ui->radioButtonGradient->isChecked()) + onRadioButtonGradientToggled(true); + else + onRadioButtonRadialGradientToggled(true); } /** @@ -112,5 +131,45 @@ void DlgSettingsViewColor::onSwitchGradientColorsPressed() ui->backgroundColorTo->setColor(tempColor); } +void DlgSettingsViewColor::onCheckMidColorToggled(bool val) +{ + ui->color2Label->setVisible(val); + ui->backgroundColorMid->setVisible(val); +} + +void DlgSettingsViewColor::onRadioButtonSimpleToggled(bool val) +{ + setGradientColorVisibility(!val); +} + +void DlgSettingsViewColor::onRadioButtonGradientToggled(bool val) +{ + setGradientColorVisibility(val); + ui->color1Label->setText(tr("Top:")); + ui->color2Label->setText(tr("Middle:")); + ui->color3Label->setText(tr("Bottom:")); +} + +void DlgSettingsViewColor::onRadioButtonRadialGradientToggled(bool val) +{ + setGradientColorVisibility(val); + ui->color1Label->setText(tr("Central:")); + ui->color2Label->setText(tr("Midway:")); + ui->color3Label->setText(tr("End:")); +} + +void DlgSettingsViewColor::setGradientColorVisibility(bool val) +{ + ui->SelectionColor_Background->setVisible(!val); + ui->color1Label->setVisible(val); + ui->backgroundColorFrom->setVisible(val); + ui->color2Label->setVisible(val && ui->checkMidColor->isChecked()); + ui->backgroundColorMid->setVisible(val && ui->checkMidColor->isChecked()); + ui->color3Label->setVisible(val); + ui->backgroundColorTo->setVisible(val); + ui->checkMidColor->setVisible(val); + ui->SwitchGradientColors->setVisible(val); +} + #include "moc_DlgSettingsViewColor.cpp" diff --git a/src/Gui/DlgSettingsViewColor.h b/src/Gui/DlgSettingsViewColor.h index 394c13892e..bed4835a2c 100644 --- a/src/Gui/DlgSettingsViewColor.h +++ b/src/Gui/DlgSettingsViewColor.h @@ -52,6 +52,13 @@ protected: protected Q_SLOTS: void onSwitchGradientColorsPressed(); + void onRadioButtonSimpleToggled(bool val); + void onRadioButtonGradientToggled(bool val); + void onRadioButtonRadialGradientToggled(bool val); + void onCheckMidColorToggled(bool val); + +private: + void setGradientColorVisibility(bool val); private: std::unique_ptr ui; diff --git a/src/Gui/DlgSettingsViewColor.ui b/src/Gui/DlgSettingsViewColor.ui index 398205dcbe..2d259085ff 100644 --- a/src/Gui/DlgSettingsViewColor.ui +++ b/src/Gui/DlgSettingsViewColor.ui @@ -209,12 +209,6 @@ - - - 240 - 0 - - Background will have selected color @@ -229,7 +223,45 @@ - + + + + Background will have selected color gradient + + + Linear gradient + + + true + + + Gradient + + + View + + + + + + + Background will have selected color gradient + + + Radial gradient + + + false + + + RadialGradient + + + View + + + + false @@ -261,30 +293,15 @@ - - - - Background will have selected color gradient - + + - Linear gradient - - - true - - - Gradient - - - View + Top: - + - - Top color - @@ -303,40 +320,42 @@ - - - - Switches the colors of the gradient - - - Switch - - + + + + Middle: + + - - - - Background will have selected color gradient - + + - Radial gradient + - - false + + + 111 + 111 + 147 + - RadialGradient + BackgroundColor4 View - - - - Bottom color + + + + Bottom: + + + + @@ -355,7 +374,21 @@ - + + + + Switches the colors of the gradient + + + Switch + + + + :/icons/button_switch.svg:/icons/button_switch.svg + + + + Color gradient will get selected color as middle color @@ -371,32 +404,6 @@ - - - - false - - - Middle color - - - - - - - 111 - 111 - 147 - - - - BackgroundColor4 - - - View - - - @@ -631,117 +638,5 @@ - - checkMidColor - toggled(bool) - backgroundColorMid - setEnabled(bool) - - - 114 - 363 - - - 310 - 365 - - - - - radioButtonSimple - toggled(bool) - SelectionColor_Background - setEnabled(bool) - - - 103 - 282 - - - 310 - 284 - - - - - radioButtonGradient - toggled(bool) - backgroundColorFrom - setEnabled(bool) - - - 110 - 309 - - - 310 - 311 - - - - - radioButtonGradient - toggled(bool) - backgroundColorTo - setEnabled(bool) - - - 77 - 309 - - - 310 - 338 - - - - - rbRadialGradient - toggled(bool) - backgroundColorFrom - setEnabled(bool) - - - 110 - 309 - - - 310 - 311 - - - - - rbRadialGradient - toggled(bool) - backgroundColorTo - setEnabled(bool) - - - 77 - 309 - - - 310 - 338 - - - - - radioButtonSimple - toggled(bool) - checkMidColor - setDisabled(bool) - - - 99 - 282 - - - 93 - 363 - - - diff --git a/src/Gui/Icons/button_switch.svg b/src/Gui/Icons/button_switch.svg new file mode 100644 index 0000000000..af09a6b662 --- /dev/null +++ b/src/Gui/Icons/button_switch.svg @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + Mon Oct 10 13:44:52 2011 +0000 + + + [wmayer] + + + + + FreeCAD LGPL2+ + + + + + FreeCAD + + + FreeCAD/src/Mod/Draft/Resources/icons/Draft_Rotate.svg + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + [agryson] Alexander Gryson + + + An arrow in a circular shape with the head curving towards the tail + + + arrow + curved + refresh + rotate + + + arrow-ccw + https://www.gnu.org/copyleft/lesser.html + + + + diff --git a/src/Gui/Icons/resource.qrc b/src/Gui/Icons/resource.qrc index 56ecc604a1..ba6c064894 100644 --- a/src/Gui/Icons/resource.qrc +++ b/src/Gui/Icons/resource.qrc @@ -19,6 +19,7 @@ button_right.svg button_up.svg button_sort.svg + button_switch.svg button_add_all.svg button_valid.svg button_invalid.svg