♻️ refactor(dock/indicators): adapt RecordingIndicator layout based on dock position, update time label only in horizontal mode
This commit is contained in:
1 file changed
+20
-8
@@ -184,11 +184,21 @@ class RecordingIndicator(Button):
|
|||||||
self.recording_label = Label(name="recording-label", markup=icons.screenrecord)
|
self.recording_label = Label(name="recording-label", markup=icons.screenrecord)
|
||||||
self.time_label = Label(name="recording-time-label", markup="00:00")
|
self.time_label = Label(name="recording-time-label", markup="00:00")
|
||||||
|
|
||||||
self.recording_box = Box(
|
# Adapt layout based on dock position
|
||||||
orientation="h",
|
if data.VERTICAL:
|
||||||
spacing=4,
|
# Vertical dock: show only icon
|
||||||
children=[self.recording_label, self.time_label]
|
self.recording_box = Box(
|
||||||
)
|
orientation="v",
|
||||||
|
spacing=2,
|
||||||
|
children=[self.recording_label]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# Horizontal dock: place icon and time side by side
|
||||||
|
self.recording_box = Box(
|
||||||
|
orientation="h",
|
||||||
|
spacing=4,
|
||||||
|
children=[self.recording_label, self.time_label]
|
||||||
|
)
|
||||||
self.add(self.recording_box)
|
self.add(self.recording_box)
|
||||||
|
|
||||||
self.connect("clicked", self.on_stop_recording)
|
self.connect("clicked", self.on_stop_recording)
|
||||||
@@ -218,9 +228,11 @@ class RecordingIndicator(Button):
|
|||||||
elapsed_seconds = int(time.time() - self.recording_start_time)
|
elapsed_seconds = int(time.time() - self.recording_start_time)
|
||||||
minutes = elapsed_seconds // 60
|
minutes = elapsed_seconds // 60
|
||||||
seconds = elapsed_seconds % 60
|
seconds = elapsed_seconds % 60
|
||||||
time_text = f"{minutes:02d}:{seconds:02d}"
|
# Only update time label in horizontal mode
|
||||||
self.time_label.set_markup(time_text)
|
if not data.VERTICAL:
|
||||||
self.set_tooltip_text(f"Recording in progress ({time_text}) - Click to stop")
|
time_text = f"{minutes:02d}:{seconds:02d}"
|
||||||
|
self.time_label.set_markup(time_text)
|
||||||
|
self.set_tooltip_text(f"Recording in progress ({minutes:02d}:{seconds:02d}) - Click to stop")
|
||||||
else:
|
else:
|
||||||
self.set_tooltip_text("Recording in progress - Click to stop")
|
self.set_tooltip_text("Recording in progress - Click to stop")
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in new issue
Block a user