Replace OptionsPage error property with clearer initialized property

- drop tooltip, as error is clear displayed in the page anyway
- technically those exceptions happen during `__init__()` not `load()`, so that's less ambiguous
This commit is contained in:
Laurent Monin
2024-04-28 18:32:43 +02:00
parent 200028f2c7
commit b80f4d698e
2 changed files with 6 additions and 6 deletions

View File

@@ -55,8 +55,8 @@ class OptionsPage(QtWidgets.QWidget):
STYLESHEET_ERROR = "QWidget { background-color: #f55; color: white; font-weight:bold; padding: 2px; }"
STYLESHEET = "QLabel { qproperty-wordWrap: true; }"
initialized = False
loaded = False
error = None
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

View File

@@ -108,10 +108,10 @@ class ErrorOptionsPage(OptionsPage):
super().__init__(parent)
self.error = _("This page failed to load")
self.error = _("This page failed to initialize")
title_widget = QtWidgets.QLabel(
_("Error while loading option page '%s':")
_("Error while initializing option page '%s':")
% _(from_cls.TITLE)
)
@@ -153,9 +153,8 @@ class OptionsDialog(PicardDialog, SingletonDialog):
items = []
for foo, bar, page in sorted(pages):
item = HashableTreeWidgetItem(parent_item)
if page.error:
if not page.initialized:
title = _("%s (error)") % _(page.TITLE)
item.setToolTip(0, page.error)
else:
title = _(page.TITLE)
item.setText(0, title)
@@ -212,6 +211,7 @@ class OptionsDialog(PicardDialog, SingletonDialog):
try:
page = Page()
page.set_dialog(self)
page.initialized = True
except Exception as e:
log.exception("Failed initializing options page %r", Page)
# create an empty page with the error message in place of the failing page
@@ -263,7 +263,7 @@ class OptionsDialog(PicardDialog, SingletonDialog):
@property
def initialized_pages(self):
yield from (page for page in self.pages if not page.error)
yield from (page for page in self.pages if page.initialized)
@property
def loaded_pages(self):