Use the main gui askQuestion function for yes/no dialogs
This commit is contained in:
+7
-10
@@ -31,7 +31,7 @@ import logging
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialog, QVBoxLayout, QComboBox, QListWidget, QAbstractItemView,
|
||||
QListWidgetItem, QDialogButtonBox, QLabel, QMessageBox
|
||||
QListWidgetItem, QDialogButtonBox, QLabel
|
||||
)
|
||||
|
||||
from nw.core import NWDoc
|
||||
@@ -163,15 +163,12 @@ class GuiDocSplit(QDialog):
|
||||
), nwAlert.ERROR)
|
||||
return
|
||||
|
||||
msgBox = QMessageBox()
|
||||
msgRes = msgBox.question(
|
||||
self, "Split Document", (
|
||||
"The document will be split into %d file(s) in a new folder. "
|
||||
"The original document will remain intact.<br><br>"
|
||||
"Continue with the splitting process?"
|
||||
) % nFiles
|
||||
)
|
||||
if msgRes != QMessageBox.Yes:
|
||||
msgYes = self.theParent.askQuestion("Split Document", (
|
||||
"The document will be split into %d file(s) in a new folder. "
|
||||
"The original document will remain intact.<br><br>"
|
||||
"Continue with the splitting process?"
|
||||
) % nFiles)
|
||||
if not msgYes:
|
||||
return
|
||||
|
||||
# Create the folder
|
||||
|
||||
+4
-5
@@ -36,7 +36,7 @@ from PyQt5.QtGui import QKeySequence
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialog, QHBoxLayout, QVBoxLayout, QGridLayout, QPushButton, QTreeWidget,
|
||||
QAbstractItemView, QTreeWidgetItem, QDialogButtonBox, QLabel, QShortcut,
|
||||
QFileDialog, QLineEdit, QMessageBox
|
||||
QFileDialog, QLineEdit
|
||||
)
|
||||
|
||||
from nw.common import formatInt
|
||||
@@ -218,12 +218,11 @@ class GuiProjectLoad(QDialog):
|
||||
"""
|
||||
selList = self.listBox.selectedItems()
|
||||
if selList:
|
||||
msgBox = QMessageBox()
|
||||
msgRes = msgBox.question(
|
||||
self, "Remove Entry",
|
||||
msgYes = self.theParent.askQuestion(
|
||||
"Remove Entry",
|
||||
"Remove the selected entry from the recent projects list?"
|
||||
)
|
||||
if msgRes == QMessageBox.Yes:
|
||||
if msgYes:
|
||||
self.mainConf.removeFromRecentCache(
|
||||
selList[0].data(self.C_NAME, Qt.UserRole)
|
||||
)
|
||||
|
||||
+11
-15
@@ -32,8 +32,7 @@ import logging
|
||||
from PyQt5.QtCore import Qt, QSize
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtWidgets import (
|
||||
qApp, QTreeWidget, QTreeWidgetItem, QAbstractItemView, QMessageBox,
|
||||
QMenu, QAction
|
||||
qApp, QTreeWidget, QTreeWidgetItem, QAbstractItemView, QMenu, QAction
|
||||
)
|
||||
|
||||
from nw.core import NWDoc
|
||||
@@ -391,13 +390,12 @@ class GuiProjectTree(QTreeWidget):
|
||||
self.makeAlert("The Trash folder is already empty.", nwAlert.INFO)
|
||||
return False
|
||||
|
||||
msgBox = QMessageBox()
|
||||
msgRes = msgBox.question(
|
||||
self, "Empty Trash", "Permanently delete %d file%s from Trash?" % (
|
||||
msgYes = self.theParent.askQuestion(
|
||||
"Empty Trash", "Permanently delete %d file%s from Trash?" % (
|
||||
nTrash, "s" if nTrash > 1 else ""
|
||||
)
|
||||
)
|
||||
if msgRes != QMessageBox.Yes:
|
||||
if not msgYes:
|
||||
return False
|
||||
|
||||
logger.verbose("Deleting %d files from Trash" % nTrash)
|
||||
@@ -449,11 +447,10 @@ class GuiProjectTree(QTreeWidget):
|
||||
# user if they want to permanently delete the file.
|
||||
doPermanent = False
|
||||
if not alreadyAsked:
|
||||
msgBox = QMessageBox()
|
||||
msgRes = msgBox.question(
|
||||
self, "Delete File", "Permanently delete file '%s'?" % nwItemS.itemName
|
||||
msgYes = self.theParent.askQuestion(
|
||||
"Delete File", "Permanently delete file '%s'?" % nwItemS.itemName
|
||||
)
|
||||
if msgRes == QMessageBox.Yes:
|
||||
if msgYes:
|
||||
doPermanent = True
|
||||
else:
|
||||
doPermanent = True
|
||||
@@ -478,11 +475,10 @@ class GuiProjectTree(QTreeWidget):
|
||||
# move it there.
|
||||
doTrash = False
|
||||
if askForTrash:
|
||||
msgBox = QMessageBox()
|
||||
msgRes = msgBox.question(
|
||||
self, "Delete File", "Move file '%s' to Trash?" % nwItemS.itemName
|
||||
msgYes = self.theParent.askQuestion(
|
||||
"Delete File", "Move file '%s' to Trash?" % nwItemS.itemName
|
||||
)
|
||||
if msgRes == QMessageBox.Yes:
|
||||
if msgYes:
|
||||
doTrash = True
|
||||
else:
|
||||
doTrash = True
|
||||
@@ -1122,7 +1118,7 @@ class GuiProjectTreeMenu(QMenu):
|
||||
return
|
||||
|
||||
def _doEmptyTrash(self):
|
||||
"""Forward the delete item call to the project tree.
|
||||
"""Forward the empty trash call to the project tree.
|
||||
"""
|
||||
self.theTree.emptyTrash()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user