mirror of
https://github.com/fergalmoran/picard.git
synced 2026-03-26 07:05:16 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user