mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-06 19:54:13 +02:00
Add custom application color picker in global settings
Add a KColorButton next to the 'Utiliser les couleurs du système' checkbox in the Apparence settings tab: - When the checkbox is active (default), system colors are used and the color button is disabled - When the checkbox is inactive, the color button becomes active and lets the user pick any color for the entire application - useCustomPalette() builds a full QPalette from the chosen color with proper light/dark text contrast, button shading, and icon theme switching - The chosen color is persisted in QSettings as 'customapplicationcolor' and restored on next startup Files changed: - sources/ui/configpage/generalconfigurationpage.ui: HBoxLayout with checkbox + KColorButton, customwidget declaration - sources/ui/configpage/generalconfigurationpage.h: new slot - sources/ui/configpage/generalconfigurationpage.cpp: load/save custom color, enable/disable logic, toggled slot - sources/qetapp.h: useCustomPalette() declaration - sources/qetapp.cpp: useCustomPalette() implementation, startup restore of custom color
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "../../utils/qetsettings.h"
|
||||
#include "../../utils/qetutils.h"
|
||||
#include "../../qetmessagebox.h"
|
||||
#include "../nokde/kcolorbutton.h"
|
||||
#include <QFileDialog>
|
||||
#include <QFontDialog>
|
||||
#include <QSettings>
|
||||
@@ -74,6 +75,12 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
ui->DiagramEditor_Grid_PointSize_min_sb->setValue(settings.value("diagrameditor/grid_pointsize_min", 1).toInt());
|
||||
ui->DiagramEditor_Grid_PointSize_max_sb->setValue(settings.value("diagrameditor/grid_pointsize_max", 1).toInt());
|
||||
ui->m_use_system_color_cb->setChecked(settings.value("usesystemcolors", "true").toBool());
|
||||
bool sysColors = ui->m_use_system_color_cb->isChecked();
|
||||
ui->m_custom_app_color_kpb->setEnabled(!sysColors);
|
||||
if (settings.contains("customapplicationcolor"))
|
||||
ui->m_custom_app_color_kpb->setColor(QColor(settings.value("customapplicationcolor").toString()));
|
||||
else
|
||||
ui->m_custom_app_color_kpb->setColor(QApplication::palette().color(QPalette::Window));
|
||||
bool tabbed = settings.value("diagrameditor/viewmode", "tabbed") == "tabbed";
|
||||
if(tabbed)
|
||||
ui->m_use_tab_mode_rb->setChecked(true);
|
||||
@@ -206,7 +213,17 @@ void GeneralConfigurationPage::applyConf()
|
||||
bool must_use_system_colors = ui->m_use_system_color_cb->isChecked();
|
||||
settings.setValue("usesystemcolors", must_use_system_colors);
|
||||
if (was_using_system_colors != must_use_system_colors) {
|
||||
QETApp::instance()->useSystemPalette(must_use_system_colors);
|
||||
if (must_use_system_colors) {
|
||||
QETApp::instance()->useSystemPalette(true);
|
||||
} else {
|
||||
QColor custom_color = ui->m_custom_app_color_kpb->color();
|
||||
settings.setValue("customapplicationcolor", custom_color.name());
|
||||
QETApp::instance()->useCustomPalette(custom_color);
|
||||
}
|
||||
} else if (!must_use_system_colors) {
|
||||
QColor custom_color = ui->m_custom_app_color_kpb->color();
|
||||
settings.setValue("customapplicationcolor", custom_color.name());
|
||||
QETApp::instance()->useCustomPalette(custom_color);
|
||||
}
|
||||
settings.setValue("border-columns_0",ui->m_border_0->isChecked());
|
||||
settings.setValue("lang", ui->m_lang_cb->itemData(ui->m_lang_cb->currentIndex()).toString());
|
||||
@@ -625,3 +642,14 @@ void GeneralConfigurationPage::on_m_hdpi_round_cb_clicked(bool checked)
|
||||
ui->m_hdpi_round_policy_cb->setEnabled(checked);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief GeneralConfigurationPage::on_m_use_system_color_cb_toggled
|
||||
Enable/disable the custom color picker when the system color
|
||||
checkbox is toggled.
|
||||
@param checked
|
||||
*/
|
||||
void GeneralConfigurationPage::on_m_use_system_color_cb_toggled(bool checked)
|
||||
{
|
||||
ui->m_custom_app_color_kpb->setEnabled(!checked);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ class GeneralConfigurationPage : public ConfigPage
|
||||
void on_ElementEditor_Grid_PointSize_min_sb_valueChanged(int value);
|
||||
|
||||
void on_m_hdpi_round_cb_clicked(bool checked);
|
||||
void on_m_use_system_color_cb_toggled(bool checked);
|
||||
|
||||
private:
|
||||
void fillLang();
|
||||
|
||||
@@ -23,15 +23,26 @@
|
||||
<attribute name="title">
|
||||
<string>Apparence</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_use_system_color_cb">
|
||||
<property name="text">
|
||||
<string>Utiliser les couleurs du système</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="m_system_color_layout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_use_system_color_cb">
|
||||
<property name="text">
|
||||
<string>Utiliser les couleurs du système</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorButton" name="m_custom_app_color_kpb">
|
||||
<property name="toolTip">
|
||||
<string>Couleur de l'application</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@@ -1161,4 +1172,11 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>nokde/kcolorbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user