|
1 | | -import os |
| 1 | +import os, sys |
2 | 2 | import ctypes |
3 | 3 | from PyQt6 import QtCore, QtGui, QtWidgets |
| 4 | +import subprocess |
4 | 5 |
|
5 | 6 | from Extensions_Qt6 import StyleSheet |
6 | 7 |
|
7 | | - |
8 | 8 | class ManageShortcuts(QtWidgets.QLabel): |
9 | 9 |
|
10 | 10 | updateShortcuts = QtCore.pyqtSignal() |
@@ -101,7 +101,7 @@ def removeShorcut(self): |
101 | 101 | self.loadShortcuts() |
102 | 102 |
|
103 | 103 | def addShortcut(self): |
104 | | - options = QtWidgets.QFileDialog.DontResolveSymlinks | QtWidgets.QFileDialog.ShowDirsOnly |
| 104 | + options = QtWidgets.QFileDialog.Option.DontResolveSymlinks | QtWidgets.QFileDialog.Option.ShowDirsOnly |
105 | 105 | directory = QtWidgets.QFileDialog.getExistingDirectory(self, |
106 | 106 | "Select directory", self.useData.getLastOpenedDir(), options) |
107 | 107 | if directory: |
@@ -347,5 +347,13 @@ def locate(self): |
347 | 347 | path_index = indexList[0] |
348 | 348 | file_path = \ |
349 | 349 | 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