Support for opening and displaying desktop files

This commit is contained in:
kateleet 2021-12-05 15:50:42 +08:00
parent 6ace2da599
commit 94ecc56617
2 changed files with 12 additions and 4 deletions

View file

@ -246,8 +246,10 @@ QVariant FolderModel::data(const QModelIndex &index, int role) const
case UrlRole:
return item.url();
case DisplayNameRole: {
if (item.isDesktopFile())
return "";
if (item.isDesktopFile()) {
KDesktopFile dfile(item.localPath());
return dfile.readName();
}
return item.url().fileName();
}
@ -938,6 +940,12 @@ void FolderModel::openSelected()
KFileItem item(url);
QString mimeType = item.mimetype();
// Desktop file.
if (mimeType == "application/x-desktop") {
FileLauncher::self()->launchApp(url.toLocalFile(), "");
continue;
}
// runnable
if (mimeType == "application/x-executable" ||
mimeType == "application/x-sharedlib" ||

View file

@ -39,7 +39,7 @@ Item {
property bool hovered: GridView.view.hoveredItem === control
property bool selected: model.selected
property bool blank: model.blank
property var fileName: model.fileName
property var fileName: model.displayName
// For desktop
visible: GridView.view.isDesktopView ? !blank : true
@ -207,7 +207,7 @@ Item {
textFormat: Text.PlainText
elide: Qt.ElideRight
wrapMode: Text.Wrap
text: model.fileName
text: control.fileName
color: control.GridView.view.isDesktopView ? "white"
: selected ? FishUI.Theme.highlightedTextColor
: FishUI.Theme.textColor