Skip to content

Conversation

sendevent
Copy link

This PR introduces an alternative way to display the list of available Formatting options in the toolbar. Instead of using a combobox, users can now enable a dedicated toolbar for one-click access. The default combobox is displayed when the new toolbar is disabled via the Configuration dialog or the toolbars' context menu.

Additionally, this PR includes:

  • Small refactorings in window.py to improve the code structure.
  • Adjustments to the Config dialog, specifically in the Interface tab, to enhance organization.

retext_1200_20

@sendevent sendevent force-pushed the dengof_add_formatting_toolbar branch from 6914bf1 to c4b9ff7 Compare March 9, 2025 19:54
Copy link
Member

@mitya57 mitya57 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for delay with reviewing this. I have left some comments now.

Comment on lines +62 to +64
'showToolBarFile': True,
'showToolBarEdit': True,
'showToolBarFormat': True,
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,

@@ -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).

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.

<RCC>
<qresource prefix="/icn_format">
<file>icons/format/light/blockquote.svg</file>
<file>icons/format/light/bold.svg</file>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least for bold, italics and underline (and probably also for images, bullets and numbering), it is possible to use theme icons:

If the icons exist in the user theme, then it’s preferable to use those, otherwise we use the built-in ones.

But for the built-in ones, please use the existing mechanism (getBundledIcon function) instead of inventing a new one. This way you won't need the ugly retext_rc.py file.

@@ -38,6 +38,8 @@
ReTextWebEnginePreview,
)
from ReText.tabledialog import InsertTableDialog
from ReText.editor import detectThemeVariant
from ReText import retext_rc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this to line 29 instead.

def _create_menus(self):
self._create_menu_file()
self._create_menu_edit()
self._create_menu_help()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, maybe better to name createFileMenu, createEditMenu, createHelpMenu, etc?

By the way, this file uses camelCase for consistency with Qt. Also, there is no need for leading underscore, since effectively everything is private.

Also, I would be extra grateful if you submit this refactoring as a separate PR, this way I can merge it sooner.

@sendevent
Copy link
Author

Sorry for delay with reviewing this. I have left some comments now.

Sure thing, I'll handle all these in a few days, probably this weekend.

Regarding the code formatting, do you use any automation tools so you could share its settings?

@mitya57
Copy link
Member

mitya57 commented Mar 27, 2025

Regarding the code formatting, do you use any automation tools so you could share its settings?

In new code I use black or ruff format (which use similar style), but ReText is very old code that doesn't use any best practices for formatting (it even had tabs until recently). And reformatting it would make git blame unusable.

Adding new black-style code is good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants