Allow customizing workspace margins on desktop.

ubuntu/kinetic
Simon Quigley 3 years ago
parent 2821aac388
commit 6ade7ae79c

3
debian/changelog vendored

@ -1,6 +1,9 @@
pcmanfm-qt (1.1.0-0ubuntu4) UNRELEASED; urgency=medium
* Backport some upstream patches:
- Prevent an empty desktop path.
+ https://github.com/lxqt/pcmanfm-qt/pull/1601
+ https://github.com/lxqt/pcmanfm-qt/commit/f1438b
-- Simon Quigley <tsimonq2@ubuntu.com> Tue, 21 Jun 2022 23:58:05 -0500

@ -1,2 +1,3 @@
scaling-pr-1596.patch
add-manual.patch
upstream-pr-1601.patch

@ -0,0 +1,91 @@
From f1438b2b3eec8a1c60532ae5d9fcd654138dc5e4 Mon Sep 17 00:00:00 2001
From: tsujan <tsujan2000@gmail.com>
Date: Tue, 21 Jun 2022 11:14:03 +0430
Subject: [PATCH] Prevent an empty desktop path (#1601)
Fall back to `$HOME/Desktop` if `~/.config/user-dirs.dirs` doesn't exist or doesn't contain a desktop path. But if `~/.config/user-dirs.dirs` contains an empty desktop path, accept it.
See https://github.com/lxqt/lxqt-session/issues/439 for the story.
---
pcmanfm/desktoppreferencesdialog.cpp | 1 -
pcmanfm/xdgdir.cpp | 34 ++++++++++++++++------------
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/pcmanfm/desktoppreferencesdialog.cpp b/pcmanfm/desktoppreferencesdialog.cpp
index b25f6435..465095c6 100644
--- a/pcmanfm/desktoppreferencesdialog.cpp
+++ b/pcmanfm/desktoppreferencesdialog.cpp
@@ -27,7 +27,6 @@
#include <QFile>
#include <QDir>
#include <QSaveFile>
-#include <QRegExp>
#include <QDebug>
#include <QStandardPaths>
#include <libfm-qt/filedialog.h>
diff --git a/pcmanfm/xdgdir.cpp b/pcmanfm/xdgdir.cpp
index 9fd9a7b0..edc5a848 100644
--- a/pcmanfm/xdgdir.cpp
+++ b/pcmanfm/xdgdir.cpp
@@ -18,10 +18,13 @@
#include "xdgdir.h"
#include <QStandardPaths>
+#include <QRegularExpression>
#include <QFile>
#include <QDir>
#include <QSaveFile>
+static const QRegularExpression desktopRegex(QStringLiteral("XDG_DESKTOP_DIR=\"([^\n]*)\""));
+
QString XdgDir::readUserDirsFile() {
QFile file(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QStringLiteral("/user-dirs.dirs"));
if(file.open(QIODevice::ReadOnly | QIODevice::Text)) {
@@ -34,30 +37,33 @@ QString XdgDir::readUserDirsFile() {
QString XdgDir::readDesktopDir() {
QString str = readUserDirsFile();
- if(str.isEmpty())
- return QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QStringLiteral("/Desktop");
- QRegExp reg(QStringLiteral("XDG_DESKTOP_DIR=\"([^\n]*)\""));
- if(reg.lastIndexIn(str) != -1) {
- str = reg.cap(1);
- if(str.startsWith(QStringLiteral("$HOME")))
- str = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + str.mid(5);
- return str;
+ if(!str.isEmpty()) {
+ QRegularExpressionMatch match;
+ if(str.lastIndexOf(desktopRegex, -1, &match) != -1) {
+ str = match.captured(1);
+ if(str.startsWith(QStringLiteral("$HOME"))) {
+ str = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + str.mid(5);
+ }
+ return str;
+ }
}
- return QString();
+ return QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QStringLiteral("/Desktop");
}
void XdgDir::setDesktopDir(QString path) {
QString home = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
- if(path.startsWith(home))
+ if(path.startsWith(home)) {
path = QStringLiteral("$HOME") + path.mid(home.length());
+ }
QString str = readUserDirsFile();
- QRegExp reg(QStringLiteral("XDG_DESKTOP_DIR=\"([^\n]*)\""));
QString line = QStringLiteral("XDG_DESKTOP_DIR=\"") + path + QLatin1Char('\"');
- if(reg.indexIn(str) != -1)
- str.replace(reg, line);
+ if(str.contains(desktopRegex)) {
+ str.replace(desktopRegex, line);
+ }
else {
- if(!str.endsWith(QLatin1Char('\n')))
+ if(!str.endsWith(QLatin1Char('\n'))) {
str += QLatin1Char('\n');
+ }
str += line + QLatin1Char('\n');
}
QString dir = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
Loading…
Cancel
Save