Added exit yes/no dialog
This commit is contained in:
+2
-3
@@ -13,7 +13,7 @@
|
||||
import logging
|
||||
import nw
|
||||
|
||||
from PyQt5.QtWidgets import qApp, QMenuBar, QAction, QMessageBox
|
||||
from PyQt5.QtWidgets import QMenuBar, QAction, QMessageBox
|
||||
from PyQt5.QtGui import QIcon
|
||||
|
||||
from nw.enum import nwItemType, nwItemClass, nwDocAction
|
||||
@@ -91,8 +91,7 @@ class GuiMainMenu(QMenuBar):
|
||||
|
||||
def _menuExit(self):
|
||||
self.theParent.closeMain()
|
||||
qApp.quit()
|
||||
return True
|
||||
return
|
||||
|
||||
def _toggleSpellCheck(self):
|
||||
self.theProject.setSpellCheck(self.toolsSpellCheck.isChecked())
|
||||
|
||||
+16
-4
@@ -14,7 +14,7 @@ import logging
|
||||
import nw
|
||||
|
||||
from os import path
|
||||
from PyQt5.QtWidgets import QWidget, QMainWindow, QVBoxLayout, QFrame, QSplitter, QFileDialog, QStackedWidget, QShortcut, QMessageBox
|
||||
from PyQt5.QtWidgets import qApp, QWidget, QMainWindow, QVBoxLayout, QFrame, QSplitter, QFileDialog, QStackedWidget, QShortcut, QMessageBox
|
||||
from PyQt5.QtGui import QIcon, QPixmap, QColor
|
||||
from PyQt5.QtCore import Qt, QTimer
|
||||
|
||||
@@ -428,7 +428,17 @@ class GuiMain(QMainWindow):
|
||||
# Main Window Actions
|
||||
##
|
||||
|
||||
def closeMain(self):
|
||||
def closeMain(self, isYes=False):
|
||||
|
||||
if not isYes:
|
||||
msgBox = QMessageBox()
|
||||
msgRes = msgBox.question(
|
||||
self, "Exit",
|
||||
"Do you want to exit %s?" % nw.__package__
|
||||
)
|
||||
if msgRes != QMessageBox.Yes:
|
||||
return False
|
||||
|
||||
logger.info("Exiting %s" % nw.__package__)
|
||||
if self._takeDocumentAction():
|
||||
self.saveDocument()
|
||||
@@ -439,7 +449,10 @@ class GuiMain(QMainWindow):
|
||||
self.mainConf.setMainPanePos(self.splitMain.sizes())
|
||||
self.mainConf.setDocPanePos(self.splitView.sizes())
|
||||
self.mainConf.saveConfig()
|
||||
return
|
||||
|
||||
qApp.quit()
|
||||
|
||||
return True
|
||||
|
||||
def setFocus(self, paneNo):
|
||||
if paneNo == 1:
|
||||
@@ -526,7 +539,6 @@ class GuiMain(QMainWindow):
|
||||
|
||||
def closeEvent(self, theEvent):
|
||||
self.closeMain()
|
||||
QMainWindow.closeEvent(self,theEvent)
|
||||
return
|
||||
|
||||
##
|
||||
|
||||
@@ -155,6 +155,7 @@ def testMainWindows(qtbot, nwTempGUI, nwRef):
|
||||
sceneFile = path.join(nwTempGUI,"data_3","1489056e0916_main.nwd")
|
||||
assert cmpFiles(sceneFile, path.join(nwRef,"gui","1_1489056e0916_main.nwd"))
|
||||
|
||||
nwGUI.closeMain(True)
|
||||
# qtbot.stopForInteraction()
|
||||
|
||||
@pytest.mark.gui
|
||||
@@ -216,6 +217,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef):
|
||||
projFile = path.join(nwTempGUI,"nwProject.nwx")
|
||||
assert cmpFiles(projFile, path.join(nwRef,"gui","2_nwProject.nwx"), [2])
|
||||
|
||||
nwGUI.closeMain(True)
|
||||
# qtbot.stopForInteraction()
|
||||
|
||||
@pytest.mark.gui
|
||||
@@ -261,4 +263,5 @@ def testItemEditor(qtbot, nwTempGUI, nwRef):
|
||||
projFile = path.join(nwTempGUI,"nwProject.nwx")
|
||||
assert cmpFiles(projFile, path.join(nwRef,"gui","3_nwProject.nwx"), [2])
|
||||
|
||||
nwGUI.closeMain(True)
|
||||
# qtbot.stopForInteraction()
|
||||
|
||||
Reference in New Issue
Block a user