Skip to content

Commit e1d642c

Browse files
FileSystem Locate menu fix
1 parent d7cb3a1 commit e1d642c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Extensions_Qt6/FileExplorer.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import os
1+
import os, sys
22
import ctypes
33
from PyQt6 import QtCore, QtGui, QtWidgets
4+
import subprocess
45

56
from Extensions_Qt6 import StyleSheet
67

7-
88
class ManageShortcuts(QtWidgets.QLabel):
99

1010
updateShortcuts = QtCore.pyqtSignal()
@@ -101,7 +101,7 @@ def removeShorcut(self):
101101
self.loadShortcuts()
102102

103103
def addShortcut(self):
104-
options = QtWidgets.QFileDialog.DontResolveSymlinks | QtWidgets.QFileDialog.ShowDirsOnly
104+
options = QtWidgets.QFileDialog.Option.DontResolveSymlinks | QtWidgets.QFileDialog.Option.ShowDirsOnly
105105
directory = QtWidgets.QFileDialog.getExistingDirectory(self,
106106
"Select directory", self.useData.getLastOpenedDir(), options)
107107
if directory:
@@ -347,5 +347,13 @@ def locate(self):
347347
path_index = indexList[0]
348348
file_path = \
349349
os.path.normpath(self.fileSystemModel.filePath(path_index))
350-
ctypes.windll.shell32.ShellExecuteW(None, 'open', 'explorer.exe',
351-
'/n,/select, ' + file_path, None, 1)
350+
if sys.platform.startswith('win'):
351+
ctypes.windll.shell32.ShellExecuteW(None, 'open', 'explorer.exe',
352+
'/n,/select, ' + file_path, None, 1)
353+
else:
354+
if subprocess.run(['which', 'qdbus'], stdout=subprocess.PIPE).returncode == 0:
355+
subprocess.run(['qdbus', 'org.freedesktop.FileManager1', '/org/freedesktop/FileManager1', 'org.freedesktop.FileManager1.ShowItems', file_path, '""'])
356+
elif subprocess.run(['which', 'gdbus'], stdout=subprocess.PIPE).returncode == 0:
357+
subprocess.run(['gdbus', 'call', '-e', '-d', 'org.freedesktop.FileManager1', '-o', '/org/freedesktop/FileManager1', '-m', 'org.freedesktop.FileManager1.ShowItems', file_path, "''"])
358+
else:
359+
subprocess.run(['xdg-open', file_path])

0 commit comments

Comments
 (0)