Commit a7c396ca authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[ScreenEdgeEffect] Create glow Svg on demand

Keeps it from loading the Svg and all the Plasma stuff (Theme etc) that comes with it on startup.

Differential Revision: https://phabricator.kde.org/D8011
parent 38ce05ea
......@@ -37,10 +37,8 @@ namespace KWin {
ScreenEdgeEffect::ScreenEdgeEffect()
: Effect()
, m_glow(new Plasma::Svg(this))
, m_cleanupTimer(new QTimer(this))
{
m_glow->setImagePath(QStringLiteral("widgets/glowbar"));
connect(effects, SIGNAL(screenEdgeApproaching(ElectricBorder,qreal,QRect)), SLOT(edgeApproaching(ElectricBorder,qreal,QRect)));
m_cleanupTimer->setInterval(5000);
m_cleanupTimer->setSingleShot(true);
......@@ -59,6 +57,14 @@ ScreenEdgeEffect::~ScreenEdgeEffect()
cleanup();
}
void ScreenEdgeEffect::ensureGlowSvg()
{
if (!m_glow) {
m_glow = new Plasma::Svg(this);
m_glow->setImagePath(QStringLiteral("widgets/glowbar"));
}
}
void ScreenEdgeEffect::cleanup()
{
for (QHash<ElectricBorder, Glow*>::iterator it = m_borders.begin();
......@@ -263,6 +269,8 @@ Glow *ScreenEdgeEffect::createGlow(ElectricBorder border, qreal factor, const QR
template <typename T>
T *ScreenEdgeEffect::createCornerGlow(ElectricBorder border)
{
ensureGlowSvg();
switch (border) {
case ElectricTopLeft:
return new T(m_glow->pixmap(QStringLiteral("bottomright")).toImage());
......@@ -277,8 +285,10 @@ T *ScreenEdgeEffect::createCornerGlow(ElectricBorder border)
}
}
QSize ScreenEdgeEffect::cornerGlowSize(ElectricBorder border) const
QSize ScreenEdgeEffect::cornerGlowSize(ElectricBorder border)
{
ensureGlowSvg();
switch (border) {
case ElectricTopLeft:
return m_glow->elementSize(QStringLiteral("bottomright"));
......@@ -296,6 +306,8 @@ QSize ScreenEdgeEffect::cornerGlowSize(ElectricBorder border) const
template <typename T>
T *ScreenEdgeEffect::createEdgeGlow(ElectricBorder border, const QSize &size)
{
ensureGlowSvg();
QPoint pixmapPosition(0, 0);
QPixmap l, r, c;
switch (border) {
......
......@@ -48,13 +48,14 @@ private Q_SLOTS:
void edgeApproaching(ElectricBorder border, qreal factor, const QRect &geometry);
void cleanup();
private:
void ensureGlowSvg();
Glow *createGlow(ElectricBorder border, qreal factor, const QRect &geometry);
template <typename T>
T *createCornerGlow(ElectricBorder border);
template <typename T>
T *createEdgeGlow(ElectricBorder border, const QSize &size);
QSize cornerGlowSize(ElectricBorder border) const;
Plasma::Svg *m_glow;
QSize cornerGlowSize(ElectricBorder border);
Plasma::Svg *m_glow = nullptr;
QHash<ElectricBorder, Glow*> m_borders;
QTimer *m_cleanupTimer;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment