mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[view] improvement: displaying tips for some custom actions (on mouse hover)
This commit is contained in:
@@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
- UI
|
- UI
|
||||||
- upgrade summary dialog size
|
- upgrade summary dialog size
|
||||||
|
- displaying tips for some custom actions (on mouse hover)
|
||||||
- screenshots: displaying the current image index as a label in the button bar (e.g: 1/3)
|
- screenshots: displaying the current image index as a label in the button bar (e.g: 1/3)
|
||||||
|
|
||||||
## [0.9.28] 2022-02-14
|
## [0.9.28] 2022-02-14
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ class CustomSoftwareAction:
|
|||||||
backup: bool = False, refresh: bool = True,
|
backup: bool = False, refresh: bool = True,
|
||||||
i18n_confirm_key: str = None,
|
i18n_confirm_key: str = None,
|
||||||
requires_internet: bool = False,
|
requires_internet: bool = False,
|
||||||
requires_confirmation: bool = True):
|
requires_confirmation: bool = True,
|
||||||
|
i18n_description_key: Optional[str] = None):
|
||||||
"""
|
"""
|
||||||
:param i18n_label_key: the i18n key that will be used to display the action name
|
:param i18n_label_key: the i18n key that will be used to display the action name
|
||||||
:param i18n_status_key: the i18n key that will be used to display the action name being executed
|
:param i18n_status_key: the i18n key that will be used to display the action name being executed
|
||||||
@@ -21,10 +22,11 @@ class CustomSoftwareAction:
|
|||||||
:param manager: the instance that will execute the action ( optional )
|
:param manager: the instance that will execute the action ( optional )
|
||||||
:param backup: if a system backup should be performed before executing the action
|
:param backup: if a system backup should be performed before executing the action
|
||||||
:param requires_root:
|
:param requires_root:
|
||||||
:param refresh: if the a full app refresh should be done if the action succeeds
|
:param refresh: if all displayed apps on the view should be refreshed if the action succeeds
|
||||||
:param i18n_confirm_key: action confirmation message
|
:param i18n_confirm_key: action confirmation message
|
||||||
:param requires_internet: if the action requires internet connection to be executed
|
:param requires_internet: if the action requires internet connection to be executed
|
||||||
:param requires_confirmation: if a confirmation popup should be displayed to the user before calling the action
|
:param requires_confirmation: if a confirmation popup should be displayed to the user before calling the action
|
||||||
|
:param i18n_description_key: the i18n key for the action description
|
||||||
"""
|
"""
|
||||||
self.i18n_label_key = i18n_label_key
|
self.i18n_label_key = i18n_label_key
|
||||||
self.i18n_status_key = i18n_status_key
|
self.i18n_status_key = i18n_status_key
|
||||||
@@ -37,12 +39,19 @@ class CustomSoftwareAction:
|
|||||||
self.i18n_confirm_key = i18n_confirm_key
|
self.i18n_confirm_key = i18n_confirm_key
|
||||||
self.requires_internet = requires_internet
|
self.requires_internet = requires_internet
|
||||||
self.requires_confirmation = requires_confirmation
|
self.requires_confirmation = requires_confirmation
|
||||||
|
self.i18n_description_key = i18n_description_key
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self) -> int:
|
||||||
return self.i18n_label_key.__hash__() + self.i18n_status_key.__hash__() + self.manager_method.__hash__()
|
return sum(hash(val) for val in self.__dict__.values())
|
||||||
|
|
||||||
|
def __eq__(self, other) -> bool:
|
||||||
|
if isinstance(other, CustomSoftwareAction):
|
||||||
|
return self.__dict__ == other.__dict__
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "CustomAction (label={}, method={})".format(self.i18n_label_key, self.manager_method)
|
return f"{self.__class__.__name__} (label={self.i18n_label_key}, method={self.manager_method})"
|
||||||
|
|
||||||
|
|
||||||
class PackageStatus(Enum):
|
class PackageStatus(Enum):
|
||||||
|
|||||||
@@ -176,9 +176,11 @@ class PackagesTable(QTableWidget):
|
|||||||
i18n=self.i18n).ask():
|
i18n=self.i18n).ask():
|
||||||
self.window.begin_execute_custom_action(pkg, action)
|
self.window.begin_execute_custom_action(pkg, action)
|
||||||
|
|
||||||
|
tip = self.i18n[action.i18n_description_key] if action.i18n_description_key else None
|
||||||
return QCustomMenuAction(parent=parent,
|
return QCustomMenuAction(parent=parent,
|
||||||
label=self.i18n[action.i18n_label_key],
|
label=self.i18n[action.i18n_label_key],
|
||||||
icon=QIcon(action.icon_path) if action.icon_path else None,
|
icon=QIcon(action.icon_path) if action.icon_path else None,
|
||||||
|
tooltip=tip,
|
||||||
action=custom_action)
|
action=custom_action)
|
||||||
|
|
||||||
def refresh(self, pkg: PackageView):
|
def refresh(self, pkg: PackageView):
|
||||||
|
|||||||
@@ -1508,9 +1508,11 @@ class ManageWindow(QWidget):
|
|||||||
else:
|
else:
|
||||||
icon = None
|
icon = None
|
||||||
|
|
||||||
|
tip = self.i18n[action.i18n_description_key] if action.i18n_description_key else None
|
||||||
return QCustomMenuAction(parent=parent,
|
return QCustomMenuAction(parent=parent,
|
||||||
label=self.i18n[action.i18n_label_key],
|
label=self.i18n[action.i18n_label_key],
|
||||||
action=lambda: self.begin_execute_custom_action(None, action),
|
action=lambda: self.begin_execute_custom_action(None, action),
|
||||||
|
tooltip=tip,
|
||||||
icon=icon)
|
icon=icon)
|
||||||
|
|
||||||
def show_custom_actions(self):
|
def show_custom_actions(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user