Commit fdbba676 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Handle fallback packages when checking for screenlocker API version

The current lookandfeel package may not contain the
"X-Plasma-ApiVersion" metadata key but at the same time also not define
a custom lockscreen, instead relying on the fallback mechanism. In that
case, we would end up setting the package path to an empty string,
causing everything else that is using the package to treat it as
invalid.

To fix that, we need to check if the lockscreen comes from the current
package and if not, check the API version of the fallback package
instead. Additionally, we also should explicitly set the package path to
the default of Breeze instead of using an empty string as path, which
implies an invalid package rather than "use the default".
parent 8dbec4a1
Pipeline #184427 passed with stage
in 2 minutes and 14 seconds
......@@ -101,6 +101,25 @@ void disableDrKonqi()
// that would enable drkonqi
Q_CONSTRUCTOR_FUNCTION(disableDrKonqi)
// Verify that a package or its fallback is using the right API
bool verifyPackageApi(const KPackage::Package &package)
{
if (package.metadata().value("X-Plasma-APIVersion", QStringLiteral("1")).toInt() >= 2) {
return true;
}
if (!package.filePath("lockscreenmainscript").contains(package.path())) {
// The current package does not contain the lock screen and we are
// using the fallback package. So check to see if that package has
// the right version instead.
if (package.fallbackPackage().metadata().value("X-Plasma-APIVersion", QStringLiteral("1")).toInt() >= 2) {
return true;
}
}
return false;
}
class FocusOutEventFilter : public QAbstractNativeEventFilter
{
public:
......@@ -186,10 +205,9 @@ void UnlockApp::initialize()
if (!KScreenSaverSettingsBase::theme().isEmpty()) {
package.setPath(KScreenSaverSettingsBase::theme());
}
QString plasmaApiVersion = package.metadata().value("X-Plasma-APIVersion", QStringLiteral("1"));
if (plasmaApiVersion.toInt() <= 1) {
if (!verifyPackageApi(package)) {
qCWarning(KSCREENLOCKER_GREET) << "Lockscreen QML outdated, falling back to default";
package.setPath(QString());
package.setPath(QStringLiteral("org.kde.breeze.desktop"));
}
m_mainQmlPath = package.fileUrl("lockscreenmainscript");
......
Supports Markdown
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