diff --git a/src/Button.cc b/src/Button.cc index 62d994c..c5fa86b 100644 --- a/src/Button.cc +++ b/src/Button.cc @@ -47,7 +47,6 @@ #include #include // qFloor - namespace Material { @@ -155,7 +154,6 @@ KDecoration2::DecorationButton* Button::create(KDecoration2::DecorationButtonTyp switch (type) { case KDecoration2::DecorationButtonType::Menu: - // case KDecoration2::DecorationButtonType::ApplicationMenu: case KDecoration2::DecorationButtonType::OnAllDesktops: case KDecoration2::DecorationButtonType::ContextHelp: case KDecoration2::DecorationButtonType::Shade: @@ -336,14 +334,16 @@ void Button::setPenWidth(QPainter *painter, const qreal gridUnit, const qreal sc QColor returnVal; QColor normalColor = QColor(0,0,0,0); - auto c = d->client().data(); + auto c = d->client().toStrongRef().data(); + bool circleClose = d->isCloseButtonCircled(); + QColor redColor( c->color( KDecoration2::ColorGroup::Warning, KDecoration2::ColorRole::Foreground ) ); if (type() == KDecoration2::DecorationButtonType::Menu) { returnVal= normalColor; } else if( isPressed() ) { - if( type() == KDecoration2::DecorationButtonType::Close ) returnVal = redColor.darker(); + if( type() == KDecoration2::DecorationButtonType::Close) returnVal = redColor.darker(); else returnVal = KColorUtils::mix( normalColor, d->titleBarForegroundColor(), 0.5 ); } else if( isChecked() && type() != KDecoration2::DecorationButtonType::Maximize ) { @@ -355,7 +355,7 @@ void Button::setPenWidth(QPainter *painter, const qreal gridUnit, const qreal sc if( type() == KDecoration2::DecorationButtonType::Close ) {return c->isActive() ? redColor.lighter() : redColor;} else {returnVal = d->titleBarForegroundColor();} } else { - if (type() == KDecoration2::DecorationButtonType::Close) { + if (type() == KDecoration2::DecorationButtonType::Close && circleClose) { returnVal = c->isActive() ? redColor : d->titleBarForegroundColor(); } else { returnVal = normalColor; @@ -369,6 +369,7 @@ void Button::setPenWidth(QPainter *painter, const qreal gridUnit, const qreal sc QColor Button::foregroundColor() const { auto d = qobject_cast( decoration() ); + bool circleClose = d->isCloseButtonCircled(); if( !d ) { return QColor(); @@ -385,7 +386,7 @@ void Button::setPenWidth(QPainter *painter, const qreal gridUnit, const qreal sc return d->titleBarBackgroundColor(); - } else if (type() == KDecoration2::DecorationButtonType::Close) { + } else if (type() == KDecoration2::DecorationButtonType::Close && circleClose) { return d->titleBarBackgroundColor(); } else { diff --git a/src/Button.h b/src/Button.h index d8df4a6..41cf801 100644 --- a/src/Button.h +++ b/src/Button.h @@ -71,6 +71,7 @@ class Button : public KDecoration2::DecorationButton bool animationEnabled() const; void setAnimationEnabled(bool value); + void setCircleClose(bool isCircled); int animationDuration() const; void setAnimationDuration(int duration); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2d3631..220c5bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -109,12 +109,12 @@ target_link_libraries (breezelimdeco ) if (Qt6_FOUND) # The QX11Info class has been removed. - target_link_libraries (materialdecoration + target_link_libraries (breezelimdeco PUBLIC Qt${QT_VERSION_MAJOR}::GuiPrivate ) elseif(Qt5_FOUND) - target_link_libraries (materialdecoration + target_link_libraries (breezelimdeco PUBLIC Qt${QT_VERSION_MAJOR}::X11Extras ) diff --git a/src/ConfigurationModule.cc b/src/ConfigurationModule.cc index 55a9462..05bd8c5 100644 --- a/src/ConfigurationModule.cc +++ b/src/ConfigurationModule.cc @@ -57,6 +57,7 @@ ConfigurationModule::ConfigurationModule(QWidget *parent, const QVariantList &ar , m_titleAlignment(InternalSettings::AlignCenterFullWidth) , m_buttonSize(InternalSettings::ButtonDefault) , m_shadowSize(InternalSettings::ShadowVeryLarge) + , m_circleClose(false) { init(); } @@ -100,6 +101,11 @@ void ConfigurationModule::init() buttonSizes->setObjectName(QStringLiteral("kcfg_ButtonSize")); generalForm->addRow(i18nd("breeze_kwin_deco", "B&utton size:"), buttonSizes); + QCheckBox *closeButtonCircle = new QCheckBox(generalTab); + closeButtonCircle->setText(i18n("Show circle around close button")); + closeButtonCircle->setObjectName(QStringLiteral("kcfg_CloseButtonCircle")); + generalForm->addRow(QStringLiteral(""), closeButtonCircle); + QDoubleSpinBox *activeOpacity = new QDoubleSpinBox(generalTab); activeOpacity->setMinimum(0.0); activeOpacity->setMaximum(1.0); @@ -209,6 +215,14 @@ void ConfigurationModule::init() InternalSettings::ButtonDefault, QStringLiteral("ButtonSize") ); + + skel->addItemBool( + QStringLiteral("CloseButtonCircle"), + m_circleClose, + false, + QStringLiteral("CloseButtonCircle") + ); + skel->addItemDouble( QStringLiteral("ActiveOpacity"), m_activeOpacity, diff --git a/src/ConfigurationModule.h b/src/ConfigurationModule.h index 57e0246..ba2e77a 100644 --- a/src/ConfigurationModule.h +++ b/src/ConfigurationModule.h @@ -46,6 +46,7 @@ class ConfigurationModule : public KCModule int m_shadowSize; int m_shadowStrength; QColor m_shadowColor; + bool m_circleClose; }; } // namespace Material diff --git a/src/Decoration.cc b/src/Decoration.cc index f53ccaa..1c19746 100644 --- a/src/Decoration.cc +++ b/src/Decoration.cc @@ -395,6 +395,7 @@ void Decoration::updateBorders() setBorders(borders); } + void Decoration::updateResizeBorders() { QMargins borders; @@ -511,6 +512,7 @@ void Decoration::updateButtonsGeometry() m_menuButtons->setPos(availableRect.topLeft()); m_menuButtons->setSpacing(0); m_menuButtons->updateOverflow(availableRect); + } update(); @@ -1099,4 +1101,9 @@ void Decoration::paintOutline(QPainter *painter, const QRect &repaintRegion) con painter->restore(); } +bool Decoration::isCloseButtonCircled() +{ + return this->m_internalSettings->closeButtonCircle(); +} + } // namespace Material diff --git a/src/Decoration.h b/src/Decoration.h index 0727e74..b98d82e 100644 --- a/src/Decoration.h +++ b/src/Decoration.h @@ -61,6 +61,8 @@ class Decoration : public KDecoration2::Decoration void paint(QPainter *painter, const QRect &repaintRegion) override; + bool isCloseButtonCircled(); + public slots: void init() override; void reconfigure(); diff --git a/src/InternalSettingsSchema.kcfg b/src/InternalSettingsSchema.kcfg index f8852ea..25cf142 100644 --- a/src/InternalSettingsSchema.kcfg +++ b/src/InternalSettingsSchema.kcfg @@ -16,6 +16,11 @@ ButtonDefault + + + false + +