port screenedge effect to KSvg
Part of https://invent.kde.org/frameworks/ksvg/-/issues/1. Port the linked usage of Plasma::Svg to KSvg::Svg, still syncing with the Plasma style.
This commit is contained in:
parent
bb18d9fbac
commit
54b3c2c6b6
4 changed files with 35 additions and 7 deletions
|
@ -82,7 +82,6 @@ find_package(KF6 ${KF6_MIN_VERSION} REQUIRED COMPONENTS
|
|||
I18n
|
||||
IdleTime
|
||||
Package
|
||||
Plasma
|
||||
Service
|
||||
Svg
|
||||
WidgetsAddons
|
||||
|
@ -136,7 +135,13 @@ add_feature_info("KF6Runner" KF6Runner_FOUND "Enable building of KWin with krunn
|
|||
find_package(KF6Kirigami2 ${KF6_MIN_VERSION} CONFIG)
|
||||
set_package_properties(KF6Kirigami2 PROPERTIES
|
||||
DESCRIPTION "A QtQuick based components set"
|
||||
PURPOSE "Required at runtime for Virtual desktop KCM"
|
||||
PURPOSE "Required at runtime for several QML effects"
|
||||
TYPE RUNTIME
|
||||
)
|
||||
find_package(KF6Plasma ${KF6_MIN_VERSION} CONFIG)
|
||||
set_package_properties(KF6Plasma PROPERTIES
|
||||
DESCRIPTION "A QtQuick based components set"
|
||||
PURPOSE "Required at runtime for several QML effects"
|
||||
TYPE RUNTIME
|
||||
)
|
||||
|
||||
|
|
|
@ -12,5 +12,6 @@ target_link_libraries(screenedge PRIVATE
|
|||
kwineffects
|
||||
kwinglutils
|
||||
|
||||
KF6::Plasma
|
||||
KF6::Svg
|
||||
KF6::ConfigCore
|
||||
)
|
||||
|
|
|
@ -13,8 +13,11 @@
|
|||
#include "libkwineffects/rendertarget.h"
|
||||
#include "libkwineffects/renderviewport.h"
|
||||
// KDE
|
||||
#include <Plasma/Svg>
|
||||
#include <KConfigGroup>
|
||||
#include <KSharedConfig>
|
||||
#include <KSvg/Svg>
|
||||
// Qt
|
||||
#include <QFile>
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
#include <QVector4D>
|
||||
|
@ -45,7 +48,23 @@ ScreenEdgeEffect::~ScreenEdgeEffect()
|
|||
void ScreenEdgeEffect::ensureGlowSvg()
|
||||
{
|
||||
if (!m_glow) {
|
||||
m_glow = new Plasma::Svg(this);
|
||||
m_glow = new KSvg::Svg(this);
|
||||
m_glow->imageSet()->setBasePath(QStringLiteral("plasma/desktoptheme"));
|
||||
|
||||
const QString groupName = QStringLiteral("Theme");
|
||||
KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasmarc"));
|
||||
KConfigGroup cg = KConfigGroup(config, groupName);
|
||||
m_glow->imageSet()->setImageSetName(cg.readEntry("name", QStringLiteral("default")));
|
||||
|
||||
m_configWatcher = KConfigWatcher::create(config);
|
||||
|
||||
connect(m_configWatcher.data(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &group, const QByteArrayList &names) {
|
||||
if (group.name() != QStringLiteral("Theme") || !names.contains(QStringLiteral("name"))) {
|
||||
return;
|
||||
}
|
||||
m_glow->imageSet()->setImageSetName(group.readEntry("name", QStringLiteral("default")));
|
||||
});
|
||||
|
||||
m_glow->setImagePath(QStringLiteral("widgets/glowbar"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
#pragma once
|
||||
#include "libkwineffects/kwineffects.h"
|
||||
|
||||
#include <KConfigWatcher>
|
||||
|
||||
class QTimer;
|
||||
namespace Plasma
|
||||
namespace KSvg
|
||||
{
|
||||
class Svg;
|
||||
}
|
||||
|
@ -45,7 +47,8 @@ private:
|
|||
QImage createCornerGlow(ElectricBorder border);
|
||||
QImage createEdgeGlow(ElectricBorder border, const QSize &size);
|
||||
QSize cornerGlowSize(ElectricBorder border);
|
||||
Plasma::Svg *m_glow = nullptr;
|
||||
KConfigWatcher::Ptr m_configWatcher;
|
||||
KSvg::Svg *m_glow = nullptr;
|
||||
std::map<ElectricBorder, std::unique_ptr<Glow>> m_borders;
|
||||
QTimer *m_cleanupTimer;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue