Commit 62e66052 authored by Jan Grulich's avatar Jan Grulich

FileChooser: escape slash character in user visible filter name

Do this only in case of non-mobile file dialog

BUG:427306
parent 5094b7e0
......@@ -588,8 +588,12 @@ void FileChooserPortal::ExtractFilters(const QVariantMap &options, QStringList &
}
if (!filterStrings.isEmpty()) {
QString userVisibleName = filterList.userVisibleName;
if (!isMobile()) {
userVisibleName.replace(QLatin1Char('/'), QStringLiteral("\\/"));
}
const QString filterString = filterStrings.join(QLatin1Char(' '));
const QString nameFilter = QStringLiteral("%1|%2").arg(filterString, filterList.userVisibleName);
const QString nameFilter = QStringLiteral("%1|%2").arg(filterString, userVisibleName);
nameFilters << nameFilter;
allFilters[filterList.userVisibleName] = filterList;
}
......@@ -603,7 +607,11 @@ void FileChooserPortal::ExtractFilters(const QVariantMap &options, QStringList &
if (filterStruct.type == 0) {
// make the relevant entry the first one in the list of filters,
// since that is the one that gets preselected by KFileWidget::setFilter
QString nameFilter = QStringLiteral("%1|%2").arg(filterStruct.filterString, filterList.userVisibleName);
QString userVisibleName = filterList.userVisibleName;
if (!isMobile()) {
userVisibleName.replace(QLatin1Char('/'), QStringLiteral("\\/"));
}
QString nameFilter = QStringLiteral("%1|%2").arg(filterStruct.filterString, userVisibleName);
nameFilters.removeAll(nameFilter);
nameFilters.push_front(nameFilter);
} else {
......@@ -615,7 +623,7 @@ void FileChooserPortal::ExtractFilters(const QVariantMap &options, QStringList &
}
}
bool FileChooserPortal::isMobile() const
bool FileChooserPortal::isMobile()
{
QByteArray mobile = qgetenv("QT_QUICK_CONTROLS_MOBILE");
return mobile == "true" || mobile == "1";
......
......@@ -110,7 +110,7 @@ private:
QStringList &mimeTypeFilters, QMap<QString, FilterList> &allFilters,
QString &selectedMimeTypeFilter);
bool isMobile() const;
static bool isMobile();
MobileFileDialog *m_mobileFileDialog;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment