Commit 303106cf authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

Merge branch '264_add_tooltip_for_errors' into 'master'

Add tooltip when asset is invalid

Closes #264

See merge request !135
parents 3c0c058b b0af5c74
Pipeline #40551 passed with stages
in 11 minutes and 31 seconds
...@@ -236,14 +236,19 @@ class AssetWidget(QWidget): ...@@ -236,14 +236,19 @@ class AssetWidget(QWidget):
self.asset_name_label.setText(self.current_asset.name) self.asset_name_label.setText(self.current_asset.name)
self.save_button.setEnabled(False) self.save_button.setEnabled(False)
def __update_editors_icon(self, is_valid): def __update_editors_icon(self, is_valid, errors=None):
tab_index = self.tab_widget.indexOf(self.editors) tab_index = self.tab_widget.indexOf(self.editors)
tab_icon = ( tab_icon = (
self.style().standardIcon(QStyle.SP_MessageBoxCritical) self.style().standardIcon(QStyle.SP_MessageBoxCritical)
if not is_valid if not is_valid
else QIcon() else QIcon()
) )
tab_tooltip = ""
if errors is not None:
tab_tooltip = "\n".join(errors)
self.tab_widget.setTabIcon(tab_index, tab_icon) self.tab_widget.setTabIcon(tab_index, tab_icon)
self.tab_widget.setTabToolTip(tab_index, tab_tooltip)
def __clear_watcher(self): def __clear_watcher(self):
"""Clears the content of the file system watcher""" """Clears the content of the file system watcher"""
...@@ -454,7 +459,7 @@ class AssetWidget(QWidget): ...@@ -454,7 +459,7 @@ class AssetWidget(QWidget):
do_load = True do_load = True
if do_load: if do_load:
self.__update_editors_icon(is_valid) self.__update_editors_icon(is_valid, errors)
declaration = asset.declaration declaration = asset.declaration
...@@ -512,8 +517,8 @@ class AssetWidget(QWidget): ...@@ -512,8 +517,8 @@ class AssetWidget(QWidget):
with FileBlocker(self.watcher, declaration_path): with FileBlocker(self.watcher, declaration_path):
self.current_asset.declaration = json_data self.current_asset.declaration = json_data
is_valid, _ = self.current_asset.is_valid() is_valid, errors = self.current_asset.is_valid()
self.__update_editors_icon(is_valid) self.__update_editors_icon(is_valid, errors)
if self.current_asset.type == AssetType.ALGORITHM: if self.current_asset.type == AssetType.ALGORITHM:
update_code(self.current_asset) update_code(self.current_asset)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment