blob: 6910dcff1b5636a37bc6815c3e449540df59ff91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
From eb684e42e768e4c57dbf81abf51f7597df164814 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Mon, 17 Jan 2022 22:05:09 +0100
Subject: [PATCH 1/3] Use QFileDialog for selecting directories
KFileWidget is not as good at selecting directories as KDirSelectDialog
from plasma-integration. On top of that, directory selection appears to be
entirely broken currently.
Use KDirSelectDialog through QFileDialog if possible.
BUG: 437505
---
src/filechooser.cpp | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/src/filechooser.cpp b/src/filechooser.cpp
index 4302c24..97a48fc 100644
--- a/src/filechooser.cpp
+++ b/src/filechooser.cpp
@@ -13,6 +13,7 @@
#include <QDBusMetaType>
#include <QDialogButtonBox>
#include <QFile>
+#include <QFileDialog>
#include <QGridLayout>
#include <QLabel>
#include <QLoggingCategory>
@@ -256,6 +257,37 @@ uint FileChooserPortal::OpenFile(const QDBusObjectPath &handle,
return retCode;
}
+ // Use QFileDialog for most directory requests to utilize
+ // plasma-integration's KDirSelectDialog
+ if (directory && !options.contains(QStringLiteral("choices"))) {
+ QFileDialog dirDialog;
+ dirDialog.setWindowTitle(title);
+ dirDialog.setModal(modalDialog);
+ dirDialog.setFileMode(QFileDialog::Directory);
+ dirDialog.setOptions(QFileDialog::ShowDirsOnly);
+ dirDialog.setSupportedSchemes(QStringList{QStringLiteral("file")});
+ if (!acceptLabel.isEmpty()) {
+ dirDialog.setLabelText(QFileDialog::Accept, acceptLabel);
+ }
+
+ dirDialog.winId(); // Trigger window creation
+ Utils::setParentWindow(&dirDialog, parent_window);
+
+ if (dirDialog.exec() != QDialog::Accepted) {
+ return 1;
+ }
+
+ const auto urls = dirDialog.selectedUrls();
+ if (urls.empty()) {
+ return 2;
+ }
+
+ results.insert(QStringLiteral("uris"), QUrl::toStringList(urls));
+ results.insert(QStringLiteral("writable"), true);
+
+ return 0;
+ }
+
// for handling of options - choices
QScopedPointer<QWidget> optionsWidget;
// to store IDs for choices along with corresponding comboboxes/checkboxes
--
2.35.0
|