Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
KDE Portal for XDG Desktop
Commits
62e66052
Commit
62e66052
authored
Oct 23, 2020
by
Jan Grulich
Browse files
FileChooser: escape slash character in user visible filter name
Do this only in case of non-mobile file dialog
BUG:427306
parent
5094b7e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/filechooser.cpp
View file @
62e66052
...
...
@@ -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"
;
...
...
src/filechooser.h
View file @
62e66052
...
...
@@ -110,7 +110,7 @@ private:
QStringList
&
mimeTypeFilters
,
QMap
<
QString
,
FilterList
>
&
allFilters
,
QString
&
selectedMimeTypeFilter
);
bool
isMobile
()
const
;
static
bool
isMobile
();
MobileFileDialog
*
m_mobileFileDialog
;
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment