Commit 4e30c7b6 authored by Volker Krause's avatar Volker Krause

Move screen lock explanation message to user code

parent 5e2b59e3
......@@ -34,7 +34,7 @@ Rectangle {
anchors.fill: parent
onDoubleClicked: {
_brightnessManager.toggleBrightness()
_lockManager.toggleInhibitScreenLock()
_lockManager.toggleInhibitScreenLock(i18n("In barcode scanning mode"))
}
}
......
......@@ -81,7 +81,7 @@ ColumnLayout {
anchors.fill: parent
onDoubleClicked: {
_brightnessManager.toggleBrightness()
_lockManager.toggleInhibitScreenLock()
_lockManager.toggleInhibitScreenLock(i18n("In barcode scanning mode"))
}
}
......
......@@ -23,6 +23,5 @@ target_link_libraries(SolidExtras PUBLIC Qt5::Core)
if (ANDROID)
target_link_libraries(SolidExtras PRIVATE Qt5::AndroidExtras)
else()
# TODO i18n code needs to move to the user code
target_link_libraries(SolidExtras PRIVATE Qt5::DBus KF5::I18n)
target_link_libraries(SolidExtras PRIVATE Qt5::DBus)
endif()
......@@ -35,7 +35,8 @@ void AndroidLockBackend::setInhibitionOff()
QAndroidJniObject::callStaticMethod<void>("org.kde.solid.Solid", "setLockInhibitionOff", "(Landroid/app/Activity;)V", QtAndroid::androidActivity().object());
}
void AndroidLockBackend::setInhibitionOn()
void AndroidLockBackend::setInhibitionOn(const QString &explanation)
{
Q_UNUSED(explanation);
QAndroidJniObject::callStaticMethod<void>("org.kde.solid.Solid", "setLockInhibitionOn", "(Landroid/app/Activity;)V", QtAndroid::androidActivity().object());
}
......@@ -30,7 +30,7 @@ public:
virtual ~AndroidLockBackend();
void setInhibitionOff() override;
void setInhibitionOn() override;
void setInhibitionOn(const QString &explanation) override;
};
#endif // ANDROIDBRIGHTNESSBACKEND_H
......
......@@ -38,7 +38,7 @@ LockManager::LockManager(QObject *parent)
LockManager::~LockManager() = default;
void LockManager::toggleInhibitScreenLock()
void LockManager::toggleInhibitScreenLock(const QString &explanation)
{
if (!m_backend)
return;
......@@ -46,7 +46,7 @@ void LockManager::toggleInhibitScreenLock()
if (m_inhibit) {
m_backend->setInhibitionOff();
} else {
m_backend->setInhibitionOn();
m_backend->setInhibitionOn(explanation);
}
m_inhibit = !m_inhibit;
}
......@@ -26,7 +26,7 @@ public:
explicit LockBackend(QObject *parent = nullptr) : QObject(parent)
{}
virtual ~LockBackend() = default;
virtual void setInhibitionOn() = 0;
virtual void setInhibitionOn(const QString &explanation) = 0;
virtual void setInhibitionOff() = 0;
};
......@@ -39,7 +39,11 @@ public:
~LockManager();
public Q_SLOTS:
void toggleInhibitScreenLock();
/** Toggle screen lock inhibition.
* @param explanation A human-readable explanation on why the screen lock is inhibited.
* (not used on all platforms).
*/
void toggleInhibitScreenLock(const QString &explanation);
private:
LockBackend *m_backend;
bool m_inhibit;
......
......@@ -19,8 +19,6 @@
#include "screensaverdbusinterface.h"
#include <KLocalizedString>
#include <QDBusConnection>
SolidLockBackend::SolidLockBackend(QObject *parent)
......@@ -35,8 +33,8 @@ void SolidLockBackend::setInhibitionOff()
m_iface->UnInhibit(m_cookie);
}
void SolidLockBackend::setInhibitionOn()
void SolidLockBackend::setInhibitionOn(const QString &explanation)
{
m_cookie = m_iface->Inhibit(QStringLiteral("org.kde.itinerary"), i18n("In barcode scanning mode"));
m_cookie = m_iface->Inhibit(QStringLiteral("org.kde.itinerary"), explanation);
}
......@@ -30,7 +30,7 @@ public:
explicit SolidLockBackend(QObject *parent = nullptr);
void setInhibitionOff() override;
void setInhibitionOn() override;
void setInhibitionOn(const QString &explanation) override;
private:
OrgFreedesktopScreenSaverInterface* m_iface;
......
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