SuspendSession::SuspendSession(QObject* parent) : Action(parent), m_fadeEffect(new PowerDevil::KWinKScreenHelperEffect()) { // DBus new SuspendSessionAdaptor(this); setRequiredPolicies(PowerDevil::PolicyAgent::InterruptSession); connect(backend(), &PowerDevil::BackendInterface::resumeFromSuspend, this, [this]() { KIdleTime::instance()->simulateUserActivity(); PowerDevil::PolicyAgent::instance()->setupSystemdInhibition(); m_fadeEffect->stop(); Q_EMIT resumingFromSuspend(); }); connect(m_fadeEffect.data(), &PowerDevil::KWinKScreenHelperEffect::fadedOut, this, [this]() { if (!m_savedArgs.isEmpty()) { QVariantMap args = m_savedArgs; args["SkipFade"] = true; triggerImpl(args); } }); }
Device::Device(QObject* parent) : QObject(parent) , m_isReady(false) , m_isLaptop(false) , m_isLidClosed(false) , m_isDocked(false) { m_freedesktop = new OrgFreedesktopDBusPropertiesInterface(QStringLiteral("org.freedesktop.UPower"), QStringLiteral("/org/freedesktop/UPower"), QDBusConnection::systemBus(), this); if (!m_freedesktop->isValid()) { qCWarning(KSCREEN_KDED) << "UPower not available, lid detection won't work"; qCDebug(KSCREEN_KDED) << m_freedesktop->lastError().message(); } else { QDBusConnection::systemBus().connect(QStringLiteral("org.freedesktop.UPower"), QStringLiteral("/org/freedesktop/UPower"), QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"), this, SLOT(changed())); fetchIsLaptop(); } m_suspendSession = new QDBusInterface(QStringLiteral("org.kde.Solid.PowerManagement"), QStringLiteral("/org/kde/Solid/PowerManagement/Actions/SuspendSession"), QStringLiteral("org.kde.Solid.PowerManagement.Actions.SuspendSession"), QDBusConnection::sessionBus(), this); if (m_suspendSession->isValid()) { connect(m_suspendSession, SIGNAL(resumingFromSuspend()), this, SIGNAL(resumingFromSuspend())); connect(m_suspendSession, SIGNAL(aboutToSuspend()), this, SIGNAL(aboutToSuspend())); } else { qCWarning(KSCREEN_KDED) << "PowerDevil SuspendSession action not available!"; qCDebug(KSCREEN_KDED) << m_suspendSession->lastError().message(); } fetchIsLaptop(); }
AccountManager::AccountManager() : QObject( qApp ), d(new Private()) { setObjectName( "KopeteAccountManager" ); connect( Solid::Networking::notifier(), SIGNAL(shouldConnect()), this, SLOT(networkConnected()) ); connect( Solid::Networking::notifier(), SIGNAL(shouldDisconnect()), this, SLOT(networkDisconnected()) ); connect( Solid::PowerManagement::notifier(), SIGNAL(resumingFromSuspend()), this, SLOT(resume()) ); #ifdef __GNUC__ #warning TODO: Switch to a org.kde.Solid.PowerManagement Sleeping/Suspending signal when available. #endif QDBusConnection::systemBus().connect( "org.freedesktop.UPower", "/org/freedesktop/UPower", "", "Sleeping", this, SLOT( suspend() ) ); d->suspended = false; }