[aurorae] Fix BorderSize for SVG based themes

This commit is contained in:
Martin Gräßlin 2014-12-05 17:36:25 +01:00
parent f6a01c134e
commit d26b5a1739
4 changed files with 34 additions and 45 deletions

View file

@ -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<int>("BorderSize", KDecorationDefines::BorderNormal));
theme->setBorderSize(s->borderSize());
connect(s.data(), &KDecoration2::DecorationSettings::borderSizeChanged, theme, &AuroraeTheme::setBorderSize);
// m_theme->setButtonSize((KDecorationDefines::BorderSize)themeGroup.readEntry<int>("ButtonSize", KDecorationDefines::BorderNormal));
// m_theme->setTabDragMimeType(tabDragMimeType());
context->setContextProperty(QStringLiteral("auroraeTheme"), theme);

View file

@ -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<int>("BorderSize", BorderNormal));
setButtonSize((BorderSize)themeGroup.readEntry<int>("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;
}

View file

@ -27,6 +27,8 @@
#include <QLoggingCategory>
#include <KDecoration2/DecorationButton>
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;

View file

@ -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;