Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ReText/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def getBundledIcon(iconName):
'font': '',
'handleWebLinks': False,
'hideToolBar': False,
'showToolBarFile': True,
'showToolBarEdit': True,
'showToolBarFormat': True,
Comment on lines +62 to +64
Copy link
Member

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?

Suggested change
'showToolBarFile': True,
'showToolBarEdit': True,
'showToolBarFormat': True,
'showFileToolBar': True,
'showEditToolBar': True,
'showFormatToolBar': True,

'highlightCurrentLine': 'disabled',
'iconTheme': '',
'lineNumbersEnabled': False,
Expand Down
49 changes: 43 additions & 6 deletions ReText/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
QSpinBox,
QTabWidget,
QVBoxLayout,
QWidget,
QWidget, QGroupBox, QHBoxLayout,
Copy link
Member

Choose a reason for hiding this comment

The 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 isort tool for that).

)

from ReText import getBundledIcon, getSettingsFilePath, globalSettings
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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()

Expand All @@ -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())


Copy link
Member

Choose a reason for hiding this comment

The 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))
Expand Down
10 changes: 6 additions & 4 deletions ReText/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,14 @@
'urlPopupBorder': {'light': '#64323232', 'dark': '#64fafafa'},
}

colorValues = {}

def updateColorScheme(settings=settings):
def detectThemeVariant():
palette = QApplication.palette()
windowColor = palette.color(QPalette.ColorRole.Window)
themeVariant = 'light' if windowColor.lightness() > 150 else 'dark'
return 'light' if windowColor.lightness() > 150 else 'dark'

colorValues = {}
def updateColorScheme(settings=settings):
themeVariant = detectThemeVariant()
settings.beginGroup('ColorScheme')
for key in colors:
if settings.contains(key):
Expand Down
2 changes: 2 additions & 0 deletions ReText/icons/format/README.md
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/).

10 changes: 10 additions & 0 deletions ReText/icons/format/dark/blockquote.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions ReText/icons/format/dark/bold.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions ReText/icons/format/dark/bullets.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions ReText/icons/format/dark/code block.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions ReText/icons/format/dark/header.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions ReText/icons/format/dark/image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions ReText/icons/format/dark/inline code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions ReText/icons/format/dark/italic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading