Remove reverse-applicable upstream patches.

ubuntu/lunar
Simon Quigley 2 years ago
parent 9c9c87e096
commit 4446d0959d

1
debian/changelog vendored

@ -5,6 +5,7 @@ pcmanfm-qt (1.2.0-0ubuntu1) UNRELEASED; urgency=medium
* Lubuntuify the package slightly, to make debhelper happy.
* Bump Standards-version to 4.6.1, no changes needed.
* Bump build dependencies in debian/control.
* Remove reverse-applicable upstream patches.
-- Simon Quigley <tsimonq2@ubuntu.com> Fri, 18 Nov 2022 18:44:59 -0600

@ -1,215 +0,0 @@
From c84434e576ec37208237f143ad5ef8f37ce25a24 Mon Sep 17 00:00:00 2001
From: tsujan <tsujan2000@gmail.com>
Date: Fri, 3 Jun 2022 05:16:58 +0430
Subject: [PATCH] Consider device pixel ratio when drawing wallpaper (#1596)
Previously, wallpapers weren't sharp with scale factors > 1.
Also, an old problem is fixed in centering per-screen wallpapers with multi-screen setups. Previously, if the centered wallpaper was smaller than the screen size, the dektop background color would be removed from the screen part to its right and bottom.
Fixes https://github.com/lxqt/pcmanfm-qt/issues/1595
---
pcmanfm/desktopwindow.cpp | 93 ++++++++++++++++++++++++---------------
1 file changed, 58 insertions(+), 35 deletions(-)
diff --git a/pcmanfm/desktopwindow.cpp b/pcmanfm/desktopwindow.cpp
index b0734582..d69b660e 100644
--- a/pcmanfm/desktopwindow.cpp
+++ b/pcmanfm/desktopwindow.cpp
@@ -644,88 +644,107 @@ QImage DesktopWindow::loadWallpaperFile(QSize requiredSize) {
// really generate the background pixmap according to current settings and apply it.
void DesktopWindow::updateWallpaper() {
if(wallpaperMode_ != WallpaperNone) { // use wallpaper
+ auto screen = getDesktopScreen();
+ if(screen == nullptr) {
+ return;
+ }
QPixmap pixmap;
QImage image;
Settings& settings = static_cast<Application* >(qApp)->settings();
- auto screen = getDesktopScreen();
- bool perScreenWallpaper(screen != nullptr && screen->virtualSiblings().size() > 1 && settings.perScreenWallpaper());
+ const auto screens = screen->virtualSiblings();
+ bool perScreenWallpaper(screens.size() > 1 && settings.perScreenWallpaper());
+
+ // the pixmap's size should be calculated by considering
+ // the positions and device pixel ratios of all screens
+ QRect pixmapRect;
+ for(const auto& scr : screens) {
+ pixmapRect |= QRect(scr->geometry().topLeft(), scr->size() * scr->devicePixelRatio());
+ }
+ const QSize pixmapSize = pixmapRect.size();
+
+ // the pixmap's device pixel ratio
+ qreal DPRatio = windowHandle() ? windowHandle()->devicePixelRatio() : qApp->devicePixelRatio();
+
if(wallpaperMode_ == WallpaperTile) { // use the original size
image = getWallpaperImage();
if(!image.isNull()) {
// Note: We can't use the QPainter::drawTiledPixmap(), because it doesn't tile
// correctly for background pixmaps bigger than the current screen size.
- const QSize s = size();
- pixmap = QPixmap{s};
+ pixmap = QPixmap{pixmapSize};
QPainter painter{&pixmap};
- for (int x = 0; x < s.width(); x += image.width()) {
- for (int y = 0; y < s.height(); y += image.height()) {
+ for (int x = 0; x < pixmapSize.width(); x += image.width()) {
+ for (int y = 0; y < pixmapSize.height(); y += image.height()) {
painter.drawImage(x, y, image);
}
}
+ pixmap.setDevicePixelRatio(DPRatio);
}
}
else if(wallpaperMode_ == WallpaperStretch) {
if(perScreenWallpaper) {
- const QSize s = size();
- pixmap = QPixmap{s};
+ pixmap = QPixmap{pixmapSize};
QPainter painter{&pixmap};
pixmap.fill(bgColor_);
image = getWallpaperImage();
if(!image.isNull()) {
QImage scaled;
- const auto screens = screen->virtualSiblings();
for(const auto& scr : screens) {
- scaled = image.scaled(scr->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ scaled = image.scaled(scr->size() * scr->devicePixelRatio(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
painter.drawImage(scr->geometry().x(), scr->geometry().y(), scaled);
}
}
+ pixmap.setDevicePixelRatio(DPRatio);
}
else {
- image = loadWallpaperFile(size());
+ image = loadWallpaperFile(pixmapSize);
pixmap = QPixmap::fromImage(image);
+ pixmap.setDevicePixelRatio(DPRatio);
}
}
else { // WallpaperCenter || WallpaperFit
if(perScreenWallpaper) {
- const QSize s = size();
- pixmap = QPixmap{s};
+ pixmap = QPixmap{pixmapSize};
QPainter painter{&pixmap};
pixmap.fill(bgColor_);
image = getWallpaperImage();
if(!image.isNull()) {
QImage scaled;
int x, y;
- const auto screens = screen->virtualSiblings();
if(wallpaperMode_ == WallpaperCenter) {
for(const auto& scr : screens) {
+ const auto scrSize = scr->size() * scr->devicePixelRatio();
// get the gap between image and screen to avoid overlapping and displacement
- int x_gap = (image.width() - scr->geometry().width()) / 2;
- int y_gap = (image.height() - scr->geometry().height()) / 2;
- scaled = image.copy(qMax(x_gap, 0), qMax(y_gap, 0), scr->geometry().width(), scr->geometry().height());
+ int x_gap = (image.width() - scrSize.width()) / 2;
+ int y_gap = (image.height() - scrSize.height()) / 2;
+ scaled = image.copy(qMax(x_gap, 0), qMax(y_gap, 0), scrSize.width(), scrSize.height());
x = scr->geometry().x() + qMax(0, -x_gap);
- y = scr->geometry().y() + qMax(0, - y_gap);
+ y = scr->geometry().y() + qMax(0, -y_gap);
+ painter.save();
+ painter.setClipRect(QRect(x, y, image.width(), image.height()));
painter.drawImage(x, y, scaled);
+ painter.restore();
}
}
else if((wallpaperMode_ == WallpaperFit || wallpaperMode_ == WallpaperZoom)
&& image.width() > 0 && image.height() > 0) {
for(const auto& scr : screens) {
+ const auto scrSize = scr->size() * scr->devicePixelRatio();
// get the screen-to-image ratio to calculate the scale factors
- const qreal w_ratio = static_cast<qreal>(scr->geometry().width()) / image.width();
- const qreal h_ratio = static_cast<qreal>(scr->geometry().height()) / image.height();
+ const qreal w_ratio = static_cast<qreal>(scrSize.width()) / image.width();
+ const qreal h_ratio = static_cast<qreal>(scrSize.height()) / image.height();
if(w_ratio <= h_ratio) {
if(wallpaperMode_ == WallpaperFit) {
// fit horizontally
- scaled = image.scaledToWidth(scr->geometry().width(), Qt::SmoothTransformation);
+ scaled = image.scaledToWidth(scrSize.width(), Qt::SmoothTransformation);
x = scr->geometry().x();
- y = scr->geometry().y() + (scr->geometry().height() - scaled.height()) / 2;
+ y = scr->geometry().y() + (scrSize.height() - scaled.height()) / 2;
}
else { // zoom
// fit vertically
- scaled = image.scaledToHeight(scr->geometry().height(), Qt::SmoothTransformation);
+ scaled = image.scaledToHeight(scrSize.height(), Qt::SmoothTransformation);
// crop to avoid overlapping
- int x_gap = (scaled.width() - scr->geometry().width()) / 2;
- scaled = scaled.copy(x_gap, 0, scr->geometry().width(), scaled.height());
+ int x_gap = (scaled.width() - scrSize.width()) / 2;
+ scaled = scaled.copy(x_gap, 0, scrSize.width(), scaled.height());
x = scr->geometry().x();
y = scr->geometry().y();
}
@@ -733,16 +752,16 @@ void DesktopWindow::updateWallpaper() {
else { // w_ratio > h_ratio
if(wallpaperMode_ == WallpaperFit) {
// fit vertically
- scaled = image.scaledToHeight(scr->geometry().height(), Qt::SmoothTransformation);
- x = scr->geometry().x() + (scr->geometry().width() - scaled.width()) / 2;
+ scaled = image.scaledToHeight(scrSize.height(), Qt::SmoothTransformation);
+ x = scr->geometry().x() + (scrSize.width() - scaled.width()) / 2;
y = scr->geometry().y();
}
else { // zoom
// fit horizonatally
- scaled = image.scaledToWidth(scr->geometry().width(), Qt::SmoothTransformation);
+ scaled = image.scaledToWidth(scrSize.width(), Qt::SmoothTransformation);
// crop to avoid overlapping
- int y_gap = (scaled.height() - scr->geometry().height()) / 2;
- scaled = scaled.copy(0, y_gap, scaled.width(), scr->geometry().height());
+ int y_gap = (scaled.height() - scrSize.height()) / 2;
+ scaled = scaled.copy(0, y_gap, scaled.width(), scrSize.height());
x = scr->geometry().x();
y = scr->geometry().y();
}
@@ -751,6 +770,7 @@ void DesktopWindow::updateWallpaper() {
}
}
}
+ pixmap.setDevicePixelRatio(DPRatio);
}
else {
if(wallpaperMode_ == WallpaperCenter) {
@@ -770,17 +790,18 @@ void DesktopWindow::updateWallpaper() {
if(origSize.isValid()) {
QSize desiredSize = origSize;
Qt::AspectRatioMode mode = (wallpaperMode_ == WallpaperFit ? Qt::KeepAspectRatio : Qt::KeepAspectRatioByExpanding);
- desiredSize.scale(width(), height(), mode);
+ desiredSize.scale(pixmapSize, mode);
image = loadWallpaperFile(desiredSize); // load the scaled image
}
}
if(!image.isNull()) {
- pixmap = QPixmap(size());
+ pixmap = QPixmap{pixmapSize};
QPainter painter(&pixmap);
pixmap.fill(bgColor_);
- int x = (width() - image.width()) / 2;
- int y = (height() - image.height()) / 2;
+ int x = (pixmapSize.width() - image.width()) / 2;
+ int y = (pixmapSize.height() - image.height()) / 2;
painter.drawImage(x, y, image);
+ pixmap.setDevicePixelRatio(DPRatio);
}
}
}
@@ -1239,7 +1260,9 @@ void DesktopWindow::paintBackground(QPaintEvent* event) {
painter.fillRect(event->rect(), QBrush(bgColor_));
}
else {
- painter.drawPixmap(event->rect(), wallpaperPixmap_, event->rect());
+ QRectF r(QPointF(event->rect().topLeft()) * wallpaperPixmap_.devicePixelRatio(),
+ QSizeF(event->rect().size()) * wallpaperPixmap_.devicePixelRatio());
+ painter.drawPixmap(event->rect(), wallpaperPixmap_, r.toRect());
}
}

@ -1,4 +1 @@
scaling-pr-1596.patch
add-manual.patch
upstream-pr-1601.patch
upstream-pr-1606.patch

@ -1,91 +0,0 @@
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);

@ -1,411 +0,0 @@
From 1151f49984ebc102c5238a9ba1d2b1a6769a1457 Mon Sep 17 00:00:00 2001
From: tsujan <tsujan2000@gmail.com>
Date: Tue, 21 Jun 2022 13:27:25 +0430
Subject: [PATCH] Allow customizing workspace margins on desktop (#1606)
It's especially useful with panels/docks that don't reserve space but auto-hide on overlapping windows.
---
pcmanfm/desktop-preferences.ui | 153 +++++++++++++++++++++------
pcmanfm/desktoppreferencesdialog.cpp | 10 ++
pcmanfm/desktopwindow.cpp | 34 ++++--
pcmanfm/settings.cpp | 14 +++
pcmanfm/settings.h | 9 ++
5 files changed, 183 insertions(+), 37 deletions(-)
diff --git a/pcmanfm/desktop-preferences.ui b/pcmanfm/desktop-preferences.ui
index d73e7312..c23f7bdb 100644
--- a/pcmanfm/desktop-preferences.ui
+++ b/pcmanfm/desktop-preferences.ui
@@ -136,6 +136,16 @@
<string>Spacing</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
+ <property name="verticalSpacing">
+ <number>10</number>
+ </property>
+ <item row="0" column="4">
+ <widget class="QCheckBox" name="lockMargins">
+ <property name="text">
+ <string>Lock</string>
+ </property>
+ </widget>
+ </item>
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
@@ -143,10 +153,24 @@
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QSpinBox" name="hMargin">
+ <item row="0" column="5">
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="3">
+ <widget class="QSpinBox" name="vMargin">
<property name="toolTip">
- <string>3 px by default.</string>
+ <string>1 px by default.
+A space is also reserved for 3 lines of text.</string>
</property>
<property name="suffix">
<string> px</string>
@@ -155,22 +179,14 @@
<number>48</number>
</property>
<property name="value">
- <number>3</number>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QLabel" name="label_8">
- <property name="text">
- <string>x</string>
+ <number>1</number>
</property>
</widget>
</item>
- <item row="0" column="3">
- <widget class="QSpinBox" name="vMargin">
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="hMargin">
<property name="toolTip">
- <string>1 px by default.
-A space is also reserved for 3 lines of text.</string>
+ <string>3 px by default.</string>
</property>
<property name="suffix">
<string> px</string>
@@ -179,29 +195,104 @@ A space is also reserved for 3 lines of text.</string>
<number>48</number>
</property>
<property name="value">
- <number>1</number>
+ <number>3</number>
</property>
</widget>
</item>
- <item row="0" column="4">
- <widget class="QCheckBox" name="lockMargins">
+ <item row="0" column="2">
+ <widget class="QLabel" name="label_8">
<property name="text">
- <string>Lock</string>
+ <string>x</string>
</property>
</widget>
</item>
- <item row="0" column="5">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>5</height>
- </size>
- </property>
- </spacer>
+ <item row="1" column="0" colspan="6" alignment="Qt::AlignLeft">
+ <widget class="QGroupBox" name="groupBox_7">
+ <layout class="QVBoxLayout" name="verticalLayout_6">
+ <property name="spacing">
+ <number>10</number>
+ </property>
+ <property name="leftMargin">
+ <number>5</number>
+ </property>
+ <property name="topMargin">
+ <number>5</number>
+ </property>
+ <property name="rightMargin">
+ <number>5</number>
+ </property>
+ <property name="bottomMargin">
+ <number>5</number>
+ </property>
+ <item alignment="Qt::AlignHCenter">
+ <widget class="QLabel" name="label_13">
+ <property name="text">
+ <string>Margins of work area:</string>
+ </property>
+ </widget>
+ </item>
+ <item alignment="Qt::AlignHCenter">
+ <widget class="QSpinBox" name="topMargin">
+ <property name="suffix">
+ <string> px</string>
+ </property>
+ <property name="maximum">
+ <number>200</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QSpinBox" name="leftMargin">
+ <property name="suffix">
+ <string> px</string>
+ </property>
+ <property name="maximum">
+ <number>200</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="rightMargin">
+ <property name="suffix">
+ <string> px</string>
+ </property>
+ <property name="maximum">
+ <number>200</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item alignment="Qt::AlignHCenter">
+ <widget class="QSpinBox" name="bottomMargin">
+ <property name="suffix">
+ <string> px</string>
+ </property>
+ <property name="maximum">
+ <number>200</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</item>
</layout>
</widget>
diff --git a/pcmanfm/desktoppreferencesdialog.cpp b/pcmanfm/desktoppreferencesdialog.cpp
index 465095c6..04ac8bb8 100644
--- a/pcmanfm/desktoppreferencesdialog.cpp
+++ b/pcmanfm/desktoppreferencesdialog.cpp
@@ -128,6 +128,11 @@ DesktopPreferencesDialog::DesktopPreferencesDialog(QWidget* parent, Qt::WindowFl
ui.vMargin->setValue(settings.desktopCellMargins().height());
connect(ui.lockMargins, &QAbstractButton::clicked, this, &DesktopPreferencesDialog::lockMargins);
+ ui.leftMargin->setValue(settings.workAreaMargins().left());
+ ui.topMargin->setValue(settings.workAreaMargins().top());
+ ui.rightMargin->setValue(settings.workAreaMargins().right());
+ ui.bottomMargin->setValue(settings.workAreaMargins().bottom());
+
ui.defaultFileManager->setChecked(settings.openWithDefaultFileManager());
ui.allSticky->setChecked(settings.allSticky());
@@ -207,6 +212,11 @@ void DesktopPreferencesDialog::applySettings()
settings.setDesktopCellMargins(QSize(ui.hMargin->value(), ui.vMargin->value()));
+ settings.setWorkAreaMargins(QMargins(ui.leftMargin->value(),
+ ui.topMargin->value(),
+ ui.rightMargin->value(),
+ ui.bottomMargin->value()));
+
settings.setOpenWithDefaultFileManager(ui.defaultFileManager->isChecked());
settings.setAllSticky(ui.allSticky->isChecked());
diff --git a/pcmanfm/desktopwindow.cpp b/pcmanfm/desktopwindow.cpp
index d69b660e..b2870774 100644
--- a/pcmanfm/desktopwindow.cpp
+++ b/pcmanfm/desktopwindow.cpp
@@ -63,7 +63,6 @@
#include <xcb/xcb.h>
#include <X11/Xlib.h>
-#define WORK_AREA_MARGIN 12 // margin of the work area
#define MIN_SLIDE_INTERVAL 5*60000 // 5 min
#define MAX_SLIDE_INTERVAL (24*60+55)*60000 // 24 h and 55 min
@@ -1203,8 +1202,13 @@ void DesktopWindow::removeBottomGap() {
auto itemSize = delegate->itemSize();
//qDebug() << "delegate:" << delegate->itemSize();
QSize cellMargins = getMargins();
+ Settings& settings = static_cast<Application* >(qApp)->settings();
int workAreaHeight = screen->availableVirtualGeometry().height()
- - 2 * WORK_AREA_MARGIN;
+ - settings.workAreaMargins().top()
+ - settings.workAreaMargins().bottom();
+ if(workAreaHeight <= 0) {
+ return;
+ }
int cellHeight = itemSize.height() + listView_->spacing();
int iconNumber = workAreaHeight / cellHeight;
int bottomGap = workAreaHeight % cellHeight;
@@ -1219,7 +1223,6 @@ void DesktopWindow::removeBottomGap() {
qreal exactNumber = (static_cast<qreal>(cellHeight) - static_cast<qreal>(bottomGap))
/ (2 * static_cast<qreal>(iconNumber) + static_cast<qreal>(2));
int subtrahend = (int)exactNumber + ((int)exactNumber == exactNumber ? 0 : 1);
- Settings& settings = static_cast<Application*>(qApp)->settings();
int minCellHeight = settings.desktopCellMargins().height();
if(subtrahend > 0
&& cellMargins.height() - subtrahend >= minCellHeight) {
@@ -1301,11 +1304,18 @@ void DesktopWindow::trustOurDesktopShortcut(std::shared_ptr<const Fm::FileInfo>
QRect DesktopWindow::getWorkArea(QScreen* screen) const {
QRect workArea = screen->availableVirtualGeometry();
- workArea.adjust(WORK_AREA_MARGIN, WORK_AREA_MARGIN, -WORK_AREA_MARGIN, -WORK_AREA_MARGIN);
+ QMargins margins = static_cast<Application* >(qApp)->settings().workAreaMargins();
// switch between right and left with RTL to use the usual (LTR) calculations later
if(layoutDirection() == Qt::RightToLeft) {
+ int right = margins.right();
+ margins.setRight(margins.left());
+ margins.setLeft(right);
+ workArea = workArea.marginsRemoved(margins);
workArea.moveLeft(rect().right() - workArea.right());
}
+ else {
+ workArea = workArea.marginsRemoved(margins);
+ }
return workArea;
}
@@ -1709,6 +1719,9 @@ QModelIndex DesktopWindow::navigateWithKey(int key, Qt::KeyboardModifiers modifi
QRect workArea = getWorkArea(screen);
int columns = workArea.width() / (itemSize.width() + listView_->spacing());
int rows = workArea.height() / (itemSize.height() + listView_->spacing());
+ if(columns <= 0 || rows <= 0) {
+ break;
+ }
bool rtl(layoutDirection() == Qt::RightToLeft);
while(!index.isValid() && workArea.contains(pos)) {
switch(key) {
@@ -1971,7 +1984,7 @@ void DesktopWindow::childDropEvent(QDropEvent* e) {
// move selected items to the drop position, preserving their relative positions
QPoint dropPos = e->pos();
- if(curIndx.isValid()) {
+ if(curIndx.isValid() && !workArea.isEmpty()) {
QPoint curPoint = listView_->visualRect(curIndx).topLeft();
// first move the current item to the drop position
@@ -2050,7 +2063,8 @@ void DesktopWindow::childDropEvent(QDropEvent* e) {
}
// position dropped items successively, starting with the drop rectangle
- if(mimeData->hasUrls()
+ if(!workArea.isEmpty()
+ && mimeData->hasUrls()
&& (e->dropAction() == Qt::CopyAction
|| e->dropAction() == Qt::MoveAction
|| e->dropAction() == Qt::LinkAction)) {
@@ -2079,6 +2093,10 @@ void DesktopWindow::childDropEvent(QDropEvent* e) {
// until it reaches the last cell and then puts the remaining items in the opposite
// direction. In this way, it creates a natural DND, especially with multiple files.
bool DesktopWindow::stickToPosition(const std::string& file, QPoint& pos, const QRect& workArea, const QSize& grid, bool reachedLastCell) {
+ if(workArea.isEmpty()) {
+ return reachedLastCell;
+ }
+
// normalize the position, depending on the positioning direction
if(!reachedLastCell) { // default direction: top -> bottom, left -> right
@@ -2178,6 +2196,10 @@ void DesktopWindow::alignToGrid(QPoint& pos, const QPoint& topLeft, const QSize&
// the text or icon rectangle but we make an exception for Trash because we want
// to trash dropped items once the drop point is inside the Trash cell.
QModelIndex DesktopWindow::indexForPos(bool* isTrash, const QPoint& pos, const QRect& workArea, const QSize& grid) const {
+ if(workArea.isEmpty()) {
+ return QModelIndex();
+ }
+
// first normalize the position
QPoint p(pos);
diff --git a/pcmanfm/settings.cpp b/pcmanfm/settings.cpp
index c5ccc00f..b1397cab 100644
--- a/pcmanfm/settings.cpp
+++ b/pcmanfm/settings.cpp
@@ -134,6 +134,7 @@ Settings::Settings():
templateRunApp_(false),
folderViewCellMargins_(QSize(3, 3)),
desktopCellMargins_(QSize(3, 1)),
+ workAreaMargins_(QMargins(12, 12, 12, 12)),
openWithDefaultFileManager_(false),
allSticky_(false),
searchNameCaseInsensitive_(false),
@@ -269,6 +270,14 @@ bool Settings::loadFile(QString filePath) {
desktopCellMargins_ = (settings.value(QStringLiteral("DesktopCellMargins"), QSize(3, 1)).toSize()
.expandedTo(QSize(0, 0))).boundedTo(QSize(48, 48));
+ auto l = settings.value(QStringLiteral("WorkAreaMargins")).toList();
+ if(l.size() >= 4) {
+ workAreaMargins_.setLeft(qBound(0, l.at(0).toInt(), 200));
+ workAreaMargins_.setTop(qBound(0, l.at(1).toInt(), 200));
+ workAreaMargins_.setRight(qBound(0, l.at(2).toInt(), 200));
+ workAreaMargins_.setBottom(qBound(0, l.at(3).toInt(), 200));
+ }
+
openWithDefaultFileManager_ = settings.value(QStringLiteral("OpenWithDefaultFileManager"), false).toBool();
allSticky_ = settings.value(QStringLiteral("AllSticky"), false).toBool();
settings.endGroup();
@@ -416,6 +425,11 @@ bool Settings::saveFile(QString filePath) {
settings.setValue(QStringLiteral("SortFolderFirst"), desktopSortFolderFirst_);
settings.setValue(QStringLiteral("SortHiddenLast"), desktopSortHiddenLast_);
settings.setValue(QStringLiteral("DesktopCellMargins"), desktopCellMargins_);
+ QList<QVariant> l{workAreaMargins_.left(),
+ workAreaMargins_.top(),
+ workAreaMargins_.right(),
+ workAreaMargins_.bottom()};
+ settings.setValue(QStringLiteral("WorkAreaMargins"), l);
settings.setValue(QStringLiteral("OpenWithDefaultFileManager"), openWithDefaultFileManager_);
settings.setValue(QStringLiteral("AllSticky"), allSticky_);
settings.endGroup();
diff --git a/pcmanfm/settings.h b/pcmanfm/settings.h
index 63c92b71..e9641b18 100644
--- a/pcmanfm/settings.h
+++ b/pcmanfm/settings.h
@@ -788,6 +788,14 @@ class Settings : public QObject {
desktopCellMargins_ = size;
}
+ QMargins workAreaMargins() const {
+ return workAreaMargins_;
+ }
+
+ void setWorkAreaMargins(QMargins margins) {
+ workAreaMargins_ = margins;
+ }
+
bool openWithDefaultFileManager() const {
return openWithDefaultFileManager_;
}
@@ -1145,6 +1153,7 @@ class Settings : public QObject {
QSize folderViewCellMargins_;
QSize desktopCellMargins_;
+ QMargins workAreaMargins_;
bool openWithDefaultFileManager_;
Loading…
Cancel
Save