Clean up dialogs

This commit is contained in:
Veronica Berglyd Olsen
2023-11-27 17:10:29 +01:00
parent 93b36406f1
commit 4fa20273f7
10 changed files with 117 additions and 113 deletions
+12 -4
View File
@@ -26,7 +26,8 @@ from __future__ import annotations
import logging
from PyQt5.QtWidgets import (
QDialog, QVBoxLayout, QLineEdit, QLabel, QDialogButtonBox, QHBoxLayout
QDialog, QDialogButtonBox, QHBoxLayout, QLabel, QLineEdit, QVBoxLayout,
QWidget
)
from novelwriter import CONFIG
@@ -36,9 +37,10 @@ logger = logging.getLogger(__name__)
class GuiEditLabel(QDialog):
def __init__(self, parent, text=""):
def __init__(self, parent: QWidget, text: str = "") -> None:
super().__init__(parent=parent)
logger.debug("Create: GuiEditLabel")
self.setObjectName("GuiEditLabel")
self.setWindowTitle(self.tr("Item Label"))
@@ -70,14 +72,20 @@ class GuiEditLabel(QDialog):
self.setLayout(self.outerBox)
logger.debug("Ready: GuiEditLabel")
return
def __del__(self) -> None: # pragma: no cover
logger.debug("Delete: GuiEditLabel")
return
@property
def itemLabel(self):
def itemLabel(self) -> str:
return self.labelValue.text()
@classmethod
def getLabel(cls, parent, text):
def getLabel(cls, parent: QWidget, text: str) -> tuple[str, bool]:
cls = GuiEditLabel(parent, text=text)
cls.exec_()
return cls.itemLabel, cls.result() == QDialog.Accepted