-
Notifications
You must be signed in to change notification settings - Fork 204
Add alternative toolbar for Formatting options #658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
ec56307
e017435
7f8e22c
06d00f5
2921a5b
c3bdf03
965a559
42337cf
7e7d67a
c4b9ff7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ | |
QSpinBox, | ||
QTabWidget, | ||
QVBoxLayout, | ||
QWidget, | ||
QWidget, QGroupBox, QHBoxLayout, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use one import per line and keep the list sorted (you can use |
||
) | ||
|
||
from ReText import getBundledIcon, getSettingsFilePath, globalSettings | ||
|
@@ -152,7 +152,7 @@ def initConfigOptions(self): | |
(self.tr('Ordered list mode'), 'orderedListMode'), | ||
)), | ||
(self.tr('Interface'), ( | ||
(self.tr('Hide toolbar'), 'hideToolBar'), | ||
(self.tr('Toolbars'), 'hideToolBar'), | ||
(self.tr('Icon theme name'), 'iconTheme'), | ||
(self.tr('Stylesheet file'), 'styleSheet', True), | ||
(self.tr('Hide tabs bar when there is only one tab'), 'tabBarAutoHide'), | ||
|
@@ -222,6 +222,24 @@ def getPageWidget(self, options): | |
self.configurators[name].setCurrentIndex(comboBoxIndex) | ||
elif name == 'directoryPath': | ||
self.configurators[name] = DirectorySelectButton(self, value, fileLabel) | ||
elif name == 'hideToolBar': | ||
# A label that has been created but not yet laid out could remain visible even after its reference has been dropped | ||
label.setParent(None) | ||
label = None | ||
|
||
gb = QGroupBox("Toolbars") | ||
gb.setCheckable(True) | ||
gb.setChecked(not globalSettings.hideToolBar) | ||
|
||
self.configurators[name] = gb | ||
|
||
hBox = QHBoxLayout(gb) | ||
for tb, tbOption in [(self.parent.toolBar, "showToolBarFile"), | ||
(self.parent.editBar, "showToolBarEdit"), | ||
(self.parent.formatBar, "showToolBarFormat"), | ||
]: | ||
self.configurators[tbOption] = self.__create_toolbar_entry(tb) | ||
hBox.addWidget(self.configurators[tbOption]) | ||
elif isinstance(value, bool): | ||
self.configurators[name] = QCheckBox(self) | ||
self.configurators[name].setChecked(value) | ||
|
@@ -240,14 +258,24 @@ def getPageWidget(self, options): | |
elif isinstance(value, str): | ||
self.configurators[name] = QLineEdit(self) | ||
self.configurators[name].setText(value) | ||
layout.addWidget(label, index, 0) | ||
layout.addWidget(self.configurators[name], index, 1, Qt.AlignmentFlag.AlignRight) | ||
|
||
if label: | ||
layout.addWidget(label, index, 0) | ||
layout.addWidget(self.configurators[name], index, 1, Qt.AlignmentFlag.AlignRight) | ||
else: | ||
layout.addWidget(self.configurators[name], index, 0, 1, 2) | ||
|
||
if fileLabel is not None: | ||
index += 1 | ||
layout.addWidget(fileLabel, index, 0, 1, 2) | ||
index += 1 | ||
return page | ||
|
||
def __create_toolbar_entry(selfself, toolbar): | ||
cb = QCheckBox(toolbar.windowTitle()) | ||
cb.setChecked(toolbar.toggleViewAction().isChecked()) | ||
return cb | ||
|
||
def handleRightMarginSet(self, value): | ||
if value < 10: | ||
self.configurators['rightMarginWrap'].setChecked(False) | ||
|
@@ -270,6 +298,10 @@ def saveSettings(self): | |
value = configurator.currentData() | ||
elif isinstance(configurator, FileDialogButton): | ||
value = configurator.fileName | ||
elif isinstance(configurator, QGroupBox) and configurator.isCheckable(): | ||
value = configurator.isChecked() | ||
if name == 'hideToolBar': | ||
value = not value | ||
setattr(globalSettings, name, value) | ||
self.applySettings() | ||
|
||
|
@@ -289,8 +321,13 @@ def applySettings(self): | |
tab.editBox.viewport().update() | ||
self.parent.updateStyleSheet() | ||
self.parent.tabWidget.setTabBarAutoHide(globalSettings.tabBarAutoHide) | ||
self.parent.toolBar.setVisible(not globalSettings.hideToolBar) | ||
self.parent.editBar.setVisible(not globalSettings.hideToolBar) | ||
|
||
self.parent.manage_toolbars_visibility() | ||
self.configurators["showToolBarFile"].setChecked(self.parent.toolBar.toggleViewAction().isChecked()) | ||
self.configurators["showToolBarEdit"].setChecked(self.parent.editBar.toggleViewAction().isChecked()) | ||
self.configurators["showToolBarFormat"].setChecked(self.parent.formatBar.toggleViewAction().isChecked()) | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't use two empty lines inside a function, remove one. |
||
path = globalSettings.directoryPath | ||
self.parent.fileSystemModel.setRootPath(path) | ||
self.parent.treeView.setRootIndex(self.parent.fileSystemModel.index(path)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Icons in this directory are by Pixel Bazaar (header.svg) and TinyMCE (the rest), all licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe these names would sound more naturally in English?