plasma theme extended:separator area margins

--discover and expose plasma theme margins for
separator areas
work/spdx
Michail Vourlakos 4 years ago
parent 7f9f418b75
commit 674b6ea754

@ -91,6 +91,7 @@ void Theme::load()
{
loadThemePaths();
updateBackgrounds();
updateSeperatorAreaMarginsValues();
}
Theme::~Theme()
@ -131,6 +132,27 @@ void Theme::setOutlineWidth(int width)
emit outlineWidthChanged();
}
int Theme::separatorAreaMarginTop() const
{
return m_separatorAreaMarginTop;
}
int Theme::separatorAreaMarginLeft() const
{
return m_separatorAreaMarginLeft;
}
int Theme::separatorAreaMarginBottom() const
{
return m_separatorAreaMarginBottom;
}
int Theme::separatorAreaMarginRight() const
{
return m_separatorAreaMarginRight;
}
PanelBackground *Theme::backgroundTopEdge() const
{
return m_backgroundTopEdge;
@ -485,6 +507,44 @@ const CornerRegions &Theme::cornersMask(const int &radius)
return m_cornerRegions[radius];
}
void Theme::updateSeperatorAreaMarginsValues()
{
m_separatorAreaMarginTop = 0;
m_separatorAreaMarginLeft = 0;
m_separatorAreaMarginBottom = 0;
m_separatorAreaMarginRight = 0;
Plasma::Svg *svg = new Plasma::Svg(this);
svg->setImagePath(QStringLiteral("widgets/panel-background"));
bool hasThickSeparatorMargins = svg->hasElement("thick-center");
if (hasThickSeparatorMargins) {
int topMargin = svg->hasElement("hint-top-margin") ? svg->elementSize("hint-top-margin").height() : 0;
int leftMargin = svg->hasElement("hint-left-margin") ? svg->elementSize("hint-left-margin").width() : 0;
int bottomMargin = svg->hasElement("hint-bottom-margin") ? svg->elementSize("hint-bottom-margin").height() : 0;
int rightMargin = svg->hasElement("hint-right-margin") ? svg->elementSize("hint-right-margin").width() : 0;
int thickTopMargin = svg->hasElement("thick-hint-top-margin") ? svg->elementSize("thick-hint-top-margin").height() : 0;
int thickLeftMargin = svg->hasElement("thick-hint-left-margin") ? svg->elementSize("thick-hint-left-margin").width() : 0;
int thickBottomMargin = svg->hasElement("thick-hint-bottom-margin") ? svg->elementSize("thick-hint-bottom-margin").height() : 0;
int thickRightMargin = svg->hasElement("thick-hint-right-margin") ? svg->elementSize("thick-hint-right-margin").width() : 0;
m_separatorAreaMarginTop = qMax(0, thickTopMargin - topMargin);
m_separatorAreaMarginLeft = qMax(0, thickLeftMargin - leftMargin);
m_separatorAreaMarginBottom = qMax(0, thickBottomMargin - bottomMargin);
m_separatorAreaMarginRight = qMax(0, thickRightMargin - rightMargin);
}
qDebug() << "PLASMA THEME SEPARATOR AREA MARGINS ::" <<
m_separatorAreaMarginTop << m_separatorAreaMarginLeft <<
m_separatorAreaMarginBottom << m_separatorAreaMarginRight;
svg->deleteLater();
emit separatorAreaMarginsChanged();
}
void Theme::loadConfig()
{
setOutlineWidth(m_themeGroup.readEntry("outlineWidth", 1));

@ -69,6 +69,11 @@ class Theme: public QObject
Q_PROPERTY(int outlineWidth READ outlineWidth NOTIFY outlineWidthChanged)
Q_PROPERTY(int separatorAreaMarginTop READ separatorAreaMarginTop NOTIFY separatorAreaMarginsChanged)
Q_PROPERTY(int separatorAreaMarginLeft READ separatorAreaMarginLeft NOTIFY separatorAreaMarginsChanged)
Q_PROPERTY(int separatorAreaMarginBottom READ separatorAreaMarginBottom NOTIFY separatorAreaMarginsChanged)
Q_PROPERTY(int separatorAreaMarginRight READ separatorAreaMarginRight NOTIFY separatorAreaMarginsChanged)
Q_PROPERTY(Latte::PlasmaExtended::PanelBackground *backgroundTopEdge READ backgroundTopEdge NOTIFY backgroundsChanged)
Q_PROPERTY(Latte::PlasmaExtended::PanelBackground *backgroundLeftEdge READ backgroundLeftEdge NOTIFY backgroundsChanged)
Q_PROPERTY(Latte::PlasmaExtended::PanelBackground *backgroundBottomEdge READ backgroundBottomEdge NOTIFY backgroundsChanged)
@ -89,6 +94,11 @@ public:
int outlineWidth() const;
void setOutlineWidth(int width);
int separatorAreaMarginTop() const;
int separatorAreaMarginLeft() const;
int separatorAreaMarginBottom() const;
int separatorAreaMarginRight() const;
PanelBackground *backgroundTopEdge() const;
PanelBackground *backgroundLeftEdge() const;
PanelBackground *backgroundBottomEdge() const;
@ -107,6 +117,7 @@ signals:
void compositingChanged();
void hasShadowChanged();
void outlineWidthChanged();
void separatorAreaMarginsChanged();
void themeChanged();
private slots:
@ -125,6 +136,7 @@ private:
void updateDefaultSchemeValues();
void updateReversedScheme();
void updateReversedSchemeValues();
void updateSeperatorAreaMarginsValues();
void qmlRegisterTypes();
@ -135,6 +147,11 @@ private:
int m_outlineWidth{1};
int m_separatorAreaMarginTop{0};
int m_separatorAreaMarginLeft{0};
int m_separatorAreaMarginBottom{0};
int m_separatorAreaMarginRight{0};
QString m_themePath;
QString m_themeWidgetsPath;
QString m_defaultSchemePath;

Loading…
Cancel
Save