Skip to content

Commit b1efa1a

Browse files
committed
Add Fullscreen actions
1 parent 90424c9 commit b1efa1a

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

src/views/main_window_view.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def __init__(self, MainController: "MainController") -> None:
155155
self._actionLastPage: QAction = QAction(self)
156156
self._actionPreviousComic: QAction = QAction(self)
157157
self._actionNextComic: QAction = QAction(self)
158+
self._actionFullscreen: QAction = QAction(self)
158159
self._actionFitVertical: QAction = QAction(self)
159160
self._actionFitHorizontal: QAction = QAction(self)
160161
self._actionFitOriginal: QAction = QAction(self)
@@ -371,10 +372,7 @@ def _setupActions(self) -> None:
371372
self._setupNavigationActions()
372373

373374
# Fit actions
374-
self._setupFitActions()
375-
376-
# Rotate actions
377-
self._setupRotateActions()
375+
self._setupViewActions()
378376

379377
# About action
380378
self._actionAbout = self._createAction(
@@ -460,12 +458,23 @@ def _setupNavigationActions(self) -> None:
460458
enable=False,
461459
)
462460

463-
def _setupFitActions(self) -> None:
461+
def _setupViewActions(self) -> None:
464462
"""
465463
Configures fit actions for adjusting the content display.
466464
"""
467465
logger.debug("Setting up fit actions")
468466

467+
# Set Fullscreen action
468+
self._actionFullscreen = self._createAction(
469+
iconName="fullscreen",
470+
text=self.tr("Fullscreen"),
471+
objectName="actionFullscreen",
472+
shortcut="F",
473+
slot=self.onActionFullscreenTriggered,
474+
checkable=True,
475+
enable=True,
476+
)
477+
469478
# Fit Vertical action
470479
self._actionFitVertical = self._createAction(
471480
iconName="fit_page_height",
@@ -526,10 +535,6 @@ def _setupFitActions(self) -> None:
526535
for act in self._actionFitGroup.actions():
527536
act.setChecked(self._mainController.getCurrentFitMode() == act.objectName())
528537

529-
def _setupRotateActions(self) -> None:
530-
"""
531-
Configures rotate actions for rotating the content.
532-
"""
533538
logger.debug("Setting up rotate actions")
534539

535540
# Rotate Left action
@@ -567,6 +572,8 @@ def _setupMenuBar(self) -> None:
567572
self._menuFile.addAction(self._actionExit)
568573

569574
self._menuView = QMenu(self._menuBar, title=self.tr("&View"))
575+
self._menuView.addAction(self._actionFullscreen)
576+
self._menuView.addSeparator()
570577
self._menuView.addActions(self._actionFitGroup.actions())
571578
self._menuView.addSeparator()
572579
self._menuView.addAction(self._actionRotateLeft)
@@ -681,10 +688,10 @@ def _setupGlobalShortcuts(self) -> None:
681688
logger.debug("Setting up global shortcuts")
682689

683690
# Shortcut to toggle fullscreen mode using the "F" key
684-
self.fullScreenShortcut = QShortcut(
685-
QKeySequence("F"), self, self.onActionFullscreenTriggered
686-
)
687-
self.fullScreenShortcut.setEnabled(True)
691+
# self.fullScreenShortcut = QShortcut(
692+
# QKeySequence("F"), self, self.onActionFullscreenTriggered
693+
# )
694+
# self.fullScreenShortcut.setEnabled(True)
688695

689696
# Shortcut to close the application using "Ctrl+Q"
690697
self.closeShortcut = QShortcut(QKeySequence("Ctrl+Q"), self, self.close)
@@ -699,6 +706,8 @@ def _setupGlobalShortcuts(self) -> None:
699706
"Ctrl+Right": self._mainController.onActionLastPageTriggered, # Navigate to last page
700707
"Right": self._mainController.onActionNextPageTriggered, # Navigate to next page
701708
"Left": self._mainController.onActionPreviousPageTriggered, # Navigate to previous page
709+
"F": self.onActionFullscreenTriggered, # Toggle fullscreen
710+
"ESC": self.onActionFullscreenTriggered, # Out fullscreen
702711
}
703712

704713
# Create and configure shortcuts, initially disabled for fullscreen mode
@@ -943,6 +952,7 @@ def onActionFullscreenTriggered(self):
943952
# Check if the window is currently in fullscreen mode
944953
if self.isFullScreen():
945954
self._toolBar.show() # Show the toolbar
955+
self._menuBar.show()
946956
self.showNormal() # Restore the window to normal mode
947957
self._mainController.updateCentralWidgetContent() # Update the central widget content
948958

@@ -954,6 +964,7 @@ def onActionFullscreenTriggered(self):
954964
# Enter fullscreen mode
955965
self.showFullScreen() # Switch the window to fullscreen mode
956966
self._toolBar.hide()
967+
self._menuBar.hide()
957968
self._mainController.updateCentralWidgetContent() # Update the central widget content
958969

959970
# Enable global shortcuts when entering fullscreen mode

0 commit comments

Comments
 (0)