diff options
Diffstat (limited to 'plugin')
| -rw-r--r-- | plugin/src/Caelestia/Internal/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | plugin/src/Caelestia/Internal/logindmanager.cpp | 65 | ||||
| -rw-r--r-- | plugin/src/Caelestia/Internal/logindmanager.hpp | 27 | ||||
| -rw-r--r-- | plugin/src/Caelestia/cutils.cpp | 2 |
4 files changed, 1 insertions, 94 deletions
diff --git a/plugin/src/Caelestia/Internal/CMakeLists.txt b/plugin/src/Caelestia/Internal/CMakeLists.txt index 0240de8..d0b7548 100644 --- a/plugin/src/Caelestia/Internal/CMakeLists.txt +++ b/plugin/src/Caelestia/Internal/CMakeLists.txt @@ -4,7 +4,6 @@ qml_module(caelestia-internal circularindicatormanager.hpp circularindicatormanager.cpp hyprdevices.hpp hyprdevices.cpp hyprextras.hpp hyprextras.cpp - logindmanager.hpp logindmanager.cpp LIBRARIES Qt::Gui Qt::Quick diff --git a/plugin/src/Caelestia/Internal/logindmanager.cpp b/plugin/src/Caelestia/Internal/logindmanager.cpp deleted file mode 100644 index 4194ee1..0000000 --- a/plugin/src/Caelestia/Internal/logindmanager.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "logindmanager.hpp" - -#include <QtDBus/qdbusconnection.h> -#include <QtDBus/qdbuserror.h> -#include <QtDBus/qdbusinterface.h> -#include <QtDBus/qdbusreply.h> - -namespace caelestia::internal { - -LogindManager::LogindManager(QObject* parent) - : QObject(parent) { - auto bus = QDBusConnection::systemBus(); - if (!bus.isConnected()) { - qWarning() << "LogindManager::LogindManager: failed to connect to system bus:" << bus.lastError().message(); - return; - } - - bool ok = bus.connect("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", - "PrepareForSleep", this, SLOT(handlePrepareForSleep(bool))); - - if (!ok) { - qWarning() << "LogindManager::LogindManager: failed to connect to PrepareForSleep signal:" - << bus.lastError().message(); - } - - QDBusInterface login1("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", bus); - const QDBusReply<QDBusObjectPath> reply = login1.call("GetSession", "auto"); - if (!reply.isValid()) { - qWarning() << "LogindManager::LogindManager: failed to get session path"; - return; - } - const auto sessionPath = reply.value().path(); - - ok = bus.connect("org.freedesktop.login1", sessionPath, "org.freedesktop.login1.Session", "Lock", this, - SLOT(handleLockRequested())); - - if (!ok) { - qWarning() << "LogindManager::LogindManager: failed to connect to Lock signal:" << bus.lastError().message(); - } - - ok = bus.connect("org.freedesktop.login1", sessionPath, "org.freedesktop.login1.Session", "Unlock", this, - SLOT(handleUnlockRequested())); - - if (!ok) { - qWarning() << "LogindManager::LogindManager: failed to connect to Unlock signal:" << bus.lastError().message(); - } -} - -void LogindManager::handlePrepareForSleep(bool sleep) { - if (sleep) { - emit aboutToSleep(); - } else { - emit resumed(); - } -} - -void LogindManager::handleLockRequested() { - emit lockRequested(); -} - -void LogindManager::handleUnlockRequested() { - emit unlockRequested(); -} - -} // namespace caelestia::internal diff --git a/plugin/src/Caelestia/Internal/logindmanager.hpp b/plugin/src/Caelestia/Internal/logindmanager.hpp deleted file mode 100644 index 72a3401..0000000 --- a/plugin/src/Caelestia/Internal/logindmanager.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include <qobject.h> -#include <qqmlintegration.h> - -namespace caelestia::internal { - -class LogindManager : public QObject { - Q_OBJECT - QML_ELEMENT - -public: - explicit LogindManager(QObject* parent = nullptr); - -signals: - void aboutToSleep(); - void resumed(); - void lockRequested(); - void unlockRequested(); - -private slots: - void handlePrepareForSleep(bool sleep); - void handleLockRequested(); - void handleUnlockRequested(); -}; - -} // namespace caelestia::internal diff --git a/plugin/src/Caelestia/cutils.cpp b/plugin/src/Caelestia/cutils.cpp index 0e1778c..6e3bfa9 100644 --- a/plugin/src/Caelestia/cutils.cpp +++ b/plugin/src/Caelestia/cutils.cpp @@ -100,7 +100,7 @@ bool CUtils::copyFile(const QUrl& source, const QUrl& target, bool overwrite) co return false; } - if (overwrite) { + if (overwrite && QFile::exists(target.toLocalFile())) { if (!QFile::remove(target.toLocalFile())) { qWarning() << "CUtils::copyFile: overwrite was specified but failed to remove" << target.toLocalFile(); return false; |