Added "Close" button in some widget toolbar.

This add supports for window closing where there
is no traffic light control for "WindowModal" on macOS

Signed-off-by: LorenEteval <loren.eteval@proton.me>
This commit is contained in:
LorenEteval
2026-06-21 15:56:19 +08:00
committed by Loren Eteval
parent bc50fa5a8b
commit 890d7a559d
3 changed files with 68 additions and 50 deletions
+13 -15
View File
@@ -76,21 +76,7 @@ class TextEditorWindow(AppQMainWindow):
super().__init__(*args, **kwargs)
self.customWindowTitle = ''
if PLATFORM == 'Darwin':
# Window-modal child windows are rendered as macOS sheets
# without traffic-light controls.
self.setWindowFlags(
self.windowFlags()
| QtCore.Qt.WindowType.Window
| QtCore.Qt.WindowType.WindowTitleHint
| QtCore.Qt.WindowType.WindowSystemMenuHint
| QtCore.Qt.WindowType.WindowMinimizeButtonHint
| QtCore.Qt.WindowType.WindowCloseButtonHint
)
self.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
else:
self.setWindowModality(QtCore.Qt.WindowModality.WindowModal)
self.setWindowModality(QtCore.Qt.WindowModality.WindowModal)
self.setFixedSize(450, int(450 * GOLDEN_RATIO))
@@ -121,6 +107,18 @@ class TextEditorWindow(AppQMainWindow):
self.setCentralWidget(self.jsonEditor)
if PLATFORM == 'Darwin':
self.toolbar = AppQToolBar(
AppQAction(
_('Close'),
icon=bootstrapIcon('window-x.svg'),
callback=lambda: self.close(),
),
parent=self,
)
self.addToolBar(self.toolbar)
self.fileMenu = AppQMenu(
AppQAction(
_('Save'),