From 6f1aa5b8127104c7f0dfb67f0cd015cf9884216d Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 6 Aug 2023 14:49:35 +0200 Subject: [PATCH] Remove fullscreen setting in config file --- novelwriter/config.py | 9 ++---- novelwriter/guimain.py | 28 ++++--------------- tests/reference/baseConfig_novelwriter.conf | 3 +- .../reference/guiPreferences_novelwriter.conf | 7 ++--- tests/test_gui/test_gui_guimain.py | 6 ++-- 5 files changed, 16 insertions(+), 37 deletions(-) diff --git a/novelwriter/config.py b/novelwriter/config.py index e6a13373..60e750a9 100644 --- a/novelwriter/config.py +++ b/novelwriter/config.py @@ -175,10 +175,9 @@ class Config: self.spellLanguage = "en" # State - self.isFullScreen = False # Last fullscreen state - self.showRefPanel = True # The reference panel for the viewer is visible - self.viewComments = True # Comments are shown in the viewer - self.viewSynopsis = True # Synopsis is shown in the viewer + self.showRefPanel = True # The reference panel for the viewer is visible + self.viewComments = True # Comments are shown in the viewer + self.viewSynopsis = True # Synopsis is shown in the viewer # Search Bar Switches self.searchCase = False @@ -603,7 +602,6 @@ class Config: # State cnfSec = "State" - self.isFullScreen = theConf.rdBool(cnfSec, "fullscreen", self.isFullScreen) self.showRefPanel = theConf.rdBool(cnfSec, "showrefpanel", self.showRefPanel) self.viewComments = theConf.rdBool(cnfSec, "viewcomments", self.viewComments) self.viewSynopsis = theConf.rdBool(cnfSec, "viewsynopsis", self.viewSynopsis) @@ -732,7 +730,6 @@ class Config: } theConf["State"] = { - "fullscreen": str(self.isFullScreen), "showrefpanel": str(self.showRefPanel), "viewcomments": str(self.viewComments), "viewsynopsis": str(self.viewSynopsis), diff --git a/novelwriter/guimain.py b/novelwriter/guimain.py index 90904cc8..f50e6cec 100644 --- a/novelwriter/guimain.py +++ b/novelwriter/guimain.py @@ -313,8 +313,6 @@ class GuiMain(QMainWindow): # Handle Windows Mode self.showNormal() - if CONFIG.isFullScreen: - self.toggleFullScreenMode() logger.debug("Ready: GUI") @@ -1188,9 +1186,8 @@ class GuiMain(QMainWindow): # Main Window Actions ## - def closeMain(self): - """Save everything, and close novelWriter. - """ + def closeMain(self) -> bool: + """Save everything, and close novelWriter.""" if self.hasProject: msgYes = self.askQuestion( self.tr("Exit"), @@ -1211,7 +1208,8 @@ class GuiMain(QMainWindow): CONFIG.setViewPanePos(self.splitView.sizes()) CONFIG.showRefPanel = self.viewMeta.isVisible() - if not CONFIG.isFullScreen: + if self.windowState() & Qt.WindowFullScreen != Qt.WindowFullScreen: + # Ignore window size if in full screen mode CONFIG.setMainWinSize(self.width(), self.height()) if self.hasProject: @@ -1297,23 +1295,9 @@ class GuiMain(QMainWindow): return True - def toggleFullScreenMode(self): - """Main GUI full screen mode. The mode is tracked by the flag - in config. This only tracks whether the window has been - maximised using the internal commands, and may not be correct - if the user uses the system window manager. Currently, Qt - doesn't have access to the exact state of the window. - """ + def toggleFullScreenMode(self) -> None: + """Toggle full screen mode""" self.setWindowState(self.windowState() ^ Qt.WindowFullScreen) - - winState = self.windowState() & Qt.WindowFullScreen == Qt.WindowFullScreen - if winState: - logger.debug("Activated full screen mode") - else: - logger.debug("Deactivated full screen mode") - - CONFIG.isFullScreen = winState - return ## diff --git a/tests/reference/baseConfig_novelwriter.conf b/tests/reference/baseConfig_novelwriter.conf index fa12d483..50f12524 100644 --- a/tests/reference/baseConfig_novelwriter.conf +++ b/tests/reference/baseConfig_novelwriter.conf @@ -1,5 +1,5 @@ [Meta] -timestamp = 2023-05-31 10:52:21 +timestamp = 2023-08-02 14:53:36 [Main] theme = default @@ -69,7 +69,6 @@ stopwhenidle = True useridletime = 300 [State] -fullscreen = False showrefpanel = True viewcomments = True viewsynopsis = True diff --git a/tests/reference/guiPreferences_novelwriter.conf b/tests/reference/guiPreferences_novelwriter.conf index 672f6f7b..de16e4e6 100644 --- a/tests/reference/guiPreferences_novelwriter.conf +++ b/tests/reference/guiPreferences_novelwriter.conf @@ -1,5 +1,5 @@ [Meta] -timestamp = 2022-11-11 12:48:20 +timestamp = 2023-08-02 14:53:40 [Main] theme = default @@ -10,11 +10,11 @@ localisation = en_GB hidevscroll = True hidehscroll = True lastnotes = 0x0 -lastpath = /home/vkbo/Code/novelWriter/Source/tests/temp/function +lastpath = [Sizes] mainwindow = 1200, 650 -preferences = 699, 614 +preferences = 765, 614 projloadcols = 280, 60, 160 mainpane = 300, 800 viewpane = 500, 150 @@ -69,7 +69,6 @@ stopwhenidle = True useridletime = 300 [State] -fullscreen = False showrefpanel = True viewcomments = True viewsynopsis = True diff --git a/tests/test_gui/test_gui_guimain.py b/tests/test_gui/test_gui_guimain.py index 7c49585d..17dc381f 100644 --- a/tests/test_gui/test_gui_guimain.py +++ b/tests/test_gui/test_gui_guimain.py @@ -590,11 +590,11 @@ def testGuiMain_FocusFullMode(qtbot, nwGUI, projPath, mockRnd): # Full Screen Mode # ================ - assert CONFIG.isFullScreen is False + assert nwGUI.windowState() & Qt.WindowFullScreen != Qt.WindowFullScreen nwGUI.toggleFullScreenMode() - assert CONFIG.isFullScreen is True + assert nwGUI.windowState() & Qt.WindowFullScreen == Qt.WindowFullScreen nwGUI.toggleFullScreenMode() - assert CONFIG.isFullScreen is False + assert nwGUI.windowState() & Qt.WindowFullScreen != Qt.WindowFullScreen # qtbot.stop()