Skip to content

Commit 385c38a

Browse files
committed
Move toolbars creation code to a common place
1 parent 6387883 commit 385c38a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

ReText/window.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
ReTextWebEnginePreview,
3939
)
4040
from ReText.tabledialog import InsertTableDialog
41-
from ReText import retext_rc
4241
from ReText.editor import detectThemeVariant
42+
from ReText import retext_rc
4343

4444
try:
4545
from ReText.fakevimeditor import FakeVimMode, ReTextFakeVimHandler
@@ -146,12 +146,6 @@ def __init__(self, parent=None):
146146
self.setCentralWidget(self.splitter)
147147
self.tabWidget.currentChanged.connect(self.changeIndex)
148148
self.tabWidget.tabCloseRequested.connect(self.closeTab)
149-
self.toolBar = QToolBar(self.tr('File toolbar'), self)
150-
self.addToolBar(Qt.ToolBarArea.TopToolBarArea, self.toolBar)
151-
self.editBar = QToolBar(self.tr('Edit toolbar'), self)
152-
self.addToolBar(Qt.ToolBarArea.TopToolBarArea, self.editBar)
153-
self.searchBar = QToolBar(self.tr('Search toolbar'), self)
154-
self.addToolBar(Qt.ToolBarArea.BottomToolBarArea, self.searchBar)
155149

156150
self._create_actions()
157151
self._create_menus()
@@ -226,7 +220,7 @@ def _create_actions(self):
226220
self.search, shct=QKeySequence.StandardKey.Find)
227221
self.actionGoToLine = self.act(self.tr('Go to line'),
228222
trig=self.goToLine, shct=Qt.Modifier.CTRL | Qt.Key.Key_G)
229-
self.searchBar.visibilityChanged.connect(self.searchBarVisibilityChanged)
223+
230224
self.actionPreview = self.act(self.tr('Preview'), shct=Qt.Modifier.CTRL | Qt.Key.Key_E,
231225
trigbool=self.preview)
232226
if QIcon.hasThemeIcon('document-preview'):
@@ -354,6 +348,9 @@ def _create_toolbars(self):
354348
self.manage_toolbars_visibility()
355349

356350
def _create_toolbar_file(self):
351+
self.toolBar = QToolBar(self.tr('File toolbar'), self)
352+
self.addToolBar(Qt.ToolBarArea.TopToolBarArea, self.toolBar)
353+
357354
self.toolBar.addAction(self.actionNew)
358355
self.toolBar.addSeparator()
359356
self.toolBar.addAction(self.actionOpen)
@@ -379,6 +376,9 @@ def __populate_combo(self, parent, title, items, handler):
379376
return cb
380377

381378
def _create_toolbar_edit(self):
379+
self.editBar = QToolBar(self.tr('Edit toolbar'), self)
380+
self.addToolBar(Qt.ToolBarArea.TopToolBarArea, self.editBar)
381+
382382
self.editBar.addAction(self.actionUndo)
383383
self.editBar.addAction(self.actionRedo)
384384
self.editBar.addSeparator()
@@ -400,6 +400,11 @@ def _create_toolbar_edit(self):
400400
self.editBar.addWidget(self.symbolBox)
401401

402402
def _create_toolbar_search(self):
403+
self.searchBar = QToolBar(self.tr('Search toolbar'), self)
404+
self.addToolBar(Qt.ToolBarArea.BottomToolBarArea, self.searchBar)
405+
406+
self.searchBar.visibilityChanged.connect(self.searchBarVisibilityChanged)
407+
403408
self.searchEdit = QLineEdit(self.searchBar)
404409
self.searchEdit.setPlaceholderText(self.tr('Search'))
405410
self.searchEdit.returnPressed.connect(self.find)

0 commit comments

Comments
 (0)