diff --git a/shortcut_composer/templates/pie_menu_utils/pie_style.py b/shortcut_composer/templates/pie_menu_utils/pie_style.py index 3dbcb8e..0af9d03 100644 --- a/shortcut_composer/templates/pie_menu_utils/pie_style.py +++ b/shortcut_composer/templates/pie_menu_utils/pie_style.py @@ -18,14 +18,14 @@ class PieStyle: def __init__( self, - unscaled_label_style: LabelWidgetStyle, + label_style: LabelWidgetStyle, pie_radius_callback: Callable[[], int], deadzone_radius_callback: Callable[[], float], settings_button_radius_callback: Callable[[], int], accept_button_radius_callback: Callable[[], int], background_opacity_callback: Callable[[], int], ) -> None: - self._unscaled_label_style = unscaled_label_style + self._label_style = label_style self._pie_radius_callback = pie_radius_callback self._deadzone_radius_callback = deadzone_radius_callback @@ -56,12 +56,12 @@ def accept_button_radius(self) -> int: @property def widget_radius(self) -> int: """Radius of the entire widget, including base and the icons.""" - return self.pie_radius + self._unscaled_label_style.icon_radius + return self.pie_radius + self._label_style.icon_radius @property def border_thickness(self) -> int: """Thickness of border of the pie.""" - return self._unscaled_label_style.border_thickness + return self._label_style.border_thickness @property def decorator_thickness(self) -> int: @@ -81,12 +81,12 @@ def inner_edge_radius(self) -> int: @property def active_color(self) -> QColor: """Color of active elements.""" - return self._unscaled_label_style.active_color + return self._label_style.active_color @property def background_color(self) -> QColor: """Color of the widget background.""" - opaque = self._unscaled_label_style.background_color + opaque = self._label_style.background_color return QColor( opaque.red(), opaque.green(), @@ -96,17 +96,17 @@ def background_color(self) -> QColor: @property def active_color_dark(self) -> QColor: """Color variation of active element.""" - return self._unscaled_label_style.active_color_dark + return self._label_style.active_color_dark @property def border_color(self) -> QColor: """Color of the active pie border.""" - return self._unscaled_label_style.border_color + return self._label_style.border_color @property def background_decorator_color(self) -> QColor: """Color of decorator near inner edge.""" - color = self._unscaled_label_style.background_color + color = self._label_style.background_color color = QColor(color.red()-5, color.green()-5, color.blue()-5, 60) return color diff --git a/shortcut_composer/templates/pie_menu_utils/pie_style_holder.py b/shortcut_composer/templates/pie_menu_utils/pie_style_holder.py index e403475..145b0e6 100644 --- a/shortcut_composer/templates/pie_menu_utils/pie_style_holder.py +++ b/shortcut_composer/templates/pie_menu_utils/pie_style_holder.py @@ -30,7 +30,7 @@ def __init__(self, pie_config: PieConfig) -> None: active_color_callback=self._active_color, background_color_callback=self._background_color) self.pie_style = PieStyle( - unscaled_label_style=self.unscaled_label_style, + label_style=self.label_style, pie_radius_callback=self._pie_radius, deadzone_radius_callback=self._deadzone_radius, settings_button_radius_callback=self._settings_button_radius, @@ -59,7 +59,11 @@ def _icon_radius(self) -> int: max_radius = round( self.pie_style.pie_radius * math.pi / len(elements)) - return min(self._unscaled_icon_radius(), max_radius) + desired_radius = round( + self._unscaled_icon_radius() + * self._pie_config.ICON_RADIUS_SCALE.read()) + + return min(desired_radius, max_radius) def _border_thickness(self) -> int: """Return border thickness based on configured value.""" diff --git a/shortcut_composer/templates/pie_menu_utils/pie_widget.py b/shortcut_composer/templates/pie_menu_utils/pie_widget.py index dd7d781..148905a 100644 --- a/shortcut_composer/templates/pie_menu_utils/pie_widget.py +++ b/shortcut_composer/templates/pie_menu_utils/pie_widget.py @@ -3,7 +3,7 @@ from typing import TypeVar, Generic -from PyQt5.QtCore import Qt +from PyQt5.QtCore import Qt, QPoint from PyQt5.QtGui import ( QDragEnterEvent, QDragLeaveEvent, @@ -67,6 +67,7 @@ def __init__( self._config.PIE_RADIUS_SCALE.register_callback(self._reset) self._config.ICON_RADIUS_SCALE.register_callback(self._reset) + self._config.ORDER.register_callback(self._reset) Config.PIE_GLOBAL_SCALE.register_callback(self._reset) Config.PIE_ICON_GLOBAL_SCALE.register_callback(self._reset) @@ -170,5 +171,10 @@ def _type(self) -> type | None: def _reset(self) -> None: """Set widget geometry according to style.""" - diameter = 2*self._style_holder.pie_style.widget_radius - self.resize(diameter, diameter) + radius = self._style_holder.pie_style.widget_radius + difference = radius - self.width()//2 + new_center = QPoint( + self.center_global.x() - difference, + self.center_global.y()) + self.resize(2*radius, 2*radius) + self.move_center(new_center)