summaryrefslogtreecommitdiffstats
path: root/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp')
-rw-r--r--src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
index ae2532e69e..2c72538387 100644
--- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
@@ -121,7 +121,7 @@ public:
QString selectedMimeTypeFilter;
QString selectedNameFilter;
QStringList selectedFiles;
- QPlatformFileDialogHelper *nativeFileDialog = nullptr;
+ std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
};
QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
@@ -131,8 +131,8 @@ QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelp
Q_D(QXdgDesktopPortalFileDialog);
if (d->nativeFileDialog) {
- connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
- connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
+ connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
+ connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
}
}
@@ -185,7 +185,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
QLatin1String("/org/freedesktop/portal/desktop"),
QLatin1String("org.freedesktop.portal.FileChooser"),
d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
- QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId);
+ QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
QVariantMap options;
if (!d->acceptLabel.isEmpty())
@@ -210,7 +210,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
qDBusRegisterMetaType<FilterList>();
FilterList filterList;
- Filter* selectedFilter = nullptr;
+ auto selectedFilterIndex = filterList.size() - 1;
d->userVisibleToNameFilter.clear();
@@ -236,7 +236,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
filterList << filter;
if (!d->selectedMimeTypeFilter.isEmpty() && d->selectedMimeTypeFilter == mimeTypefilter)
- selectedFilter = &filterList.last();
+ selectedFilterIndex = filterList.size() - 1;
}
} else if (!d->nameFilters.isEmpty()) {
for (const QString &nameFilter : d->nameFilters) {
@@ -248,6 +248,11 @@ void QXdgDesktopPortalFileDialog::openPortal()
QString userVisibleName = match.captured(1);
QStringList filterStrings = match.captured(2).split(QLatin1Char(' '), Qt::SkipEmptyParts);
+ if (filterStrings.isEmpty()) {
+ qWarning() << "Filter " << userVisibleName << " is empty and will be ignored.";
+ continue;
+ }
+
FilterConditionList filterConditions;
for (const QString &filterString : filterStrings) {
FilterCondition filterCondition;
@@ -265,7 +270,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
d->userVisibleToNameFilter.insert(userVisibleName, nameFilter);
if (!d->selectedNameFilter.isEmpty() && d->selectedNameFilter == nameFilter)
- selectedFilter = &filterList.last();
+ selectedFilterIndex = filterList.size() - 1;
}
}
}
@@ -273,9 +278,8 @@ void QXdgDesktopPortalFileDialog::openPortal()
if (!filterList.isEmpty())
options.insert(QLatin1String("filters"), QVariant::fromValue(filterList));
- if (selectedFilter) {
- options.insert(QLatin1String("current_filter"), QVariant::fromValue(*selectedFilter));
- }
+ if (selectedFilterIndex != -1)
+ options.insert(QLatin1String("current_filter"), QVariant::fromValue(filterList[selectedFilterIndex]));
options.insert(QLatin1String("handle_token"), QStringLiteral("qt%1").arg(QRandomGenerator::global()->generate()));
@@ -298,6 +302,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
this,
SLOT(gotResponse(uint,QVariantMap)));
}
+ watcher->deleteLater();
});
}
@@ -462,3 +467,5 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
}
QT_END_NAMESPACE
+
+#include "moc_qxdgdesktopportalfiledialog_p.cpp"