...
 
Commits (5)
......@@ -184,11 +184,17 @@ void DeviceState::connectUserManager()
{
Q_D(DeviceState);
QDBusConnection::systemBus().connect(SAILFISH_USERMANAGER_DBUS_INTERFACE,
SAILFISH_USERMANAGER_DBUS_OBJECT_PATH,
SAILFISH_USERMANAGER_DBUS_INTERFACE,
"aboutToChangeCurrentUser",
d,
SLOT(emitUserSwitching(uint)));
SAILFISH_USERMANAGER_DBUS_OBJECT_PATH,
SAILFISH_USERMANAGER_DBUS_INTERFACE,
"aboutToChangeCurrentUser",
d,
SLOT(emitUserSwitching(uint)));
QDBusConnection::systemBus().connect(SAILFISH_USERMANAGER_DBUS_INTERFACE,
SAILFISH_USERMANAGER_DBUS_OBJECT_PATH,
SAILFISH_USERMANAGER_DBUS_INTERFACE,
"currentUserChangeFailed",
d,
SLOT(emitUserSwitchingFailed(uint)));
}
void DeviceState::disconnectUserManager()
......@@ -199,7 +205,13 @@ void DeviceState::disconnectUserManager()
SAILFISH_USERMANAGER_DBUS_INTERFACE,
"aboutToChangeCurrentUser",
d,
SLOT(emitUserChanging(uint)));
SLOT(emitUserSwitching(uint)));
QDBusConnection::systemBus().disconnect(SAILFISH_USERMANAGER_DBUS_INTERFACE,
SAILFISH_USERMANAGER_DBUS_OBJECT_PATH,
SAILFISH_USERMANAGER_DBUS_INTERFACE,
"currentUserChangeFailed",
d,
SLOT(emitUserSwitchingFailed(uint)));
}
} // DeviceState namespace
......@@ -67,7 +67,8 @@ public:
RebootDeniedUSB, //!< Reboot denied because USB is connected in mass storage mode
ShutdownDeniedUSB, //!< Shutdown denied because USB is connected in mass storage mode
Reboot, //!< Reboot
UserSwitching //!< User switching
UserSwitching, //!< User switching
UserSwitchingFailed //!< User switching failed
};
public:
......
......@@ -107,6 +107,11 @@ namespace DeviceState
emit nextUserChanged(uid);
emit systemStateChanged(DeviceState::UserSwitching);
}
void emitUserSwitchingFailed(uint uid) {
Q_UNUSED(uid)
emit systemStateChanged(DeviceState::UserSwitchingFailed);
}
};
}
#endif // DEVICESTATE_P_H
......@@ -16,6 +16,7 @@
#include "homeapplication.h"
#include "compositor/lipstickcompositor.h"
#include "notifications/notificationmanager.h"
LipstickApi::LipstickApi(QObject *parent)
: QObject(parent)
......@@ -40,3 +41,8 @@ ScreenshotResult *LipstickApi::takeScreenshot(const QString &path)
{
return ScreenshotService::saveScreenshot(path);
}
QString LipstickApi::notificationSystemApplicationName() const
{
return NotificationManager::instance(false)->systemApplicationName();
}
......@@ -23,6 +23,7 @@ class LIPSTICK_EXPORT LipstickApi : public QObject
Q_OBJECT
Q_PROPERTY(bool active READ active NOTIFY activeChanged)
Q_PROPERTY(QObject *compositor READ compositor CONSTANT)
Q_PROPERTY(QString notificationSystemApplicationName READ notificationSystemApplicationName CONSTANT)
public:
LipstickApi(QObject *parent = 0);
......@@ -32,6 +33,8 @@ public:
Q_INVOKABLE ScreenshotResult *takeScreenshot(const QString &path = QString());
QString notificationSystemApplicationName() const;
signals:
void activeChanged();
};
......
......@@ -427,8 +427,9 @@ void BatteryNotifier::sendNotification(BatteryNotifier::NotificationType type)
qtTrId("qtn_ener_exit_psnote"),
""},
{"x-nemo.battery.lowbattery", // NotificationLowBattery
//% "Low battery"
qtTrId("qtn_ener_lowbatt"),
//: Shown when the battery is low. %1 = current battery level as a percentage
//% "Low battery: %1%"
qtTrId("qtn_ener_lowbatt_with_percentage"),
""},
{"x-nemo.battery.notenoughpower", // NotificationNotEnoughPower
//% "Not enough power to charge"
......@@ -450,10 +451,14 @@ void BatteryNotifier::sendNotification(BatteryNotifier::NotificationType type)
}
}
const QString &message = type == NotificationLowBattery
? info.message.arg(m_currentState.m_batteryLevel)
: info.message;
/* Add fresh notification item */
QVariantHash hints;
hints.insert(LipstickNotification::HINT_CATEGORY, info.category);
hints.insert(LipstickNotification::HINT_PREVIEW_BODY, info.message);
hints.insert(LipstickNotification::HINT_PREVIEW_BODY, message);
hints.insert(LipstickNotification::HINT_VISIBILITY, QLatin1String("public"));
QueuedNotification queuedNotification;
queuedNotification.m_type = type;
......
......@@ -56,6 +56,7 @@ void ShutdownScreen::setWindowVisible(bool visible)
}
if (!m_window->isVisible()) {
m_window->setContextProperty("shutdownMode", m_shutdownMode);
m_window->show();
emit windowVisibleChanged();
}
......@@ -107,6 +108,17 @@ void ShutdownScreen::applySystemState(DeviceState::DeviceState::StateIndication
applySystemState(DeviceState::DeviceState::Shutdown);
break;
case DeviceState::DeviceState::UserSwitchingFailed:
m_shutdownMode = "userswitchFailed";
m_window->setContextProperty("shutdownMode", m_shutdownMode);
emit userSwitchFailed();
QTimer::singleShot(10000, this, [this] {
// Allow for some time for the notification to be visible
setWindowVisible(false);
m_shutdownMode.clear();
});
break;
default:
break;
}
......
......@@ -55,6 +55,8 @@ public:
signals:
//! Sent when the visibility of the window has changed.
void windowVisibleChanged();
//! Sent when user change has failed.
void userSwitchFailed();
private slots:
/*!
......