diff --git a/clients/aurorae/src/aurorae.cpp b/clients/aurorae/src/aurorae.cpp index f933a95826..664ee42bda 100644 --- a/clients/aurorae/src/aurorae.cpp +++ b/clients/aurorae/src/aurorae.cpp @@ -308,7 +308,8 @@ void Decoration::init() // KConfigGroup themeGroup(&conf, themeName); AuroraeTheme *theme = new AuroraeTheme(this); theme->loadTheme(themeName, config); -// m_theme->setBorderSize((KDecorationDefines::BorderSize)themeGroup.readEntry("BorderSize", KDecorationDefines::BorderNormal)); + theme->setBorderSize(s->borderSize()); + connect(s.data(), &KDecoration2::DecorationSettings::borderSizeChanged, theme, &AuroraeTheme::setBorderSize); // m_theme->setButtonSize((KDecorationDefines::BorderSize)themeGroup.readEntry("ButtonSize", KDecorationDefines::BorderNormal)); // m_theme->setTabDragMimeType(tabDragMimeType()); context->setContextProperty(QStringLiteral("auroraeTheme"), theme); diff --git a/clients/aurorae/src/lib/auroraetheme.cpp b/clients/aurorae/src/lib/auroraetheme.cpp index 910305f840..5628ddcce1 100644 --- a/clients/aurorae/src/lib/auroraetheme.cpp +++ b/clients/aurorae/src/lib/auroraetheme.cpp @@ -45,16 +45,16 @@ public: Aurorae::ThemeConfig themeConfig; QHash< AuroraeButtonType, QString > pathes; bool activeCompositing; - AuroraeTheme::BorderSize borderSize; - AuroraeTheme::BorderSize buttonSize; + KDecoration2::BorderSize borderSize; + KDecoration2::BorderSize buttonSize; QString dragMimeType; QString decorationPath; }; AuroraeThemePrivate::AuroraeThemePrivate() :activeCompositing(true) - , borderSize(AuroraeTheme::BorderNormal) - , buttonSize(AuroraeTheme::BorderNormal) + , borderSize(KDecoration2::BorderSize::Normal) + , buttonSize(KDecoration2::BorderSize::Normal) { } @@ -106,8 +106,6 @@ void AuroraeTheme::loadTheme(const QString &name) KConfig::FullConfig, QStandardPaths::GenericDataLocation); KConfigGroup themeGroup(&conf, name); loadTheme(name, config); - setBorderSize((BorderSize)themeGroup.readEntry("BorderSize", BorderNormal)); - setButtonSize((BorderSize)themeGroup.readEntry("ButtonSize", BorderNormal)); } void AuroraeTheme::loadTheme(const QString &name, const KConfig &config) @@ -211,7 +209,7 @@ void AuroraeTheme::borders(int& left, int& top, int& right, int& bottom, bool ma } } else { switch (d->borderSize) { - case BorderTiny: + case KDecoration2::BorderSize::Tiny: // TODO: this looks wrong if (isCompositingActive()) { left = qMin(0, (int)left - d->themeConfig.borderLeft() - d->themeConfig.paddingLeft()); @@ -223,22 +221,22 @@ void AuroraeTheme::borders(int& left, int& top, int& right, int& bottom, bool ma bottom = qMin(0, (int)bottom - d->themeConfig.borderBottom()); } break; - case BorderLarge: + case KDecoration2::BorderSize::Large: left = right = bottom = top = 4; break; - case BorderVeryLarge: + case KDecoration2::BorderSize::VeryLarge: left = right = bottom = top = 8; break; - case BorderHuge: + case KDecoration2::BorderSize::Huge: left = right = bottom = top = 12; break; - case BorderVeryHuge: + case KDecoration2::BorderSize::VeryHuge: left = right = bottom = top = 23; break; - case BorderOversized: + case KDecoration2::BorderSize::Oversized: left = right = bottom = top = 36; break; - case BorderNormal: + case KDecoration2::BorderSize::Normal: default: left = right = bottom = top = 0; } @@ -450,7 +448,7 @@ void AuroraeTheme::setCompositingActive(bool active) d->activeCompositing = active; } -void AuroraeTheme::setBorderSize(BorderSize size) +void AuroraeTheme::setBorderSize(KDecoration2::BorderSize size) { if (d->borderSize == size) { return; @@ -459,7 +457,7 @@ void AuroraeTheme::setBorderSize(BorderSize size) emit borderSizesChanged(); } -void AuroraeTheme::setButtonSize(BorderSize size) +void AuroraeTheme::setButtonSize(KDecoration2::BorderSize size) { if (d->buttonSize == size) { return; @@ -481,19 +479,19 @@ const QString &AuroraeTheme::tabDragMimeType() const qreal AuroraeTheme::buttonSizeFactor() const { switch (d->buttonSize) { - case BorderTiny: + case KDecoration2::BorderSize::Tiny: return 0.8; - case BorderLarge: + case KDecoration2::BorderSize::Large: return 1.2; - case BorderVeryLarge: + case KDecoration2::BorderSize::VeryLarge: return 1.4; - case BorderHuge: + case KDecoration2::BorderSize::Huge: return 1.6; - case BorderVeryHuge: + case KDecoration2::BorderSize::VeryHuge: return 1.8; - case BorderOversized: + case KDecoration2::BorderSize::Oversized: return 2.0; - case BorderNormal: // fall through + case KDecoration2::BorderSize::Normal: // fall through default: return 1.0; } diff --git a/clients/aurorae/src/lib/auroraetheme.h b/clients/aurorae/src/lib/auroraetheme.h index 573b8bf598..f3f7b99432 100644 --- a/clients/aurorae/src/lib/auroraetheme.h +++ b/clients/aurorae/src/lib/auroraetheme.h @@ -27,6 +27,8 @@ #include +#include + Q_DECLARE_LOGGING_CATEGORY(AURORAE) class KConfig; @@ -113,18 +115,6 @@ class /*LIBAURORAE_EXPORT*/ AuroraeTheme : public QObject Q_PROPERTY(Qt::Alignment horizontalAlignment READ alignment NOTIFY themeChanged) Q_PROPERTY(Qt::Alignment verticalAlignment READ verticalAlignment NOTIFY themeChanged) public: - enum BorderSize { - BorderTiny, ///< Minimal borders - BorderNormal, ///< Standard size borders, the default setting - BorderLarge, ///< Larger borders - BorderVeryLarge, ///< Very large borders - BorderHuge, ///< Huge borders - BorderVeryHuge, ///< Very huge borders - BorderOversized, ///< Oversized borders - BorderNoSides, ///< No borders on sides @since 4.11 - BorderNone, ///< No borders except title @since 4.11 - BordersCount ///< @internal - }; explicit AuroraeTheme(QObject* parent = nullptr); virtual ~AuroraeTheme(); // TODO: KSharedConfigPtr @@ -194,13 +184,13 @@ public: * @returns true if the theme contains a FrameSvg for specified button. */ bool hasButton(AuroraeButtonType button) const; - void setBorderSize(BorderSize size); + void setBorderSize(KDecoration2::BorderSize size); /** * Sets the size of the buttons. * The available sizes are identical to border sizes, therefore BorderSize is used. * @param size The buttons size */ - void setButtonSize(BorderSize size); + void setButtonSize(KDecoration2::BorderSize size); qreal buttonSizeFactor() const; DecorationPosition decorationPosition() const; diff --git a/clients/aurorae/src/qml/aurorae.qml b/clients/aurorae/src/qml/aurorae.qml index fe688e18d8..ecf567cd0e 100644 --- a/clients/aurorae/src/qml/aurorae.qml +++ b/clients/aurorae/src/qml/aurorae.qml @@ -22,14 +22,14 @@ Decoration { id: root property bool animate: false Component.onCompleted: { - borders.left = Math.max(0, auroraeTheme.borderLeft); - borders.right = Math.max(0, auroraeTheme.borderRight); - borders.top = Math.max(0, auroraeTheme.borderTop); - borders.bottom = Math.max(0, auroraeTheme.borderBottom); - maximizedBorders.left = Math.max(0, auroraeTheme.borderLeftMaximized); - maximizedBorders.right = Math.max(0, auroraeTheme.borderRightMaximized); - maximizedBorders.bottom = Math.max(0, auroraeTheme.borderBottomMaximized); - maximizedBorders.top = Math.max(0, auroraeTheme.borderTopMaximized); + borders.left = Qt.binding(function() { return Math.max(0, auroraeTheme.borderLeft);}); + borders.right = Qt.binding(function() { return Math.max(0, auroraeTheme.borderRight);}); + borders.top = Qt.binding(function() { return Math.max(0, auroraeTheme.borderTop);}); + borders.bottom = Qt.binding(function() { return Math.max(0, auroraeTheme.borderBottom);}); + maximizedBorders.left = Qt.binding(function() { return Math.max(0, auroraeTheme.borderLeftMaximized);}); + maximizedBorders.right = Qt.binding(function() { return Math.max(0, auroraeTheme.borderRightMaximized);}); + maximizedBorders.bottom = Qt.binding(function() { return Math.max(0, auroraeTheme.borderBottomMaximized);}); + maximizedBorders.top = Qt.binding(function() { return Math.max(0, auroraeTheme.borderTopMaximized);}); padding.left = auroraeTheme.paddingLeft; padding.right = auroraeTheme.paddingRight; padding.bottom = auroraeTheme.paddingBottom;