Commit dd149d62 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

Warn on logout screen when another user is logged in

Since we have a unified screen for logging out and shutting down, the hint is always shown as the user could click on "Logout"
but then shut down anyway.

Differential Revision: https://phabricator.kde.org/D14905
parent 499d145e
......@@ -73,6 +73,22 @@ bool SessionsModel::shouldLock() const
return m_shouldLock;
}
bool SessionsModel::includeUnusedSessions() const
{
return m_includeUnusedSessions;
}
void SessionsModel::setIncludeUnusedSessions(bool includeUnusedSessions)
{
if (m_includeUnusedSessions != includeUnusedSessions) {
m_includeUnusedSessions = includeUnusedSessions;
reload();
emit includeUnusedSessionsChanged();
}
}
void SessionsModel::switchUser(int vt, bool shouldLock)
{
if (vt < 0) {
......@@ -157,6 +173,10 @@ void SessionsModel::reload()
continue;
}
if (!m_includeUnusedSessions && session.session.isEmpty()) {
continue;
}
SessionEntry entry;
entry.name = session.user;
entry.displayNumber = session.display;
......
......@@ -56,6 +56,7 @@ class SessionsModel : public QAbstractListModel
Q_PROPERTY(bool canStartNewSession READ canStartNewSession CONSTANT)
Q_PROPERTY(bool shouldLock READ shouldLock NOTIFY shouldLockChanged)
Q_PROPERTY(bool showNewSessionEntry MEMBER m_showNewSessionEntry WRITE setShowNewSessionEntry NOTIFY showNewSessionEntryChanged)
Q_PROPERTY(bool includeUnusedSessions READ includeUnusedSessions WRITE setIncludeUnusedSessions NOTIFY includeUnusedSessionsChanged)
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
......@@ -77,8 +78,10 @@ public:
bool canSwitchUser() const;
bool canStartNewSession() const;
bool shouldLock() const;
bool includeUnusedSessions() const;
void setShowNewSessionEntry(bool showNewSessionEntry);
void setIncludeUnusedSessions(bool includeUnusedSessions);
Q_INVOKABLE void reload();
Q_INVOKABLE void switchUser(int vt, bool shouldLock = false);
......@@ -92,6 +95,7 @@ signals:
void shouldLockChanged();
void showNewSessionEntryChanged();
void countChanged();
void includeUnusedSessionsChanged();
void switchedUser(int vt);
void startedNewSession();
......@@ -110,6 +114,7 @@ private:
bool m_pendingReserve = false;
bool m_showNewSessionEntry = false;
bool m_includeUnusedSessions = true;
org::freedesktop::ScreenSaver *m_screensaverInterface = nullptr;
......
......@@ -28,6 +28,8 @@ import org.kde.kcoreaddons 1.0 as KCoreAddons
import "../components"
import "timer.js" as AutoTriggerTimer
import org.kde.plasma.private.sessions 2.0
PlasmaCore.ColorScope {
id: root
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
......@@ -65,6 +67,12 @@ PlasmaCore.ColorScope {
id: kuser
}
// For showing a "other users are logged in" hint
SessionsModel {
id: sessionsModel
includeUnusedSessions: false
}
Controls.Action {
onTriggered: root.cancelRequested()
shortcut: "Escape"
......@@ -128,6 +136,20 @@ PlasmaCore.ColorScope {
height: Math.max(implicitHeight, units.gridUnit * 10)
width: Math.max(implicitWidth, units.gridUnit * 16)
PlasmaComponents.Label {
Layout.maximumWidth: units.gridUnit * 16
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
font.italic: true
text: i18ndp("plasma_lookandfeel_org.kde.lookandfeel",
"One other user is currently logged in. If the computer is shut down or rebooted, that user may lose work.",
"%1 other users are currently logged in. If the computer is shut down or rebooted, those users may lose work.",
sessionsModel.count)
visible: sessionsModel.count > 0
}
RowLayout {
spacing: units.largeSpacing * 2
Layout.alignment: Qt.AlignHCenter
......
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