void StatusBar::setupConnections() { SysStatus & sys_status = SysStatus::instance(); connect(&sys_status, SIGNAL(batterySignal(int, int)), this, SLOT(onBatterySignal(int, int))); connect(&sys_status, SIGNAL(aboutToSuspend()), this, SLOT(onAboutToSuspend())); connect(&sys_status, SIGNAL(lowBatterySignal()), this, SLOT(onLowBatterySignal())); connect(&sys_status, SIGNAL(wakeup()), this, SLOT(onWakeup())); connect(&sys_status, SIGNAL(aboutToShutdown()), this, SLOT(onAboutToShutdown())); connect(&sys_status, SIGNAL(sdioChangedSignal(bool)), this, SLOT(onWifiDeviceChanged(bool))); connect(&sys_status, SIGNAL(stylusChanged(bool)), this, SLOT(onStylusChanged(bool))); connect(&sys_status, SIGNAL(connectToPC(bool)), this, SLOT(onConnectToPC(bool))); connect(&sys_status, SIGNAL(volumeUpPressed()), this, SLOT(onVolumeButtonsPressed())); connect(&sys_status, SIGNAL(volumeDownPressed()), this, SLOT(onVolumeButtonsPressed())); connect(&sys_status, SIGNAL(report3GNetwork(const int, const int, const int)), this, SLOT(onReport3GNetwork(const int, const int, const int))); connect(&sys_status, SIGNAL(pppConnectionChanged(const QString &, int)), this, SLOT(onPppConnectionChanged(const QString &, int))); // connect configure keyboard signal connect(&sys_status, SIGNAL(configKeyboard()), this, SLOT(onConfigKeyboard())); }
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(); }
void SuspendSession::triggerImpl(const QVariantMap &args) { qCDebug(POWERDEVIL) << "Suspend session triggered with" << args; const auto mode = static_cast<Mode>(args["Type"].toUInt()); if (mode == ToRamMode || mode == ToDiskMode || mode == SuspendHybridMode) { // don't suspend if shutting down if (KWorkSpace::isShuttingDown()) { qCDebug(POWERDEVIL) << "Not suspending because a shutdown is in progress"; return; } if (!args["SkipFade"].toBool()) { m_savedArgs = args; m_fadeEffect->start(); return; } } if (args["GraceFade"].toBool()) { return; } // Switch for real action KJob *suspendJob = 0; switch ((Mode) (args["Type"].toUInt())) { case ToRamMode: Q_EMIT aboutToSuspend(); suspendJob = backend()->suspend(PowerDevil::BackendInterface::ToRam); break; case ToDiskMode: Q_EMIT aboutToSuspend(); suspendJob = backend()->suspend(PowerDevil::BackendInterface::ToDisk); break; case SuspendHybridMode: Q_EMIT aboutToSuspend(); suspendJob = backend()->suspend(PowerDevil::BackendInterface::HybridSuspend); break; case ShutdownMode: KWorkSpace::requestShutDown(KWorkSpace::ShutdownConfirmNo, KWorkSpace::ShutdownTypeHalt); break; case LogoutDialogMode: KWorkSpace::requestShutDown(KWorkSpace::ShutdownConfirmYes); break; case LockScreenMode: { // TODO should probably go through the backend (logind perhaps) eventually QDBusConnection::sessionBus().asyncCall(QDBusMessage::createMethodCall("org.freedesktop.ScreenSaver", "/ScreenSaver", "org.freedesktop.ScreenSaver", "Lock")); break; } default: break; } if (suspendJob) { // TODO connect(suspendJob, &KJob::error ??, this, [this]() { m_fadeEffect->stop(); }); suspendJob->start(); } }