💅 style(dashboard): format code for readability and consistency
This commit is contained in:
2 files changed
+26
-59
No files matched your search
@@ -88,7 +88,11 @@ class Dashboard(Box):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def handle_tile_menu_expand(self, tile: str, toggle: bool):
|
def handle_tile_menu_expand(self, tile: str, toggle: bool):
|
||||||
print(f"Tile menu expand: {tile}, toggle: {toggle}, active_tile: {self.active_tile}")
|
print(
|
||||||
|
f"Tile menu expand: {tile}, toggle: {toggle}, active_tile: {
|
||||||
|
self.active_tile
|
||||||
|
}"
|
||||||
|
)
|
||||||
|
|
||||||
# If clicking the same tile that's already active, deactivate it
|
# If clicking the same tile that's already active, deactivate it
|
||||||
if self.active_tile == tile and toggle:
|
if self.active_tile == tile and toggle:
|
||||||
@@ -125,7 +129,7 @@ class Dashboard(Box):
|
|||||||
|
|
||||||
# Reset all tile toggle states
|
# Reset all tile toggle states
|
||||||
for tile in self.tiles:
|
for tile in self.tiles:
|
||||||
if hasattr(tile, 'toggle'):
|
if hasattr(tile, "toggle"):
|
||||||
tile.toggle = False
|
tile.toggle = False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+20
-57
@@ -32,8 +32,18 @@ import utils.icons as icons
|
|||||||
def add_hover_cursor(widget):
|
def add_hover_cursor(widget):
|
||||||
"""Add hover cursor functionality to a widget."""
|
"""Add hover cursor functionality to a widget."""
|
||||||
widget.add_events(Gdk.EventMask.ENTER_NOTIFY_MASK | Gdk.EventMask.LEAVE_NOTIFY_MASK)
|
widget.add_events(Gdk.EventMask.ENTER_NOTIFY_MASK | Gdk.EventMask.LEAVE_NOTIFY_MASK)
|
||||||
widget.connect("enter-notify-event", lambda w, e: w.get_window().set_cursor(Gdk.Cursor.new_from_name(w.get_display(), "pointer")) if w.get_window() else None)
|
widget.connect(
|
||||||
widget.connect("leave-notify-event", lambda w, e: w.get_window().set_cursor(None) if w.get_window() else None)
|
"enter-notify-event",
|
||||||
|
lambda w, e: w.get_window().set_cursor(
|
||||||
|
Gdk.Cursor.new_from_name(w.get_display(), "pointer")
|
||||||
|
)
|
||||||
|
if w.get_window()
|
||||||
|
else None,
|
||||||
|
)
|
||||||
|
widget.connect(
|
||||||
|
"leave-notify-event",
|
||||||
|
lambda w, e: w.get_window().set_cursor(None) if w.get_window() else None,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Tile(Box):
|
class Tile(Box):
|
||||||
@@ -71,17 +81,12 @@ class Tile(Box):
|
|||||||
|
|
||||||
def _create_tile_icon(self, markup: str):
|
def _create_tile_icon(self, markup: str):
|
||||||
"""Create the tile's icon label."""
|
"""Create the tile's icon label."""
|
||||||
self.icon = Label(
|
self.icon = Label(style_classes="tile-icon", markup=markup)
|
||||||
style_classes="tile-icon",
|
|
||||||
markup=markup
|
|
||||||
)
|
|
||||||
|
|
||||||
def _create_tile_content(self, label: str):
|
def _create_tile_content(self, label: str):
|
||||||
"""Create the tile's text content area."""
|
"""Create the tile's text content area."""
|
||||||
self.tile_label = Label(
|
self.tile_label = Label(
|
||||||
style_classes="tile-label",
|
style_classes="tile-label", label=label, h_align="start"
|
||||||
label=label,
|
|
||||||
h_align="start"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Container for label and properties
|
# Container for label and properties
|
||||||
@@ -136,7 +141,9 @@ class Tile(Box):
|
|||||||
# Create placeholder menu (content is shown in dashboard content area)
|
# Create placeholder menu (content is shown in dashboard content area)
|
||||||
self.menu = Box(
|
self.menu = Box(
|
||||||
style_classes="tile-menu",
|
style_classes="tile-menu",
|
||||||
children=[Label(label="Tile content will be shown in dashboard content area")],
|
children=[
|
||||||
|
Label(label="Tile content will be shown in dashboard content area")
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Stack to switch between normal and menu views
|
# Stack to switch between normal and menu views
|
||||||
@@ -161,31 +168,9 @@ class Tile(Box):
|
|||||||
|
|
||||||
# Notify dashboard to handle content switching
|
# Notify dashboard to handle content switching
|
||||||
if self.dashboard_instance:
|
if self.dashboard_instance:
|
||||||
self.dashboard_instance.handle_tile_menu_expand(self.get_name(), self.toggle)
|
self.dashboard_instance.handle_tile_menu_expand(
|
||||||
|
self.get_name(), self.toggle
|
||||||
def mini_view(self):
|
)
|
||||||
"""
|
|
||||||
Switch tile to mini (compact) view.
|
|
||||||
|
|
||||||
In mini view, the tile content is hidden and only the icon is shown.
|
|
||||||
This is used when other tiles are active.
|
|
||||||
"""
|
|
||||||
self.content_button.set_reveal_child(False)
|
|
||||||
self.icon.set_h_expand(True)
|
|
||||||
self.content_button.set_h_expand(False)
|
|
||||||
self.add_style_class("mini")
|
|
||||||
|
|
||||||
def maxi_view(self):
|
|
||||||
"""
|
|
||||||
Switch tile to maxi (full) view.
|
|
||||||
|
|
||||||
In maxi view, the tile shows its full content including label and properties.
|
|
||||||
This is the default state when no tiles are active.
|
|
||||||
"""
|
|
||||||
self.content_button.set_reveal_child(True)
|
|
||||||
self.icon.set_h_expand(False)
|
|
||||||
self.content_button.set_h_expand(True)
|
|
||||||
self.remove_style_class("mini")
|
|
||||||
|
|
||||||
|
|
||||||
class TileSpecial(Box):
|
class TileSpecial(Box):
|
||||||
@@ -228,25 +213,3 @@ class TileSpecial(Box):
|
|||||||
children=[self.normal_view, self.collapsed_view],
|
children=[self.normal_view, self.collapsed_view],
|
||||||
)
|
)
|
||||||
self.children = self.stack
|
self.children = self.stack
|
||||||
|
|
||||||
def mini_view(self):
|
|
||||||
"""
|
|
||||||
Switch to mini (collapsed) view.
|
|
||||||
|
|
||||||
Hides the normal view and shows the compact mini view.
|
|
||||||
Uses negative margins to hide the normal view completely.
|
|
||||||
"""
|
|
||||||
self.normal_view.set_style("margin:-999px")
|
|
||||||
self.collapsed_view.set_style("margin:0px;")
|
|
||||||
self.stack.set_visible_child(self.collapsed_view)
|
|
||||||
|
|
||||||
def maxi_view(self):
|
|
||||||
"""
|
|
||||||
Switch to maxi (normal) view.
|
|
||||||
|
|
||||||
Hides the mini view and shows the full normal view.
|
|
||||||
Uses negative margins to hide the collapsed view completely.
|
|
||||||
"""
|
|
||||||
self.collapsed_view.set_style("margin:-999px")
|
|
||||||
self.normal_view.set_style("margin:0px;")
|
|
||||||
self.stack.set_visible_child(self.normal_view)
|
|
||||||
Reference in new issue
Block a user