|
8 | 8 | import webbrowser |
9 | 9 | from functools import partial |
10 | 10 | import time |
| 11 | +import tempfile |
11 | 12 |
|
12 | 13 | # External |
13 | 14 | from Qt import QtWidgets |
@@ -1252,6 +1253,8 @@ def __init__(self, parent=None): |
1252 | 1253 | # Help Menu |
1253 | 1254 | self.help_menu = self.addMenu('Help') |
1254 | 1255 | self.help_menu.setTearOffEnabled(True) |
| 1256 | + logs_dir_action = self.help_menu.addAction('Open Logs Dir') |
| 1257 | + logs_dir_action.triggered.connect(self.open_logs_dir) |
1255 | 1258 | prefs_dir_action = self.help_menu.addAction('Open Prefs Dir') |
1256 | 1259 | prefs_dir_action.triggered.connect(self.open_prefs_dir) |
1257 | 1260 | config_dir_action = self.help_menu.addAction('Open Plugins Dir') |
@@ -1335,29 +1338,26 @@ def window_action_triggered(self, action=None): |
1335 | 1338 |
|
1336 | 1339 | @staticmethod |
1337 | 1340 | def open_prefs_dir(): |
1338 | | - d = user_dir.PREF_DIR |
1339 | | - if 'darwin' in sys.platform: |
1340 | | - os.system('open {}'.format(d)) |
1341 | | - elif 'win' in sys.platform: |
1342 | | - os.startfile(d) |
1343 | | - else: |
1344 | | - try: |
1345 | | - os.system('xdg-open {}'.format(d)) |
1346 | | - except: |
1347 | | - logger.exception('Failed to open user dir') |
| 1341 | + QtGui.QDesktopServices.openUrl( |
| 1342 | + QtCore.QUrl.fromLocalFile(user_dir.PREF_DIR) |
| 1343 | + ) |
1348 | 1344 |
|
1349 | 1345 | @staticmethod |
1350 | 1346 | def open_plugins_dir(): |
1351 | | - d = USER_PLUGIN_DIR |
1352 | | - if 'darwin' in sys.platform: |
1353 | | - os.system('open {}'.format(d)) |
1354 | | - elif 'win' in sys.platform: |
1355 | | - os.startfile(d) |
1356 | | - else: |
1357 | | - try: |
1358 | | - os.system('xdg-open {}'.format(d)) |
1359 | | - except: |
1360 | | - logger.exception('Failed to open user config dir') |
| 1347 | + QtGui.QDesktopServices.openUrl( |
| 1348 | + QtCore.QUrl.fromLocalFile(USER_PLUGIN_DIR) |
| 1349 | + ) |
| 1350 | + |
| 1351 | + @staticmethod |
| 1352 | + def open_logs_dir(): |
| 1353 | + try: |
| 1354 | + log_dir = nxt_log.LOG_DIR |
| 1355 | + except AttributeError: |
| 1356 | + # Guess the log dir if nxt core is old. |
| 1357 | + log_dir = os.path.join(tempfile.gettempdir(), 'nxt_logs') |
| 1358 | + QtGui.QDesktopServices.openUrl( |
| 1359 | + QtCore.QUrl.fromLocalFile(log_dir) |
| 1360 | + ) |
1361 | 1361 |
|
1362 | 1362 | def about_message(self): |
1363 | 1363 | text = ('nxt {} \n' |
|
0 commit comments