Skip to content

Commit 7242bfd

Browse files
committed
Add a combination (F9) to show/hide directory tree dynamically
1 parent 98f6346 commit 7242bfd

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

ReText/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ def applySettings(self):
261261
self.parent.tabWidget.setTabBarAutoHide(globalSettings.tabBarAutoHide)
262262
self.parent.toolBar.setVisible(not globalSettings.hideToolBar)
263263
self.parent.editBar.setVisible(not globalSettings.hideToolBar)
264-
self.parent.initDirectoryTree(globalSettings.showDirectoryTree, globalSettings.directoryPath)
264+
self.parent.actionShowDirectoryTree.setChecked(globalSettings.showDirectoryTree)
265+
self.parent.initDirectoryTree(globalSettings.showDirectoryTree)
265266
if globalSettings.autoSave:
266267
self.parent.autoSaveTimer.start(60000)
267268
else:

ReText/window.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(self, parent=None):
8383
self.tabWidget = QTabWidget(self.splitter)
8484
self.initTabWidget()
8585
self.splitter.setSizes([self.width() // 5, self.width() * 4 // 5])
86-
self.initDirectoryTree(globalSettings.showDirectoryTree, globalSettings.directoryPath)
86+
self.initDirectoryTree(globalSettings.showDirectoryTree)
8787
self.setCentralWidget(self.splitter)
8888
self.tabWidget.currentChanged.connect(self.changeIndex)
8989
self.tabWidget.tabCloseRequested.connect(self.closeTab)
@@ -211,6 +211,10 @@ def __init__(self, parent=None):
211211
self.actionWebEngine.setEnabled(False)
212212
self.actionWebEngine.setChecked(globalSettings.useWebEngine)
213213
self.actionShow = self.act(self.tr('Show directory'), 'system-file-manager', self.showInDir)
214+
self.actionShowDirectoryTree = self.act(self.tr('Show directory tree'),
215+
trigbool=self.initDirectoryTree,
216+
shct=Qt.Key.Key_F9)
217+
self.actionShowDirectoryTree.setChecked(globalSettings.showDirectoryTree)
214218
self.actionFind = self.act(self.tr('Next'), 'go-next', self.find,
215219
shct=QKeySequence.StandardKey.FindNext)
216220
self.actionFindPrev = self.act(self.tr('Previous'), 'go-previous',
@@ -274,6 +278,7 @@ def __init__(self, parent=None):
274278
self.menuRecentFiles = menuFile.addMenu(self.tr('Open recent'))
275279
self.menuRecentFiles.aboutToShow.connect(self.updateRecentFiles)
276280
menuFile.addAction(self.actionShow)
281+
menuFile.addAction(self.actionShowDirectoryTree)
277282
menuFile.addAction(self.actionSetEncoding)
278283
menuFile.addAction(self.actionReload)
279284
menuFile.addSeparator()
@@ -440,7 +445,8 @@ def dropEvent(e):
440445
self.tabWidget.dropEvent = dropEvent
441446
self.tabWidget.setTabBarAutoHide(globalSettings.tabBarAutoHide)
442447

443-
def initDirectoryTree(self, visible, path):
448+
def initDirectoryTree(self, visible):
449+
path = globalSettings.directoryPath
444450
if visible:
445451
self.fileSystemModel = QFileSystemModel(self.treeView)
446452
self.fileSystemModel.setRootPath(path)

0 commit comments

Comments
 (0)