forked from pool/kcm_sddm
80 lines
2.7 KiB
Diff
80 lines
2.7 KiB
Diff
|
From 65dc9de7c45d5ea4affaa6bf9e6601a000c3e321 Mon Sep 17 00:00:00 2001
|
||
|
From: Fabian Vogt <fabian@ritter-vogt.de>
|
||
|
Date: Tue, 11 Jul 2017 13:05:37 +0200
|
||
|
Subject: [PATCH] Session file parser: Support sections and respect the Hidden
|
||
|
property
|
||
|
|
||
|
Summary:
|
||
|
Some desktop files have multiple sections, but for now we're only
|
||
|
interested in [Desktop Entry]. Without this patch, every entry was seen
|
||
|
as part of the [Desktop Entry] session, resulting in values getting
|
||
|
overwritten.
|
||
|
|
||
|
Additionally, the Hidden=true property specifies that the desktop file
|
||
|
needs to be treated like it was non-existant.
|
||
|
|
||
|
Same as https://github.com/sddm/sddm/pull/821 for sddm.
|
||
|
|
||
|
BUG: 381982
|
||
|
|
||
|
Test Plan:
|
||
|
Installed the KCM, now there are no duplicate sessions and the right
|
||
|
Name is shown for icewm-session.desktop.
|
||
|
|
||
|
Reviewers: #plasma
|
||
|
|
||
|
Subscribers: plasma-devel
|
||
|
|
||
|
Tags: #plasma
|
||
|
|
||
|
Differential Revision: https://phabricator.kde.org/D6626
|
||
|
---
|
||
|
src/sessionmodel.cpp | 22 ++++++++++++++++++++--
|
||
|
1 file changed, 20 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/src/sessionmodel.cpp b/src/sessionmodel.cpp
|
||
|
index d4aa025..9e52b12 100644
|
||
|
--- a/src/sessionmodel.cpp
|
||
|
+++ b/src/sessionmodel.cpp
|
||
|
@@ -65,9 +65,22 @@ void SessionModel::loadDir(const QString &path, SessionType type)
|
||
|
if (!inputFile.open(QIODevice::ReadOnly))
|
||
|
continue;
|
||
|
SessionPtr si { new Session { session, "", "", "" } };
|
||
|
+ bool isHidden = false;
|
||
|
+ QString current_section;
|
||
|
QTextStream in(&inputFile);
|
||
|
while (!in.atEnd()) {
|
||
|
QString line = in.readLine();
|
||
|
+
|
||
|
+ if (line.startsWith(QLatin1String("["))) {
|
||
|
+ // The section name ends before the last ] before the start of a comment
|
||
|
+ int end = line.lastIndexOf(QLatin1Char(']'), line.indexOf(QLatin1Char('#')));
|
||
|
+ if (end != -1)
|
||
|
+ current_section = line.mid(1, end - 1);
|
||
|
+ }
|
||
|
+
|
||
|
+ if (current_section != QLatin1String("Desktop Entry"))
|
||
|
+ continue; // We are only interested in the "Desktop Entry" section
|
||
|
+
|
||
|
if (line.startsWith("Name=")) {
|
||
|
si->name = line.mid(5);
|
||
|
if (type == SessionTypeWayland) {
|
||
|
@@ -79,9 +92,14 @@ void SessionModel::loadDir(const QString &path, SessionType type)
|
||
|
si->exec = line.mid(5);
|
||
|
if (line.startsWith("Comment="))
|
||
|
si->comment = line.mid(8);
|
||
|
+ if (line.startsWith(QLatin1String("Hidden=")))
|
||
|
+ isHidden = line.mid(7).toLower() == QLatin1String("true");
|
||
|
+ }
|
||
|
+ if (!isHidden) {
|
||
|
+ // add to sessions list
|
||
|
+ d->sessions.push_back(si);
|
||
|
}
|
||
|
- // add to sessions list
|
||
|
- d->sessions.push_back(si);
|
||
|
+
|
||
|
// close file
|
||
|
inputFile.close();
|
||
|
}
|
||
|
|