kio: pass the full path to KIO::pixmapForUrl() from KFileWidgetPrivate::setLocationText()

for best MIME type determination results the content of the file may have
to be read and relative path (only the filename in this case) does not cut
it

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-06-04 15:49:55 +03:00
parent f6ebdfe0a7
commit ed8815b5c9

View file

@ -1165,7 +1165,13 @@ void KFileWidgetPrivate::removeDummyHistoryEntry()
void KFileWidgetPrivate::setLocationText(const KUrl& url) void KFileWidgetPrivate::setLocationText(const KUrl& url)
{ {
if (!url.isEmpty()) { if (!url.isEmpty()) {
QPixmap urlIcon = KIO::pixmapForUrl(url, KIconLoader::Small); QPixmap urlIcon;
const QString u = url.url();
if (!KUrl::isRelativeUrl(u)) {
urlIcon = KIO::pixmapForUrl(url, KIconLoader::Small);
} else {
urlIcon = KIO::pixmapForUrl(KUrl(this->url, u), KIconLoader::Small);
}
if (url.hasPath()) { if (url.hasPath()) {
if (!url.directory().isEmpty()) { if (!url.directory().isEmpty()) {
KUrl u(url); KUrl u(url);
@ -1494,7 +1500,7 @@ void KFileWidgetPrivate::_k_fileCompletion( const QString& match )
); );
} }
void KFileWidgetPrivate::_k_slotLocationChanged( const QString& text ) void KFileWidgetPrivate::_k_slotLocationChanged(const QString &text)
{ {
locationEdit->lineEdit()->setModified(true); locationEdit->lineEdit()->setModified(true);
@ -1505,7 +1511,7 @@ void KFileWidgetPrivate::_k_slotLocationChanged( const QString& text )
if (text.isEmpty()) { if (text.isEmpty()) {
removeDummyHistoryEntry(); removeDummyHistoryEntry();
} else { } else {
setDummyHistoryEntry( text ); setDummyHistoryEntry(text);
} }
if (!locationEdit->lineEdit()->text().isEmpty()) { if (!locationEdit->lineEdit()->text().isEmpty()) {