diff --git a/nw/gui/build.py b/nw/gui/build.py index 7902996d..c4a8fd8b 100644 --- a/nw/gui/build.py +++ b/nw/gui/build.py @@ -774,14 +774,13 @@ class GuiBuildNovel(QDialog): if not os.path.isdir(saveDir): saveDir = self.mainConf.homePath - if self.mainConf.showGUI: - dlgOpt = QFileDialog.Options() - dlgOpt |= QFileDialog.DontUseNativeDialog - savePath, _ = QFileDialog.getSaveFileName( - self, "Save Document As", savePath, options=dlgOpt - ) - if not savePath: - return False + dlgOpt = QFileDialog.Options() + dlgOpt |= QFileDialog.DontUseNativeDialog + savePath, _ = QFileDialog.getSaveFileName( + self, "Save Document As", savePath, options=dlgOpt + ) + if not savePath: + return False self.mainConf.setLastPath(savePath) @@ -887,19 +886,18 @@ class GuiBuildNovel(QDialog): errMsg = "Unknown format" # Report to user - if self.mainConf.showGUI: - if wSuccess: - self.theParent.makeAlert( - "%s file successfully written to:
%s" % ( - textFmt, savePath - ), nwAlert.INFO - ) - else: - self.theParent.makeAlert( - "Failed to write %s file. %s" % ( - textFmt, errMsg - ), nwAlert.ERROR - ) + if wSuccess: + self.theParent.makeAlert( + "%s file successfully written to:
%s" % ( + textFmt, savePath + ), nwAlert.INFO + ) + else: + self.theParent.makeAlert( + "Failed to write %s file. %s" % ( + textFmt, errMsg + ), nwAlert.ERROR + ) return wSuccess diff --git a/nw/guimain.py b/nw/guimain.py index 7e50cfef..37042ca5 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -971,17 +971,16 @@ class GuiMain(QMainWindow): logger.error(msgLine) # Popup - if self.mainConf.showGUI: - msgBox = QMessageBox() - if theLevel == nwAlert.INFO: - msgBox.information(self, "Information", popMsg) - elif theLevel == nwAlert.WARN: - msgBox.warning(self, "Warning", popMsg) - elif theLevel == nwAlert.ERROR: - msgBox.critical(self, "Error", popMsg) - elif theLevel == nwAlert.BUG: - popMsg += "
This is a bug!" - msgBox.critical(self, "Internal Error", popMsg) + msgBox = QMessageBox() + if theLevel == nwAlert.INFO: + msgBox.information(self, "Information", popMsg) + elif theLevel == nwAlert.WARN: + msgBox.warning(self, "Warning", popMsg) + elif theLevel == nwAlert.ERROR: + msgBox.critical(self, "Error", popMsg) + elif theLevel == nwAlert.BUG: + popMsg += "
This is a bug!" + msgBox.critical(self, "Internal Error", popMsg) return diff --git a/tests/test_base_init.py b/tests/test_base_init.py index b691bfa1..9a6daedf 100644 --- a/tests/test_base_init.py +++ b/tests/test_base_init.py @@ -61,7 +61,6 @@ def testBaseInit_Options(monkeypatch, tmpDir): nwGUI = nw.main() assert nw.logger.getEffectiveLevel() == logging.WARNING assert nw.CONFIG.debugInfo is False - assert nw.CONFIG.showGUI is False assert nwGUI.closeMain() == "closeMain" # Defaults diff --git a/tests/test_gui_build.py b/tests/test_gui_build.py index 701312f8..fbc887e3 100644 --- a/tests/test_gui_build.py +++ b/tests/test_gui_build.py @@ -9,7 +9,7 @@ from shutil import copyfile from tools import cmpFiles, getGuiItem from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import QAction, QMessageBox +from PyQt5.QtWidgets import QAction, QMessageBox, QFileDialog from nw.gui import GuiBuildNovel @@ -23,6 +23,8 @@ def testGuiBuild_Tool(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir): """ # Block message box monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) + monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes) + monkeypatch.setattr(QFileDialog, "getSaveFileName", lambda a, b, c, **kwargs: (c, None)) # Check that we cannot open when there is no project nwGUI.mainMenu.aBuildProject.activate(QAction.Trigger)