设置三个圆角gsettings

This commit is contained in:
tanjing 2023-10-18 09:37:33 +08:00 committed by xibowen
parent ad09c5e654
commit 9346a089f0
14 changed files with 127 additions and 40 deletions

View File

@ -87,5 +87,20 @@
<summary>Custom highlight color</summary>
<description>Set custom highlight color for UKUI desktop environment.Now is to compatible with third party application</description>
</key>
<key type="i" name="window-radius">
<default>8</default>
<summary>Window Radius</summary>
<description>Set the rounded corner size of the window</description>
</key>
<key type="i" name="normal-radius">
<default>6</default>
<summary>Normal Radius</summary>
<description>Setting this normal fillet value can uniformly modify the fillet values of all normal fillet controls</description>
</key>
<key type="i" name="min-radius">
<default>4</default>
<summary>Min Radius</summary>
<description>Setting this small rounded value can uniformly modify the rounded values of all small rounded controls</description>
</key>
</schema>
</schemalist>

View File

@ -1693,8 +1693,8 @@ void KyNativeFileDialog::paintEvent(QPaintEvent *e)
// sidebarPath.addRect(adjustedRect.adjusted(6, 0, 0, 0));
QPainter p(this);
QPainterPath contentPath;
if(this && this->property("maxRadius").isValid())
radius = this->property("maxRadius").toInt();
if(this && this->property("windowRadius").isValid())
radius = this->property("windowRadius").toInt();
// qDebug() << "KyNativeFileDialog radius........" << radius;
contentPath.addRoundedRect(this->rect(), radius, radius);
auto bgPath = contentPath - sidebarPath;

View File

@ -282,8 +282,8 @@ void BlurHelper::delayUpdate(QWidget *w, bool updateBlurRegionOnly)
}
QPainterPath path;
int radius = 8;
if(widget->property("maxRadius").isValid())
radius = widget->property("maxRadius").toInt();
if(widget->property("windowRadius").isValid())
radius = widget->property("windowRadius").toInt();
path.addRoundedRect(widget->rect(), radius, radius);
KWindowEffects::enableBlurBehind(widget->winId(), true, path.toFillPolygon().toPolygon());
if (!updateBlurRegionOnly)

View File

@ -155,8 +155,8 @@ QPixmap ConfigShadowHelper::getShadowPixmap(QColor color, /*ConfigShadowHelper::
QPoint currentPos;
int qAppMaxradius = maxRadius;
if(widget && widget->property("maxRadius").isValid()){
qAppMaxradius = widget->property("maxRadius").toInt();
if(widget && widget->property("windowRadius").isValid()){
qAppMaxradius = widget->property("windowRadius").toInt();
// qDebug() << "radius...." << qAppMaxradius;
}
// move to top left arc start point
@ -259,8 +259,8 @@ QPainterPath ConfigShadowHelper::caculateRelativePainterPath(QWidget *widget, qr
QPointF currentPos;
int qAppMaxradius = maxRadius;
if(widget && widget->property("maxRadius").isValid()){
qAppMaxradius = widget->property("maxRadius").toInt();
if(widget && widget->property("windowRadius").isValid()){
qAppMaxradius = widget->property("windowRadius").toInt();
//qDebug() << "radius...." << qAppMaxradius;
}

View File

@ -1,6 +1,6 @@
{
"Radius":{
"Max_Radius" : {"value": "0", "type": "int"},
"Window_Radius" : {"value": "0", "type": "int"},
"Normal_Radius" : {"value": "0", "type": "int"},
"Min_Radius" : {"value": "0", "type": "int"}
},

View File

@ -1,6 +1,6 @@
{
"Radius":{
"Max_Radius" : {"value": "8", "type": "int"},
"Window_Radius" : {"value": "8", "type": "int"},
"Normal_Radius" : {"value": "6", "type": "int"},
"Min_Radius" : {"value": "4", "type": "int"}
},

View File

@ -1,6 +1,6 @@
{
"Radius":{
"Max_Radius" : {"value": "8", "type": "int"},
"Window_Radius" : {"value": "8", "type": "int"},
"Normal_Radius" : {"value": "6", "type": "int"},
"Min_Radius" : {"value": "4", "type": "int"}
},

View File

@ -258,8 +258,6 @@ void UKUIConfigStyleParameters::initRadiusCfg()
m_adjustColorRules = m_readCfg->getColorValueAdjustRules() == "HSL" ? AdjustColorRules::HSL : AdjustColorRules::DefaultRGB;
}
m_radiusStruct = m_readCfg->getRadiusStruct(UKUI_Radius);
radius = m_radiusStruct.normalRadius;
cDebug << "min:" << m_radiusStruct.minRadius << "normal:" << m_radiusStruct.normalRadius << "max:" << m_radiusStruct.maxRadius;
}
QPalette UKUIConfigStyleParameters::setPalette(QPalette &palette)
@ -708,7 +706,7 @@ void UKUIConfigStyleParameters::initConfigPushButtonBevelParameters(bool isDark,
if (isImportant)
buttonColorCfg = readCfg()->buttonColorCfg(option->palette, C_Button_ImportButton);
int radius = m_radiusStruct.normalRadius;
int radius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
QBrush defaultBrush = QBrush(buttonColorCfg.defaultBrush);
QBrush disableBrush = QBrush(buttonColorCfg.disableBrush);
@ -1114,7 +1112,8 @@ void UKUIConfigStyleParameters::initConfigToolButtonPanelParameters(bool isDark,
if (isImportant)
buttonColorCfg = readCfg()->toolButtonColorCfg(option->palette, C_Button_ImportButton);
int radius = m_radiusStruct.normalRadius;
int radius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
QBrush defaultBrush = QBrush(buttonColorCfg.defaultBrush);
QBrush disableBrush = QBrush(buttonColorCfg.disableBrush);
QBrush clickBrush = QBrush(buttonColorCfg.clickBrush);
@ -1475,7 +1474,8 @@ void UKUIConfigStyleParameters::initConfigToolButtonLabelParameters(bool isDark,
void UKUIConfigStyleParameters::initConfigLineEditParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
int radius = m_radiusStruct.normalRadius;
int radius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
qDebug() << "initConfigLineEditParameters....." << widget->property("normalRadius").isValid() << radius;
bool needTranslucent = false;
if (widget && widget->property("needTranslucent").isValid()) {
needTranslucent = widget->property("needTranslucent").toBool();
@ -1603,7 +1603,8 @@ void UKUIConfigStyleParameters::initConfigLineEditParameters(bool isDark, const
void UKUIConfigStyleParameters::initConfigSpinBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget, bool isHorizonLayout)
{
int radius = m_radiusStruct.normalRadius;
int radius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
UKUIColorTheme::SpinBoxColorCfg spinBoxColorCfg =
readCfg()->spinBoxColorCfg(option->palette, C_SpinBox_Default, isHorizonLayout ? C_SpinBox_HorizonLayout : C_SpinBox_DefaultLayout);
@ -2028,7 +2029,8 @@ void UKUIConfigStyleParameters::initConfigSpinBoxParameters(bool isDark, const Q
void UKUIConfigStyleParameters::initConfigComboBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
int radius = m_radiusStruct.normalRadius;
int radius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
UKUIColorTheme::ComboBoxColorCfg comboBoxColorCfg = readCfg()->comboBoxColorCfg(option->palette, C_ComboBox_Default);
@ -2118,7 +2120,8 @@ void UKUIConfigStyleParameters::initConfigComboBoxParameters(bool isDark, const
void UKUIConfigStyleParameters::initConfigListParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
int radius = m_radiusStruct.normalRadius;
int radius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
bool needTranslucent = false;
bool highlightMode = false;
@ -2259,7 +2262,8 @@ void UKUIConfigStyleParameters::initConfigListParameters(bool isDark, const QSty
void UKUIConfigStyleParameters::initConfigTreeParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
int radius = m_radiusStruct.normalRadius;;
int radius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
;
bool highlightMode = false;
if (widget && widget->property("highlightMode").isValid()) {
@ -2404,7 +2408,8 @@ void UKUIConfigStyleParameters::initConfigTreeParameters(bool isDark, const QSty
void UKUIConfigStyleParameters::initConfigTableParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
int radius = m_radiusStruct.normalRadius;
int radius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
bool highlightMode = false;
if (widget && widget->property("highlightMode").isValid()) {
@ -2524,7 +2529,7 @@ void UKUIConfigStyleParameters::initConfigCheckBoxParameters(bool isDark, const
UKUIColorTheme::CheckBoxColorCfg checkboxColorCfg = readCfg()->checkBoxColorCfg(option->palette, needTranslucent ? C_CheckBox_Translucent : C_CheckBox_Default);
int radius = m_radiusStruct.minRadius;
int radius = (widget && widget->property("minRadius").isValid()) ? widget->property("minRadius").toInt() : m_radiusStruct.minRadius;
QPen defaultPen = QPen(checkboxColorCfg.defaultPen, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
QPen hoverPen = QPen(checkboxColorCfg.hoverPen, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
@ -2770,6 +2775,9 @@ void UKUIConfigStyleParameters::initConfigCheckBoxParameters(bool isDark, const
}
}
// qDebug() << "defaultpen..." << defaultPen.color().red() << defaultPen.color().green() << defaultPen.color().blue();
// qDebug() << "defaultbrush..." << defaultBrush.color().red() << defaultBrush.color().green() << defaultBrush.color().blue();
m_CheckBoxParameters.radius = radius;
m_CheckBoxParameters.checkBoxDefaultPen = defaultPen;
m_CheckBoxParameters.checkBoxHoverPen = hoverPen;
@ -2795,7 +2803,7 @@ void UKUIConfigStyleParameters::initConfigCheckBoxParameters(bool isDark, const
void UKUIConfigStyleParameters::initConfigRadioButtonParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
m_RadioButtonParameters.radius = m_radiusStruct.normalRadius;
m_RadioButtonParameters.radius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
UKUIColorTheme::RadioButtonColorCfg radioButtonColorCfg = readCfg()->radioButtonColorCfg(option->palette, C_RadioButton_Default);
QPen defaultPen = QPen(radioButtonColorCfg.defaultPen, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
@ -3238,7 +3246,8 @@ void UKUIConfigStyleParameters::initConfigSliderParameters(bool isDark, const QS
void UKUIConfigStyleParameters::initConfigProgressBarParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
int radius = widget ? (widget->height() / 2 > m_radiusStruct.normalRadius ? m_radiusStruct.normalRadius : widget->height() / 2) : m_radiusStruct.normalRadius;
int normalRadius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
int radius = widget ? (widget->height() / 2 > normalRadius ? normalRadius : widget->height() / 2) : normalRadius;
bool needTranslucent = false;
if (widget && widget->property("needTranslucent").isValid()) {
@ -3379,7 +3388,8 @@ void UKUIConfigStyleParameters::initConfigScrollBarParameters(bool isDark, const
const QStyleOptionSlider *bar = qstyleoption_cast<const QStyleOptionSlider *>(option);
//radius
if(m_radiusStruct.normalRadius != 0){
int normalRadius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
if(normalRadius != 0){
if (bar->orientation == Qt::Horizontal) {
sliderRadius = (bar->rect.height()) / 4;
} else {
@ -3390,7 +3400,8 @@ void UKUIConfigStyleParameters::initConfigScrollBarParameters(bool isDark, const
ScroolBar_LineLength = 0;
}
else{
sliderRadius = m_radiusStruct.normalRadius;
int normalRadius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
sliderRadius = normalRadius;
m_ScrollBarParameters.grooveWidthAnimation = false;
ScrooBar_ShowLine = true;
ScroolBar_LineLength = 16;
@ -3525,7 +3536,7 @@ void UKUIConfigStyleParameters::initConfigToolTipParameters(bool isDark, const Q
}
QBrush backgroundBrush = color;
int radius = m_radiusStruct.normalRadius;
int radius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
if(widget){
if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
@ -3546,7 +3557,7 @@ void UKUIConfigStyleParameters::initConfigToolTipParameters(bool isDark, const Q
void UKUIConfigStyleParameters::initConfigTabWidgetParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
int tabradius = m_radiusStruct.normalRadius;
int tabradius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
UKUIColorTheme::TabWidgetColorCfg tabWidgetColorCfg = readCfg()->tabWidgetColorCfg(option->palette, C_TabWidget_Default);
QBrush widgetBackgroundBrush = tabWidgetColorCfg.widgetBackgroundBrush;
@ -3663,8 +3674,8 @@ void UKUIConfigStyleParameters::initConfigTabWidgetParameters(bool isDark, const
void UKUIConfigStyleParameters::initConfigMenuParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
int frameradius = m_radiusStruct.maxRadius;
int itemradius = m_radiusStruct.normalRadius;
int frameradius = (widget && widget->property("windowRadius").isValid()) ? widget->property("windowRadius").toInt() : m_radiusStruct.maxRadius;
int itemradius = (widget && widget->property("normalRadius").isValid()) ? widget->property("normalRadius").toInt() : m_radiusStruct.normalRadius;
// QPixmap framePixmap(option->rect.size());
UKUIColorTheme::MenuColorCfg menuColorCfg = readCfg()->menuColorCfg(C_Menu_Default);

View File

@ -265,7 +265,13 @@ UKUIConfigStyle::UKUIConfigStyle(bool dark, bool useDefault, QString type) : QPr
sp = new UKUIConfigStyleParameters(this, isUseDarkPalette(), m_widget_theme);
setProperty("maxRadius", sp->radiusProperty().maxRadius);
if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) {
auto settings = UKUIStyleSettings::globalInstance();
if(settings->keys().contains("windowRadius"))
setProperty("windowRadius", settings->get("windowRadius").toInt());
else
setProperty("windowRadius", sp->radiusProperty().maxRadius);
}
setProperty("normalRadius", sp->radiusProperty().normalRadius);
setProperty("minRadius", sp->radiusProperty().minRadius);
}
@ -921,9 +927,28 @@ void UKUIConfigStyle::polish(QWidget *widget)
if(!widget)
return;
widget->setProperty("maxRadius", sp->radiusProperty().maxRadius);
widget->setProperty("normalRadius", sp->radiusProperty().normalRadius);
widget->setProperty("minRadius", sp->radiusProperty().minRadius);
if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) {
auto settings = UKUIStyleSettings::globalInstance();
if(settings->keys().contains("windowRadius"))
widget->setProperty("windowRadius", settings->get("windowRadius").toInt());
else
widget->setProperty("windowRadius", sp->radiusProperty().maxRadius);
}
// if(settings->keys().contains("normalRadius"))
// widget->setProperty("normalRadius", settings->get("normalRadius").toInt());
// else
// widget->setProperty("normalRadius", sp->radiusProperty().normalRadius);
// if(settings->keys().contains("minRadius"))
// widget->setProperty("minRadius", settings->get("minRadius").toInt());
// else
// widget->setProperty("minRadius", sp->radiusProperty().minRadius);
// }
// else{
widget->setProperty("normalRadius", sp->radiusProperty().normalRadius);
widget->setProperty("minRadius", sp->radiusProperty().minRadius);
// }
Style::polish(widget);

View File

@ -261,7 +261,7 @@ Qt5UKUIStyle::Qt5UKUIStyle(bool dark, bool useDefault, QString type) : QProxySty
sp = new KClassicalStyleParameters(this, isUseDarkPalette());
qDebug() << "classical setproperty........" << sp->radiusProperty().maxRadius << sp->radiusProperty().normalRadius << sp->radiusProperty().minRadius;
setProperty("maxRadius", sp->radiusProperty().maxRadius);
setProperty("windowRadius", sp->radiusProperty().maxRadius);
setProperty("normalRadius", sp->radiusProperty().normalRadius);
setProperty("minRadius", sp->radiusProperty().minRadius);
}

View File

@ -1,6 +1,6 @@
{
"Radius":{
"Max_Radius" : {"value": "0", "type": "int"},
"Window_Radius" : {"value": "0", "type": "int"},
"Normal_Radius" : {"value": "0", "type": "int"},
"Min_Radius" : {"value": "0", "type": "int"}
}

View File

@ -1128,7 +1128,7 @@ UKUIRadiusInformation::UKUIRadiusStruct ReadThemeConfig::getRadiusStruct(QString
if(!m_loadConfig)
return m_radiusStruct;
getRadius(Max_Radius, m_radiusStruct.maxRadius);
getRadius(Window_Radius, m_radiusStruct.maxRadius);
getRadius(Normal_Radius, m_radiusStruct.normalRadius);
getRadius(Min_Radius, m_radiusStruct.minRadius);
return m_radiusStruct;

View File

@ -43,7 +43,7 @@
#define Obj_PaletteRole_Type "paletterole"
#define UKUI_Radius "Radius"
#define Max_Radius "Max_Radius"
#define Window_Radius "Window_Radius"
#define Normal_Radius "Normal_Radius"
#define Min_Radius "Min_Radius"

View File

@ -65,10 +65,23 @@ UKUIStylePlugin::UKUIStylePlugin(QObject *parent) :
if(qAppName() != blackStyleChangeApp) {
if (widgetThemeName == "classical") {
styleName ="ukui-config";
qApp->setStyle(new UKUIConfigStyle(styleName));
} else {
styleName = "ukui-config";
qApp->setStyle(new UKUIConfigStyle(styleName));
}
qApp->setStyle(new UKUIConfigStyle(styleName));
if(key == "widgetThemeName" || key == "widget-theme-name"){
qDebug() << "qApp style....." << qApp->style();
auto configStyle = qobject_cast<UKUIConfigStyle *>(qApp->style());
if(configStyle){
int max, normal, min;
max = configStyle->property("windowRadius").isValid() ? configStyle->property("windowRadius").toInt() : settings->get("windowRadius").toInt();
normal = configStyle->property("normalRadius").isValid() ? configStyle->property("normalRadius").toInt() : settings->get("normalRadius").toInt();
min = configStyle->property("minRadius").isValid() ? configStyle->property("minRadius").toInt() : settings->get("minRadius").toInt();
settings->trySet("max-radius", max);
settings->trySet("normal-radius", normal);
settings->trySet("min-radius", min);
}
}
}
@ -95,6 +108,29 @@ UKUIStylePlugin::UKUIStylePlugin(QObject *parent) :
if (key == "useSystemPalette") {
onSystemPaletteChanged();
}
if(key == "max-radius" || key == "windowRadius"){
auto radius = settings->get("windowRadius").toInt();
foreach (QWidget *widget, qApp->allWidgets()) {
widget->setProperty("windowRadius", radius);
widget->repaint();
}
}
if(key == "normal-radius" || key == "normalRadius"){
auto radius = settings->get("normalRadius").toInt();
//qDebug() << "normalRadius.........." << radius;
foreach (QWidget *widget, qApp->allWidgets()) {
widget->setProperty("normalRadius", radius);
widget->repaint();
}
}
if(key == "min-radius" || key == "minRadius"){
auto radius = settings->get("minRadius").toInt();
foreach (QWidget *widget, qApp->allWidgets()) {
widget->setProperty("minRadius", radius);
widget->repaint();
}
}
});
}