Changeset View
Changeset View
Standalone View
Standalone View
components/sessionsprivate/sessionsmodel.h
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
51 | class SessionsModel : public QAbstractListModel | 51 | class SessionsModel : public QAbstractListModel | ||
52 | { | 52 | { | ||
53 | Q_OBJECT | 53 | Q_OBJECT | ||
54 | 54 | | |||
55 | Q_PROPERTY(bool canSwitchUser READ canSwitchUser CONSTANT) | 55 | Q_PROPERTY(bool canSwitchUser READ canSwitchUser CONSTANT) | ||
56 | Q_PROPERTY(bool canStartNewSession READ canStartNewSession CONSTANT) | 56 | Q_PROPERTY(bool canStartNewSession READ canStartNewSession CONSTANT) | ||
57 | Q_PROPERTY(bool shouldLock READ shouldLock NOTIFY shouldLockChanged) | 57 | Q_PROPERTY(bool shouldLock READ shouldLock NOTIFY shouldLockChanged) | ||
58 | Q_PROPERTY(bool showNewSessionEntry MEMBER m_showNewSessionEntry WRITE setShowNewSessionEntry NOTIFY showNewSessionEntryChanged) | 58 | Q_PROPERTY(bool showNewSessionEntry MEMBER m_showNewSessionEntry WRITE setShowNewSessionEntry NOTIFY showNewSessionEntryChanged) | ||
59 | Q_PROPERTY(bool includeUnusedSessions READ includeUnusedSessions WRITE setIncludeUnusedSessions NOTIFY includeUnusedSessionsChanged) | ||||
59 | 60 | | |||
60 | Q_PROPERTY(int count READ rowCount NOTIFY countChanged) | 61 | Q_PROPERTY(int count READ rowCount NOTIFY countChanged) | ||
61 | 62 | | |||
62 | public: | 63 | public: | ||
63 | explicit SessionsModel(QObject *parent = nullptr); | 64 | explicit SessionsModel(QObject *parent = nullptr); | ||
64 | ~SessionsModel() override = default; | 65 | ~SessionsModel() override = default; | ||
65 | 66 | | |||
66 | enum class Role { | 67 | enum class Role { | ||
67 | RealName = Qt::DisplayRole, | 68 | RealName = Qt::DisplayRole, | ||
68 | Icon = Qt::DecorationRole, //path to a file | 69 | Icon = Qt::DecorationRole, //path to a file | ||
69 | Name = Qt::UserRole + 1, | 70 | Name = Qt::UserRole + 1, | ||
70 | DisplayNumber, | 71 | DisplayNumber, | ||
71 | VtNumber, | 72 | VtNumber, | ||
72 | Session, | 73 | Session, | ||
73 | IsTty, | 74 | IsTty, | ||
74 | IconName //name of an icon | 75 | IconName //name of an icon | ||
75 | }; | 76 | }; | ||
76 | 77 | | |||
77 | bool canSwitchUser() const; | 78 | bool canSwitchUser() const; | ||
78 | bool canStartNewSession() const; | 79 | bool canStartNewSession() const; | ||
79 | bool shouldLock() const; | 80 | bool shouldLock() const; | ||
81 | bool includeUnusedSessions() const; | ||||
80 | 82 | | |||
81 | void setShowNewSessionEntry(bool showNewSessionEntry); | 83 | void setShowNewSessionEntry(bool showNewSessionEntry); | ||
84 | void setIncludeUnusedSessions(bool includeUnusedSessions); | ||||
82 | 85 | | |||
83 | Q_INVOKABLE void reload(); | 86 | Q_INVOKABLE void reload(); | ||
84 | Q_INVOKABLE void switchUser(int vt, bool shouldLock = false); | 87 | Q_INVOKABLE void switchUser(int vt, bool shouldLock = false); | ||
85 | Q_INVOKABLE void startNewSession(bool shouldLock = false); | 88 | Q_INVOKABLE void startNewSession(bool shouldLock = false); | ||
86 | 89 | | |||
87 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; | 90 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; | ||
88 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | 91 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | ||
89 | QHash<int, QByteArray> roleNames() const override; | 92 | QHash<int, QByteArray> roleNames() const override; | ||
90 | 93 | | |||
91 | signals: | 94 | signals: | ||
92 | void shouldLockChanged(); | 95 | void shouldLockChanged(); | ||
93 | void showNewSessionEntryChanged(); | 96 | void showNewSessionEntryChanged(); | ||
94 | void countChanged(); | 97 | void countChanged(); | ||
98 | void includeUnusedSessionsChanged(); | ||||
95 | 99 | | |||
96 | void switchedUser(int vt); | 100 | void switchedUser(int vt); | ||
97 | void startedNewSession(); | 101 | void startedNewSession(); | ||
98 | void aboutToLockScreen(); | 102 | void aboutToLockScreen(); | ||
99 | 103 | | |||
100 | private: | 104 | private: | ||
101 | void checkScreenLocked(const std::function<void (bool)> &cb); | 105 | void checkScreenLocked(const std::function<void (bool)> &cb); | ||
102 | 106 | | |||
103 | KDisplayManager m_displayManager; | 107 | KDisplayManager m_displayManager; | ||
104 | 108 | | |||
105 | QVector<SessionEntry> m_data; | 109 | QVector<SessionEntry> m_data; | ||
106 | 110 | | |||
107 | bool m_shouldLock = true; | 111 | bool m_shouldLock = true; | ||
108 | 112 | | |||
109 | int m_pendingVt = 0; | 113 | int m_pendingVt = 0; | ||
110 | bool m_pendingReserve = false; | 114 | bool m_pendingReserve = false; | ||
111 | 115 | | |||
112 | bool m_showNewSessionEntry = false; | 116 | bool m_showNewSessionEntry = false; | ||
117 | bool m_includeUnusedSessions = true; | ||||
113 | 118 | | |||
114 | org::freedesktop::ScreenSaver *m_screensaverInterface = nullptr; | 119 | org::freedesktop::ScreenSaver *m_screensaverInterface = nullptr; | ||
115 | 120 | | |||
116 | }; | 121 | }; | ||
117 | 122 | | |||
118 | #endif // SESSIONSMODEL_H | 123 | #endif // SESSIONSMODEL_H |