Fixed The player in control centre
This commit is contained in:
1 parent
8b86bfd72d
commit
f1d53b7e1e
3 files changed
+154
-58
No files matched your search
+101
-54
@@ -10,7 +10,6 @@ from fabric.utils import (
|
|||||||
)
|
)
|
||||||
from fabric.widgets.box import Box
|
from fabric.widgets.box import Box
|
||||||
from fabric.widgets.button import Button
|
from fabric.widgets.button import Button
|
||||||
from fabric.widgets.centerbox import CenterBox
|
|
||||||
from fabric.widgets.image import Image
|
from fabric.widgets.image import Image
|
||||||
from modules.controlcenter.expanded_player import ExpandedPlayer
|
from modules.controlcenter.expanded_player import ExpandedPlayer
|
||||||
from fabric.widgets.label import Label
|
from fabric.widgets.label import Label
|
||||||
@@ -53,7 +52,9 @@ def cleanup_old_cache_files():
|
|||||||
class PlayerBoxStack(Box):
|
class PlayerBoxStack(Box):
|
||||||
"""A widget that displays the current player information."""
|
"""A widget that displays the current player information."""
|
||||||
|
|
||||||
def __init__(self, mpris_manager: MprisPlayerManager, control_center=None, **kwargs):
|
def __init__(
|
||||||
|
self, mpris_manager: MprisPlayerManager, control_center=None, **kwargs
|
||||||
|
):
|
||||||
# Clean up old cache files on startup
|
# Clean up old cache files on startup
|
||||||
cleanup_old_cache_files()
|
cleanup_old_cache_files()
|
||||||
|
|
||||||
@@ -99,7 +100,7 @@ class PlayerBoxStack(Box):
|
|||||||
fallback_cover_path = f"{data.HOME_DIR}/.current.wall"
|
fallback_cover_path = f"{data.HOME_DIR}/.current.wall"
|
||||||
|
|
||||||
# Album cover with fallback image
|
# Album cover with fallback image
|
||||||
album_cover = Box(style_classes="album-image")
|
album_cover = Box(style_classes="album-image-c")
|
||||||
album_cover.set_style(f"background-image:url('{fallback_cover_path}')")
|
album_cover.set_style(f"background-image:url('{fallback_cover_path}')")
|
||||||
|
|
||||||
image_stack = Box(h_align="start", v_align="center", name="player-image-stack")
|
image_stack = Box(h_align="start", v_align="center", name="player-image-stack")
|
||||||
@@ -108,7 +109,7 @@ class PlayerBoxStack(Box):
|
|||||||
# Track info showing "No media playing"
|
# Track info showing "No media playing"
|
||||||
track_title = Label(
|
track_title = Label(
|
||||||
label="No media playing",
|
label="No media playing",
|
||||||
name="player-title",
|
name="player-title-c",
|
||||||
justification="left",
|
justification="left",
|
||||||
max_chars_width=15,
|
max_chars_width=15,
|
||||||
ellipsization="end",
|
ellipsization="end",
|
||||||
@@ -137,7 +138,7 @@ class PlayerBoxStack(Box):
|
|||||||
|
|
||||||
track_info = Box(
|
track_info = Box(
|
||||||
name="track-info",
|
name="track-info",
|
||||||
spacing=5,
|
# spacing=5,
|
||||||
orientation="v",
|
orientation="v",
|
||||||
v_align="start",
|
v_align="start",
|
||||||
h_align="start",
|
h_align="start",
|
||||||
@@ -274,7 +275,11 @@ class PlayerBoxStack(Box):
|
|||||||
|
|
||||||
self.set_visible(True)
|
self.set_visible(True)
|
||||||
|
|
||||||
new_player_box = PlayerBox(player=MprisPlayer(player), player_stack=self, control_center=self.control_center)
|
new_player_box = PlayerBox(
|
||||||
|
player=MprisPlayer(player),
|
||||||
|
player_stack=self,
|
||||||
|
control_center=self.control_center,
|
||||||
|
)
|
||||||
self.player_stack.children = [
|
self.player_stack.children = [
|
||||||
*self.player_stack.children,
|
*self.player_stack.children,
|
||||||
new_player_box,
|
new_player_box,
|
||||||
@@ -370,7 +375,9 @@ class PlayerBoxStack(Box):
|
|||||||
class PlayerBox(Box):
|
class PlayerBox(Box):
|
||||||
"""A widget that displays the current player information."""
|
"""A widget that displays the current player information."""
|
||||||
|
|
||||||
def __init__(self, player: MprisPlayer, player_stack=None, control_center=None, **kwargs):
|
def __init__(
|
||||||
|
self, player: MprisPlayer, player_stack=None, control_center=None, **kwargs
|
||||||
|
):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
h_align="center",
|
h_align="center",
|
||||||
name="player-box",
|
name="player-box",
|
||||||
@@ -387,7 +394,7 @@ class PlayerBox(Box):
|
|||||||
self.ex_mousecapture = DropDownMouseCapture(
|
self.ex_mousecapture = DropDownMouseCapture(
|
||||||
layer="top", child_window=self.expanded_player
|
layer="top", child_window=self.expanded_player
|
||||||
)
|
)
|
||||||
self.image_size = 120
|
self.image_size = 50
|
||||||
|
|
||||||
self.icon_size = 15
|
self.icon_size = 15
|
||||||
|
|
||||||
@@ -399,20 +406,37 @@ class PlayerBox(Box):
|
|||||||
self.temp_artwork_files = [] # Track temp files for cleanup
|
self.temp_artwork_files = [] # Track temp files for cleanup
|
||||||
self.current_download_thread = None # Track current download thread
|
self.current_download_thread = None # Track current download thread
|
||||||
|
|
||||||
self.album_cover = Box(style_classes="album-image")
|
self.album_cover = Box(style_classes="album-image-c")
|
||||||
self.album_cover.set_style(
|
self.album_cover.set_style(
|
||||||
f"background-image:url('{self.fallback_cover_path}')"
|
f"background-image:url('{self.fallback_cover_path}')"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.image_stack = Box(
|
self.image_stack = Box(
|
||||||
h_align="start", v_align="center", name="player-image-stack"
|
h_align="start",
|
||||||
|
v_align="center",
|
||||||
|
name="player-image-stack",
|
||||||
)
|
)
|
||||||
self.image_stack.children = [*self.image_stack.children, self.album_cover]
|
self.image_stack.children = [*self.image_stack.children, self.album_cover]
|
||||||
|
|
||||||
|
self.app_icon = Box(
|
||||||
|
children=Image(
|
||||||
|
icon_name=self.player.player_name, name="player-app-icon", icon_size=20
|
||||||
|
),
|
||||||
|
h_align="end",
|
||||||
|
v_align="end",
|
||||||
|
tooltip_text=self.player.player_name, # type: ignore
|
||||||
|
)
|
||||||
|
self.image = Overlay(
|
||||||
|
child=self.image_stack,
|
||||||
|
overlays=[
|
||||||
|
self.app_icon,
|
||||||
|
],
|
||||||
|
)
|
||||||
# Track Info
|
# Track Info
|
||||||
|
|
||||||
self.track_title = Label(
|
self.track_title = Label(
|
||||||
label="No Title",
|
label="No Title",
|
||||||
name="player-title",
|
name="player-title-c",
|
||||||
justification="left",
|
justification="left",
|
||||||
max_chars_width=15,
|
max_chars_width=15,
|
||||||
ellipsization="end",
|
ellipsization="end",
|
||||||
@@ -483,23 +507,13 @@ class PlayerBox(Box):
|
|||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
self.button_box = Box(
|
self.button_box = Box(
|
||||||
name="button-box",
|
name="button-box-c",
|
||||||
h_align="center",
|
# h_align="end",
|
||||||
|
# visible=False,
|
||||||
|
h_expand=False,
|
||||||
spacing=2,
|
spacing=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Stack switcher buttons box
|
|
||||||
self.stack_buttons_box = Box(
|
|
||||||
name="stack-buttons-box", spacing=4, h_align="center"
|
|
||||||
)
|
|
||||||
self.stack_buttons_box.hide() # Initially hidden
|
|
||||||
|
|
||||||
self.controls_box = CenterBox(
|
|
||||||
name="player-controls",
|
|
||||||
center_children=self.button_box,
|
|
||||||
end_children=self.stack_buttons_box,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.skip_next_icon = Image(icon_name="media-skip-forward")
|
self.skip_next_icon = Image(icon_name="media-skip-forward")
|
||||||
self.skip_prev_icon = Image(icon_name="media-skip-backward")
|
self.skip_prev_icon = Image(icon_name="media-skip-backward")
|
||||||
self.shuffle_icon = Image(icon_name="shuffle")
|
self.shuffle_icon = Image(icon_name="shuffle")
|
||||||
@@ -533,51 +547,84 @@ class PlayerBox(Box):
|
|||||||
self.player.bind_property("can_shuffle", self.shuffle_button, "sensitive")
|
self.player.bind_property("can_shuffle", self.shuffle_button, "sensitive")
|
||||||
|
|
||||||
self.button_box.children = (
|
self.button_box.children = (
|
||||||
self.shuffle_button,
|
# self.shuffle_button,
|
||||||
self.prev_button,
|
# self.prev_button,
|
||||||
self.play_pause_button,
|
self.play_pause_button,
|
||||||
self.next_button,
|
self.next_button,
|
||||||
)
|
)
|
||||||
self.custom = Button(
|
|
||||||
child=self.track_info,
|
|
||||||
on_clicked=lambda *_: self.expanded_player.set_visible(True),
|
|
||||||
)
|
|
||||||
self.player_info_box = Box(
|
self.player_info_box = Box(
|
||||||
name="player-info-box",
|
name="player-info-box-c",
|
||||||
v_align="center",
|
v_align="center",
|
||||||
|
h_expand=True,
|
||||||
h_align="start",
|
h_align="start",
|
||||||
orientation="v",
|
orientation="v",
|
||||||
children=[self.custom, self.controls_box, self.stack_buttons_box],
|
children=[
|
||||||
|
self.track_info,
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
self.inner_box = Box(
|
self.inner_box = Box(
|
||||||
name="inner-player-box",
|
name="inner-player-box",
|
||||||
|
h_expand=True,
|
||||||
v_align="center",
|
v_align="center",
|
||||||
h_align="start",
|
h_align="start",
|
||||||
)
|
children=[
|
||||||
# resize the inner box
|
self.image,
|
||||||
self.outer_box = Box(
|
|
||||||
name="outer-player-box",
|
|
||||||
h_align="start",
|
|
||||||
)
|
|
||||||
|
|
||||||
self.overlay_box = Overlay(
|
|
||||||
child=self.outer_box,
|
|
||||||
overlays=[
|
|
||||||
self.inner_box,
|
|
||||||
self.player_info_box,
|
self.player_info_box,
|
||||||
self.image_stack,
|
|
||||||
Box(
|
|
||||||
children=Image(icon_name=self.player.player_name, icon_size=18),
|
|
||||||
h_align="end",
|
|
||||||
v_align="start",
|
|
||||||
style="margin-top: 5px; margin-right: 10px;",
|
|
||||||
tooltip_text=self.player.player_name, # type: ignore
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
# resize the inner box
|
||||||
|
self.outer_box = Button(
|
||||||
|
spacing=5,
|
||||||
|
name="outer-player-box-c",
|
||||||
|
h_expand=True,
|
||||||
|
# style="background-color:#fff",
|
||||||
|
on_clicked=lambda *_: (
|
||||||
|
# Close control center if it exists
|
||||||
|
self.control_center.hide_controlcenter(),
|
||||||
|
self.expanded_player.set_visible(True),
|
||||||
|
self.ex_mousecapture.toggle_mousecapture(),
|
||||||
|
),
|
||||||
|
h_align="start",
|
||||||
|
# children=[
|
||||||
|
child=self.inner_box,
|
||||||
|
# self.inner_box,
|
||||||
|
# self.player_info_box,
|
||||||
|
# self.image,
|
||||||
|
# ],
|
||||||
|
)
|
||||||
|
|
||||||
self.children = [*self.children, self.overlay_box]
|
self.box = Box(
|
||||||
|
name="box-c",
|
||||||
|
orientation="h",
|
||||||
|
h_align="center",
|
||||||
|
h_expand=True,
|
||||||
|
children=[
|
||||||
|
self.outer_box,
|
||||||
|
self.button_box,
|
||||||
|
# self.stack_buttons_box,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
# self.overlay_box = Overlay(
|
||||||
|
# child=self.outer_box,
|
||||||
|
# overlays=[
|
||||||
|
# # self.inner_box,
|
||||||
|
# self.player_info_box,
|
||||||
|
# self.image_stack,
|
||||||
|
# Box(
|
||||||
|
# children=Image(icon_name=self.player.player_name, icon_size=18),
|
||||||
|
# h_align="end",
|
||||||
|
# v_align="start",
|
||||||
|
# style="margin-top: 5px; margin-right: 10px;",
|
||||||
|
# tooltip_text=self.player.player_name, # type: ignore
|
||||||
|
# ),
|
||||||
|
# ],
|
||||||
|
# )
|
||||||
|
|
||||||
|
self.children = [
|
||||||
|
*self.children,
|
||||||
|
self.box,
|
||||||
|
]
|
||||||
|
|
||||||
bulk_connect(
|
bulk_connect(
|
||||||
self.player,
|
self.player,
|
||||||
@@ -599,7 +646,7 @@ class PlayerBox(Box):
|
|||||||
def _on_prev_button_click(self, *_):
|
def _on_prev_button_click(self, *_):
|
||||||
"""Handle prev button click: close control center then open expanded player"""
|
"""Handle prev button click: close control center then open expanded player"""
|
||||||
# Close control center first
|
# Close control center first
|
||||||
if self.control_center and hasattr(self.control_center, 'hide_controlcenter'):
|
if self.control_center and hasattr(self.control_center, "hide_controlcenter"):
|
||||||
self.control_center.hide_controlcenter()
|
self.control_center.hide_controlcenter()
|
||||||
|
|
||||||
# Then open expanded player
|
# Then open expanded player
|
||||||
|
|||||||
@@ -312,3 +312,13 @@
|
|||||||
background-image: none;
|
background-image: none;
|
||||||
color: alpha(#fff, 0.2);
|
color: alpha(#fff, 0.2);
|
||||||
}
|
}
|
||||||
|
#thing {
|
||||||
|
background-color: alpha(#999, 0.9);
|
||||||
|
min-height: 200px;
|
||||||
|
min-width: 600px;
|
||||||
|
}
|
||||||
|
#thing-label {
|
||||||
|
color: #000;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
+43
-4
@@ -1,8 +1,12 @@
|
|||||||
#player-stack-button {
|
#player-stack-button {
|
||||||
border-radius: 5px;
|
/* border-radius: 5px; */
|
||||||
min-width: 7px;
|
/* min-width: 7px; */
|
||||||
min-height: 7px;
|
/* min-height: 7px; */
|
||||||
margin: 10px 3px;
|
/* margin: 10px 3px; */
|
||||||
|
}
|
||||||
|
|
||||||
|
#button-box-c {
|
||||||
|
margin-left: -10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#player-stack-button:hover {
|
#player-stack-button:hover {
|
||||||
@@ -24,21 +28,48 @@
|
|||||||
box-shadow: inset 0 0 0 1px alpha(#aaa, 0.4);
|
box-shadow: inset 0 0 0 1px alpha(#aaa, 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#outer-player-box-c {
|
||||||
|
min-height: 60px;
|
||||||
|
min-width: 263px;
|
||||||
|
border-radius: 10px;
|
||||||
|
/* margin: 0 6px; */
|
||||||
|
/* background-color: alpha(#000, 0.3); */
|
||||||
|
/* box-shadow: inset 0 0 0 1px alpha(#aaa, 0.4); */
|
||||||
|
}
|
||||||
|
#box-c {
|
||||||
|
min-height: 60px;
|
||||||
|
min-width: 263px;
|
||||||
|
border-radius: 10px;
|
||||||
|
margin: 0 6px;
|
||||||
|
background-color: alpha(#000, 0.3);
|
||||||
|
/* box-shadow: inset 0 0 0 1px alpha(#aaa, 0.4); */
|
||||||
|
}
|
||||||
#player-box:disabled highlight,
|
#player-box:disabled highlight,
|
||||||
#player-box:disabled progress {
|
#player-box:disabled progress {
|
||||||
background-color: rgba(205, 214, 244, 0.6);
|
background-color: rgba(205, 214, 244, 0.6);
|
||||||
background-image: none;
|
background-image: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#player-info-box-c {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
#player-info-box {
|
#player-info-box {
|
||||||
margin-left: 130px;
|
margin-left: 130px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#player-title-c {
|
||||||
|
/* margin-top: 18px; */
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
#player-title {
|
#player-title {
|
||||||
margin-top: 18px;
|
margin-top: 18px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
#player-app-icon {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
#player-artist,
|
#player-artist,
|
||||||
#player-album {
|
#player-album {
|
||||||
@@ -70,6 +101,14 @@
|
|||||||
color: #5f5f5f;
|
color: #5f5f5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.album-image-c {
|
||||||
|
min-width: 55px;
|
||||||
|
min-height: 55px;
|
||||||
|
background-position: center;
|
||||||
|
background-size: cover;
|
||||||
|
/* margin-left: 12px; */
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
.album-image {
|
.album-image {
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
min-height: 90px;
|
min-height: 90px;
|
||||||
|
|||||||
Reference in new issue
Block a user