Skip to content

Commit

Permalink
feat(widget): add tooltip option for all widgets
Browse files Browse the repository at this point in the history
This commit introduces a new `tooltip` boolean option across various widget configurations, allowing users to enable or disable tooltips on hover. The default value is set to `True`, ensuring that tooltips are displayed by default.
  • Loading branch information
amnweb committed Dec 8, 2024
1 parent dd7ee69 commit 4086d0d
Show file tree
Hide file tree
Showing 24 changed files with 115 additions and 19 deletions.
2 changes: 2 additions & 0 deletions docs/widgets/(Widget)-Bluetooth.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
|-------------------|---------|-------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| `label` | string | `'{icon}'` | The format string for the bluetooth widget. Displays icons. |
| `label_alt` | string | `'{device_name}'` | The alternative format string for the bluetooth widget. Displays list of connected devices. |
| `tooltip` | boolean | `True` | Whether to show the tooltip on hover. |
| `icons` | dict | `{'bluetooth_on', 'bluetooth_off', 'bluetooth_connected'` | Icons for bluetooth widget |
| `callbacks` | dict | `{'on_left': 'toggle_mute', 'on_middle': 'toggle_label', 'on_right': 'do_nothing'}` | Callbacks for mouse events on the memory widget. |
| `container_padding` | dict | `{'top': 0, 'left': 0, 'bottom': 0, 'right': 0}` | Explicitly set padding inside widget container. |
Expand All @@ -29,6 +30,7 @@ bluetooth:
- **label:** The format string for the bluetooth widget. Displays the bluetooth icon.
- **label_alt:** The alternative format string for the bluetooth widget. Displays list of connected devices.
- **tooltip:** Whether to show the tooltip on hover.
- **icons:** A dictionary specifying the icons for the bluetooth widget. The keys are `bluetooth_on`, `bluetooth_off`, and `bluetooth_connected`, and the values are the unicode characters for the icons.
- **callbacks:** A dictionary specifying the callbacks for mouse events. The keys are `on_left`, `on_middle`, and `on_right`, and the values are the names of the callback functions.

Expand Down
2 changes: 2 additions & 0 deletions docs/widgets/(Widget)-Clock.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
|-----------------|---------|-------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| `label` | string | `'\uf017 {%H:%M:%S}'` | The format string for the clock. You can use placeholders like `{%H:%M:%S}` to dynamically insert time information. |
| `label_alt` | string | `'\uf017 {%d-%m-%y %H:%M:%S}'` | The alternative format string for the clock. Useful for displaying additional time details. |
| `tooltip` | boolean | `True` | Whether to show the tooltip on hover. |
| `locale` | string | `""` | The locale to use for the clock. If not specified, it defaults to an empty string. |
| `update_interval` | integer | `1000` | The interval in milliseconds to update the clock. Must be between 0 and 60000. |
| `timezones` | list | `[]` | A list of timezones to cycle through. Each timezone should be a valid timezone string. |
Expand All @@ -30,6 +31,7 @@ clock:
- **label:** The format string for the clock. You can use placeholders like `{%H:%M:%S}` to dynamically insert time information.
- **label_alt:** The alternative format string for the clock. Useful for displaying additional time details.
- **locale:** The locale to use for the clock. If not specified, it defaults to an empty string.
- **tooltip:** Whether to show the tooltip on hover.
- **update_interval:** The interval in milliseconds to update the clock. Must be between 0 and 60000.
- **timezones:** A list of timezones to cycle through. If value is empty YASB will looking up time zone info from registry
- **callbacks:** A dictionary specifying the callbacks for mouse events. The keys are `on_left`, `on_middle`, and `on_right`, and the values are the names of the callback functions.
Expand Down
2 changes: 2 additions & 0 deletions docs/widgets/(Widget)-Github.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
|------------------|----------|--------------------------------|-----------------------------------------------------------------------------|
| `label` | string | `'{icon}'` | The format string for the label. You can use placeholders like `{icon}` to dynamically insert icon information. |
| `label_alt` | string | `'{data} Notifications'` | The alternative format string for the label. Useful for displaying additional notification details. |
| `tooltip` | boolean | `True` | Whether to show the tooltip on hover. |
| `update_interval`| integer | `600` | The interval in seconds to update the notifications. Must be between 60 and 3600. |
| `token` | string | `""` | The GitHub personal access token. |
| `max_notification`| integer | `20` | The maximum number of notifications to display in the menu. |
Expand Down Expand Up @@ -34,6 +35,7 @@ github:
- **label:** The format string for the label. You can use placeholders like `{icon}` to dynamically insert icon information.
- **label_alt:** The alternative format string for the label. Useful for displaying additional notification details.
- **tooltip:** Whether to show the tooltip on hover.
- **update_interval:** The interval in seconds to update the notifications. Must be between 60 and 3600.
- **token:** The GitHub personal access token. GitHub Personal access tokens (classic) https://github.com/settings/tokens you can set `token: env`, this means you have to set YASB_GITHUB_TOKEN in environment variable.
- **max_notification:** The maximum number of notifications to display in the menu, max 50.
Expand Down
2 changes: 2 additions & 0 deletions docs/widgets/(Widget)-Microphone.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
|-------------------|---------|-------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| `label` | string | `'{icon}'` | The format string for the microphone widget. Displays icon or level. |
| `label_alt` | string | `'{icon} {level}%'` | The alternative format string for the microphone widget. Displays icon or level. |
| `tooltip` | boolean | `True` | Whether to show the tooltip on hover. |
| `icons` | dict | `{'normal', 'muted'` | Icons for microphone widget |
| `callbacks` | dict | `{'on_left': 'toggle_mute', 'on_middle': 'toggle_label', 'on_right': 'do_nothing'}` | Callbacks for mouse events on the memory widget. |
| `container_padding` | dict | `{'top': 0, 'left': 0, 'bottom': 0, 'right': 0}` | Explicitly set padding inside widget container. |
Expand All @@ -30,6 +31,7 @@ microphone:
- **label:** The format string for the microphone widget. Displays the microphone icon or level.
- **label_alt:** The alternative format string for the microphone widget. Displays the microphone icon or level.
- **tooltip:** Whether to show the tooltip on hover.
- **icons:** A dictionary specifying the icons for the microphone widget. The keys are `normal` and `muted`, and the values are the unicode characters for the icons.
- **callbacks:** A dictionary specifying the callbacks for mouse events. The keys are `on_left`, `on_middle`, and `on_right`, and the values are the names of the callback functions.

Expand Down
2 changes: 2 additions & 0 deletions docs/widgets/(Widget)-Taskbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
| `icon_size` | integer | 16 | The size of icons |
| `ignore_apps` | dict | `processes:[],titles[],classes:[]` | Ignore some apps. |
| `animation` | boolean | `false` | Icons animation. |
| `tooltip` | boolean | `True` | Whether to show the tooltip on hover. |
| `container_padding` | dict | `{'top': 0, 'left': 0, 'bottom': 0, 'right': 0}` | Explicitly set padding inside widget container.
| `callbacks` | dict | `{'on_left': 'toggle_window', 'on_middle': 'do_nothing', 'on_right': 'do_nothing'}` | Callbacks for mouse events on the widget. |

Expand All @@ -30,6 +31,7 @@ taskbar:
- **icon_size:** The size of icons which will show in the widget.
- **animation:** Icons animation.
- **tooltip:** Whether to show the tooltip on hover.
- **container_padding:** Explicitly set padding inside widget container.
- **ignore_apps:** A dictionary that allows you to specify which applications should be ignored by the taskbar widget. It includes:
- processes: A list of process names to ignore.
Expand Down
2 changes: 2 additions & 0 deletions docs/widgets/(Widget)-Update-Check.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This widget checks for available updates using Windows Update and Winget.
|-----------------|---------|------------|--------------------------------------------------------------|
| `enabled` | boolean | `False` | Enable Windows Update checking. |
| `label` | string | `'{count}'`| Format string for the widget label. `{count}` shows update count. |
| `tooltip` | boolean | `True` | Whether to show the tooltip on hover. |
| `interval` | integer | `1440` | Check interval in minutes (30 to 10080). |
| `exclude` | list | `[]` | List of updates to exclude from checking. |

Expand All @@ -22,6 +23,7 @@ This widget checks for available updates using Windows Update and Winget.
|-----------------|---------|------------|--------------------------------------------------------------|
| `enabled` | boolean | `False` | Enable Winget package update checking. |
| `label` | string | `'{count}'`| Format string for the widget label. `{count}` shows update count. |
| `tooltip` | boolean | `True` | Whether to show the tooltip on hover. |
| `interval` | integer | `240` | Check interval in minutes (10 to 10080). |
| `exclude` | list | `[]` | List of packages to exclude from checking. |

Expand Down
2 changes: 2 additions & 0 deletions docs/widgets/(Widget)-Volume.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
|--------------|--------|-------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| `label` | string | `'{volume[percent]}%'` | The format string for the volume label. You can use placeholders like `{volume[percent]}` to dynamically insert volume information. |
| `label_alt` | string | `'{volume[percent]}%'` | The alternative format string for the volume label. Useful for displaying additional volume details. |
| `tooltip` | boolean | `True` | Whether to show the tooltip on hover. |
| `volume_icons` | list | `['\ueee8', '\uf026', '\uf027', '\uf027', '\uf028']` | A list of icons representing different volume levels. The icons are used based on the current volume percentage. |
| `callbacks` | dict | `{'on_middle': 'do_nothing', 'on_right': 'do_nothing'}` | Callbacks for mouse events on the volume widget. |

Expand All @@ -28,6 +29,7 @@ volume:
- **label**: The format string for the volume label. You can use placeholders like `{volume[percent]}` to dynamically insert volume information.
- **label_alt**: The alternative format string for the volume label. Useful for displaying additional volume details.
- **tooltip**: Whether to show the tooltip on hover.
- **volume_icons**: A list of icons representing different volume levels. The icons are used based on the current volume percentage.
- **callbacks**: A dictionary specifying the callbacks for mouse events. The keys are `on_middle` and `on_right`, and the values are the names of the callback functions.

Expand Down
2 changes: 2 additions & 0 deletions docs/widgets/(Widget)-Wallpapers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
| Option | Type | Default | Description |
|----------------------|----------|----------------|-----------------------------------------------------------------------------|
| `label` | string | `"{icon}"` | The format string for the wallpaper widget label. |
| `tooltip` | boolean | `True` | Whether to show the tooltip on hover. |
| `update_interval` | integer | 60 | The interval in seconds to update the wallpaper. Must be between 60 and 86400. |
| `change_automatically` | boolean | `False` | Whether to automatically change the wallpaper. |
| `image_path` | string | `""` | The path to the folder containing images for the wallpaper. This field is required. |
Expand Down Expand Up @@ -38,6 +39,7 @@ wallpapers:
## Description of Options
- **label:** The format string for the wallpaper widget label.
- **update_interval:** The interval in seconds to update the wallpaper. Must be between 60 and 86400.
- **tooltip:** Whether to show the tooltip on hover.
- **change_automatically:** Whether to automatically change the wallpaper.
- **image_path:** The path to the folder containing images for the wallpaper. This field is required.
- **gallery:** The gallery options for the wallpaper widget.
Expand Down
6 changes: 6 additions & 0 deletions src/core/validation/widgets/yasb/bluetooth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
DEFAULTS = {
'label': '\udb80\udcb1',
'label_alt': '\uf293',
'tooltip': True,
'icons': {
'bluetooth_on': '\udb80\udcaf',
'bluetooth_off': '\udb80\udcb2',
Expand All @@ -23,6 +24,11 @@
'type': 'string',
'default': DEFAULTS['label_alt']
},
'tooltip': {
'type': 'boolean',
'required': False,
'default': DEFAULTS['tooltip']
},
'icons': {
'type': 'dict',
'schema': {
Expand Down
6 changes: 6 additions & 0 deletions src/core/validation/widgets/yasb/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'label_alt': '\uf017 {%d-%m-%y %H:%M:%S}',
'update_interval': 1000,
'locale':"",
'tooltip': True,
'timezones': [],
'callbacks': {
'on_left': 'toggle_label',
Expand All @@ -25,6 +26,11 @@
'type': 'string',
'default': DEFAULTS['locale']
},
'tooltip': {
'type': 'boolean',
'required': False,
'default': DEFAULTS['tooltip']
},
'update_interval': {
'type': 'integer',
'default': 1000,
Expand Down
20 changes: 13 additions & 7 deletions src/core/validation/widgets/yasb/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
'label': '{icon}',
'label_alt': '{data} Notifications',
'update_interval': 600,
"token": "",
"max_notification":20,
"only_unread": False,
"max_field_size": 100,
"menu_width": 400,
"menu_height": 400,
"menu_offset": 240
'token': "",
'tooltip': True,
'max_notification':20,
'only_unread': False,
'max_field_size': 100,
'menu_width': 400,
'menu_height': 400,
'menu_offset': 240
}

VALIDATION_SCHEMA = {
Expand All @@ -30,6 +31,11 @@
'type': 'string',
'default': DEFAULTS['token']
},
'tooltip': {
'type': 'boolean',
'required': False,
'default': DEFAULTS['tooltip']
},
'max_notification': {
'type': 'integer',
'default': DEFAULTS['max_notification']
Expand Down
6 changes: 6 additions & 0 deletions src/core/validation/widgets/yasb/microphone.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
DEFAULTS = {
'label': '{icon}',
'label_alt': '{icon} {level}%',
'tooltip': True,
'icons': {
'normal': '\uf130',
'muted': '\uf131',
Expand All @@ -22,6 +23,11 @@
'type': 'string',
'default': DEFAULTS['label_alt']
},
'tooltip': {
'type': 'boolean',
'required': False,
'default': DEFAULTS['tooltip']
},
'icons': {
'type': 'dict',
'schema': {
Expand Down
6 changes: 6 additions & 0 deletions src/core/validation/widgets/yasb/taskbar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
DEFAULTS = {
'icon_size': 16,
'animation': False,
'tooltip': True,
'ignore_apps': {
'classes': [],
'processes': [],
Expand All @@ -24,6 +25,11 @@
'default': DEFAULTS['animation'],
'required': False
},
'tooltip': {
'type': 'boolean',
'required': False,
'default': DEFAULTS['tooltip']
},
'ignore_apps': {
'type': 'dict',
'schema': {
Expand Down
12 changes: 12 additions & 0 deletions src/core/validation/widgets/yasb/update_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
'windows_update': {
'enabled': False,
'label': '{count}',
'tooltip': True,
'interval': 1440,
'exclude': []
},
'winget_update': {
'enabled': False,
'label': '{count}',
'tooltip': True,
'interval': 240,
'exclude': []
}
Expand All @@ -25,6 +27,11 @@
'type': 'string',
'default': DEFAULTS['windows_update']['label']
},
'tooltip': {
'type': 'boolean',
'required': False,
'default': DEFAULTS['windows_update']['tooltip']
},
'interval': {
'type': 'integer',
'default': DEFAULTS['windows_update']['interval'],
Expand All @@ -51,6 +58,11 @@
'type': 'string',
'default': DEFAULTS['winget_update']['label']
},
'tooltip': {
'type': 'boolean',
'required': False,
'default': DEFAULTS['windows_update']['tooltip']
},
'interval': {
'type': 'integer',
'default': DEFAULTS['winget_update']['interval'],
Expand Down
6 changes: 6 additions & 0 deletions src/core/validation/widgets/yasb/volume.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
DEFAULTS = {
'label': "{volume[percent]}%",
'label_alt': "{volume[percent]}%",
'tooltip': True,
'volume_icons': [
"\ueee8", # Icon for muted
"\uf026", # Icon for 0-10% volume
Expand All @@ -23,6 +24,11 @@
'type': 'string',
'default': DEFAULTS['label_alt']
},
'tooltip': {
'type': 'boolean',
'required': False,
'default': DEFAULTS['tooltip']
},
'volume_icons': {
'type': 'list',
'default': DEFAULTS['volume_icons'],
Expand Down
6 changes: 6 additions & 0 deletions src/core/validation/widgets/yasb/wallpapers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'update_interval': 60,
'change_automatically': False,
'image_path': "",
'tooltip': True,
'gallery': {
'enabled': False,
'blur': True,
Expand Down Expand Up @@ -40,6 +41,11 @@
'type': 'string',
'default': DEFAULTS['image_path']
},
'tooltip': {
'required': False,
'type': 'boolean',
'default': DEFAULTS['tooltip']
},
'gallery': {
'type': 'dict',
'required': False,
Expand Down
6 changes: 4 additions & 2 deletions src/core/widgets/yasb/bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def __init__(
self,
label: str,
label_alt: str,
tooltip: bool,
icons: dict[str, str],
container_padding: dict[str, int],
callbacks: dict[str, str]
Expand All @@ -225,6 +226,7 @@ def __init__(
self._show_alt_label = False
self._label_content = label
self._label_alt_content = label_alt
self._tooltip = tooltip
self._padding = container_padding
try:
self.bt_api = get_bluetooth_api()
Expand Down Expand Up @@ -351,8 +353,8 @@ def _update_label(self, icon, connected_devices=None):
active_widgets[widget_index].setText(formatted_text)
widget_index += 1

# Set tooltip with connected device names
self._widget_container.setToolTip(tooltip_text)
if self._tooltip:
self._widget_container.setToolTip(tooltip_text)

def _update_state(self, status):
self.current_status = status
Expand Down
5 changes: 4 additions & 1 deletion src/core/widgets/yasb/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ def __init__(
label: str,
label_alt: str,
locale: str,
tooltip: bool,
update_interval: int,
timezones: list[str],
callbacks: dict[str, str],
):
super().__init__(update_interval, class_name="clock-widget")
self._locale = locale
self._tooltip = tooltip
self._active_tz = None
self._timezones = cycle(timezones if timezones else [get_localzone_name()])
self._active_datetime_format_str = ''
Expand Down Expand Up @@ -126,5 +128,6 @@ def _update_label(self):

def _next_timezone(self):
self._active_tz = next(self._timezones)
self.setToolTip(self._active_tz)
if self._tooltip:
self.setToolTip(self._active_tz)
self._update_label()
Loading

0 comments on commit 4086d0d

Please sign in to comment.