From 39f5cc84129ae2d44681e29e642ad961c8f7331a Mon Sep 17 00:00:00 2001 From: DeltaCopy Date: Tue, 28 Jan 2025 17:49:08 +0000 Subject: [PATCH 1/2] Added toolbar transparency settings --- kstyle/config/darklystyleconfig.cpp | 10 + kstyle/config/ui/darklystyleconfig.ui | 304 ++++++++++++++++++-------- kstyle/darkly.kcfg | 4 + kstyle/darklystyle.cpp | 38 +++- 4 files changed, 249 insertions(+), 107 deletions(-) diff --git a/kstyle/config/darklystyleconfig.cpp b/kstyle/config/darklystyleconfig.cpp index bf200cd5..a567d05e 100644 --- a/kstyle/config/darklystyleconfig.cpp +++ b/kstyle/config/darklystyleconfig.cpp @@ -76,6 +76,10 @@ StyleConfig::StyleConfig(QWidget *parent) connect(_menuBarOpacity, SIGNAL(valueChanged(int)), _menuBarOpacitySpinBox, SLOT(setValue(int))); connect(_menuBarOpacitySpinBox, SIGNAL(valueChanged(int)), _menuBarOpacity, SLOT(setValue(int))); + connect(_toolBarOpacity, &QAbstractSlider::valueChanged, this, &StyleConfig::updateChanged); + connect(_toolBarOpacity, SIGNAL(valueChanged(int)), _toolBarOpacitySpinBox, SLOT(setValue(int))); + connect(_toolBarOpacitySpinBox, SIGNAL(valueChanged(int)), _toolBarOpacity, SLOT(setValue(int))); + connect(_kTextEditDrawFrame, &QAbstractButton::toggled, this, &StyleConfig::updateChanged); connect(_widgetDrawShadow, &QAbstractButton::toggled, this, &StyleConfig::updateChanged); connect(_scrollableMenu, &QAbstractButton::toggled, this, &StyleConfig::updateChanged); @@ -112,6 +116,7 @@ void StyleConfig::save() StyleConfigData::setMenuOpacity(_menuOpacity->value()); StyleConfigData::setDolphinSidebarOpacity(_sidebarOpacity->value()); StyleConfigData::setMenuBarOpacity(_menuBarOpacity->value()); + StyleConfigData::setToolBarOpacity(_toolBarOpacity->value()); StyleConfigData::setButtonSize(_buttonSize->value()); StyleConfigData::setKTextEditDrawFrame(_kTextEditDrawFrame->isChecked()); StyleConfigData::setWidgetDrawShadow(_widgetDrawShadow->isChecked()); @@ -197,6 +202,9 @@ void StyleConfig::updateChanged() } else if (_menuBarOpacity->value() != StyleConfigData::menuBarOpacity()) { modified = true; _menuBarOpacitySpinBox->setValue(_menuBarOpacity->value()); + } else if (_toolBarOpacity->value() != StyleConfigData::toolBarOpacity()) { + modified = true; + _menuBarOpacitySpinBox->setValue(_menuBarOpacity->value()); } else if (_kTextEditDrawFrame->isChecked() != StyleConfigData::kTextEditDrawFrame()) modified = true; else if (_tabBarDrawCenteredTabs->isChecked() != StyleConfigData::tabBarDrawCenteredTabs()) @@ -249,6 +257,8 @@ void StyleConfig::load() _tabBarDrawCenteredTabs->setChecked(StyleConfigData::tabBarDrawCenteredTabs()); _menuBarOpacity->setValue(StyleConfigData::menuBarOpacity()); _menuBarOpacitySpinBox->setValue(StyleConfigData::menuBarOpacity()); + _toolBarOpacity->setValue(StyleConfigData::toolBarOpacity()); + _toolBarOpacitySpinBox->setValue(StyleConfigData::toolBarOpacity()); _buttonSize->setValue(StyleConfigData::buttonSize()); _kTextEditDrawFrame->setChecked(StyleConfigData::kTextEditDrawFrame()); diff --git a/kstyle/config/ui/darklystyleconfig.ui b/kstyle/config/ui/darklystyleconfig.ui index 84a1ccad..c50e24a6 100644 --- a/kstyle/config/ui/darklystyleconfig.ui +++ b/kstyle/config/ui/darklystyleconfig.ui @@ -318,7 +318,7 @@ 10 0 - 311 + 315 338 @@ -717,52 +717,46 @@ Transparency - - - - + + + + - Menu: + Menubar: - Qt::AlignmentFlag::AlignBottom|Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft + Qt::AlignmentFlag::AlignCenter 5 + + _menuBarOpacity + - - + + + + 0 + + + 0 + - + - This changes the menu items transparency - - - 0 + This only works on color schemes which support transparency 100 - - 1 - - - 10 - 100 Qt::Orientation::Horizontal - - false - - - false - QSlider::TickPosition::TicksBelow @@ -771,33 +765,94 @@ - - - - % - - - 100 - - - - + + + + Qt::AlignmentFlag::AlignCenter + + + % + + + 100 + + + + + + + + + + + + 0 + 0 + + + + Transparent + + + 73 + + + + + + + + 0 + 0 + + + + Qt::LayoutDirection::LeftToRight + + + Opaque + + + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter + + + 0 + + + 93 + + + + + + + + - Sidebars: + Sidebar: - Qt::AlignmentFlag::AlignBottom|Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft + Qt::AlignmentFlag::AlignCenter 5 + + _sidebarOpacity + - - + + + + 0 + + + 10 + @@ -835,47 +890,78 @@ - - - - % - - - 100 - - - - - + + + + Qt::AlignmentFlag::AlignCenter + + + % + + + 100 + + + + + + + + + - Menubar: + Menu: - Qt::AlignmentFlag::AlignBottom|Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft + Qt::AlignmentFlag::AlignCenter 5 + + _menuOpacity + - - + + + + 0 + + + 20 + - + - This only works on color schemes which support transparency + This changes the menu items transparency + + + 0 100 + + 1 + + + 10 + 100 Qt::Orientation::Horizontal + + false + + + false + QSlider::TickPosition::TicksBelow @@ -884,66 +970,92 @@ - - - - % - - - 100 - - - + + + + Qt::AlignmentFlag::AlignCenter + + + % + + + 100 + + + - - + + - - - - 0 - 0 - + + + true - Transparent + Toolbar: + + + Qt::AlignmentFlag::AlignCenter - 73 + 5 + + + _toolBarOpacity - - - - 0 - 0 - - - - Qt::LayoutDirection::LeftToRight + + + 0 - - Opaque + + 10 + + + + This only works on color schemes which support transparency + + + 100 + + + 100 + + + Qt::Orientation::Horizontal + + + QSlider::TickPosition::TicksBelow + + + 10 + + + + + + + - Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter + Qt::AlignmentFlag::AlignCenter - - 0 + + % - - 93 + + 100 - + Qt::Orientation::Vertical diff --git a/kstyle/darkly.kcfg b/kstyle/darkly.kcfg index b74c4e67..4e1e3138 100644 --- a/kstyle/darkly.kcfg +++ b/kstyle/darkly.kcfg @@ -267,6 +267,10 @@ 100 + + 100 + + false diff --git a/kstyle/darklystyle.cpp b/kstyle/darklystyle.cpp index 336d62ed..5426e7a1 100644 --- a/kstyle/darklystyle.cpp +++ b/kstyle/darklystyle.cpp @@ -5231,7 +5231,8 @@ bool Style::drawMenuBarEmptyAreaControl(const QStyleOption *option, QPainter *pa background.setAlphaF(opacity); painter->fillRect(rect, background); } else if (StyleConfigData::menuBarOpacity() == 0) { - background.setAlphaF(_helper->titleBarColor(windowActive).alphaF()); + opacity = 0.0; + background.setAlphaF(opacity); painter->fillRect(rect, background); } else if (StyleConfigData::menuBarOpacity() < 100 && StyleConfigData::menuBarOpacity() > 0) { // lower the opacity @@ -5320,8 +5321,8 @@ bool Style::drawMenuBarItemControl(const QStyleOption *option, QPainter *painter background.setAlphaF(opacity); painter->fillRect(rect, background); } else if (StyleConfigData::menuBarOpacity() == 0) { - // use the same titlebar color - background.setAlphaF(_helper->titleBarColor(windowActive).alphaF()); + opacity = 0.0; + background.setAlphaF(opacity); painter->fillRect(rect, background); } else if (StyleConfigData::menuBarOpacity() < 100 && StyleConfigData::menuBarOpacity() > 0) { // lower the opacity @@ -5734,15 +5735,33 @@ bool Style::drawToolBarBackgroundControl(const QStyleOption *option, QPainter *p } // qDebug() << _blurHelper->_sregisteredWidgets; - const int opacity = _helper->titleBarColor(windowActive).alphaF() * 100.0; + float opacity = 0.0; + + // paint background + QColor backgroundColor = palette.color(QPalette::Window); painter->setPen(Qt::NoPen); - _helper->renderTransparentArea(painter, rect); + if (StyleConfigData::toolBarOpacity() == 100) { + // opacity is at 100% + opacity = 1.0; + backgroundColor.setAlphaF(opacity); + painter->fillRect(rect, backgroundColor); + } else if (StyleConfigData::toolBarOpacity() == 0) { + // use the same titlebar color + _helper->renderTransparentArea(painter, rect); + opacity = 0.0; + backgroundColor.setAlphaF(opacity); + painter->fillRect(rect, backgroundColor); + } else if (StyleConfigData::toolBarOpacity() < 100 && StyleConfigData::toolBarOpacity() > 0) { + // lower the opacity + _helper->renderTransparentArea(painter, rect); + opacity = StyleConfigData::toolBarOpacity() / 100.0; + backgroundColor.setAlphaF(opacity); + painter->fillRect(rect, backgroundColor); + } - // paint background - QColor backgroundColor = palette.color(QPalette::Window); - if (sideToolbarDolphin) { + if (sideToolbarDolphin && _isDolphin) { backgroundColor.setAlphaF(StyleConfigData::dolphinSidebarOpacity() / 100.0 - 0.15); painter->fillRect(rect, backgroundColor); @@ -5765,9 +5784,6 @@ bool Style::drawToolBarBackgroundControl(const QStyleOption *option, QPainter *p painter->drawLine(rect.topLeft() + QPoint(0, 3), rect.topRight() + QPoint(0, 3)); return true; - } else { - backgroundColor.setAlphaF(opacity / 100.0); - painter->fillRect(rect, backgroundColor); } if (StyleConfigData::toolBarDrawSeparator() && !_isDolphin) { From 95aecd814fe39029418f9544f64b8251bce70ef6 Mon Sep 17 00:00:00 2001 From: DeltaCopy Date: Wed, 29 Jan 2025 13:12:35 +0000 Subject: [PATCH 2/2] Toolbar opacity --- kstyle/config/darklystyleconfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kstyle/config/darklystyleconfig.cpp b/kstyle/config/darklystyleconfig.cpp index a567d05e..87b9b7d0 100644 --- a/kstyle/config/darklystyleconfig.cpp +++ b/kstyle/config/darklystyleconfig.cpp @@ -204,7 +204,7 @@ void StyleConfig::updateChanged() _menuBarOpacitySpinBox->setValue(_menuBarOpacity->value()); } else if (_toolBarOpacity->value() != StyleConfigData::toolBarOpacity()) { modified = true; - _menuBarOpacitySpinBox->setValue(_menuBarOpacity->value()); + _toolBarOpacitySpinBox->setValue(_toolBarOpacity->value()); } else if (_kTextEditDrawFrame->isChecked() != StyleConfigData::kTextEditDrawFrame()) modified = true; else if (_tabBarDrawCenteredTabs->isChecked() != StyleConfigData::tabBarDrawCenteredTabs())