Let the shared class handle alert dialogs

This commit is contained in:
Veronica Berglyd Olsen
2023-08-14 17:08:53 +02:00
parent 3441ff38de
commit a17e73b5a2
17 changed files with 107 additions and 236 deletions
+3 -8
View File
@@ -34,7 +34,6 @@ from PyQt5.QtWidgets import (
)
from novelwriter import CONFIG, SHARED
from novelwriter.enum import nwAlert
from novelwriter.core.spellcheck import UserDictionary
if TYPE_CHECKING: # pragma: no cover
@@ -52,8 +51,6 @@ class GuiWordList(QDialog):
self.setObjectName("GuiWordList")
self.setWindowTitle(self.tr("Project Word List"))
self.mainGui = mainGui
mS = CONFIG.pxInt(250)
wW = CONFIG.pxInt(320)
wH = CONFIG.pxInt(340)
@@ -123,15 +120,13 @@ class GuiWordList(QDialog):
"""Add a new word to the word list."""
word = self.newEntry.text().strip()
if word == "":
self.mainGui.makeAlert(self.tr(
"Cannot add a blank word."
), level=nwAlert.ERROR)
SHARED.error(self.tr("Cannot add a blank word."))
return
if self.listBox.findItems(word, Qt.MatchExactly):
self.mainGui.makeAlert(self.tr(
SHARED.error(self.tr(
"The word '{0}' is already in the word list."
).format(word), level=nwAlert.ERROR)
).format(word))
return
self.listBox.addItem(word)