added queue modal screen to player

This commit is contained in:
JISAUAY committed 2025-10-03 10:08:49 -05:00
1 parent ada1ef5fba
commit 7bb50b64c7
2 files changed
+41 -12

No files matched your search

+28 -11
View File
@@ -37,7 +37,7 @@ from textual.app import App, ComposeResult, RenderResult
from textual.widgets import Footer, Header, OptionList, DataTable, ProgressBar, Label, Input, Placeholder, Static, Rule, Button from textual.widgets import Footer, Header, OptionList, DataTable, ProgressBar, Label, Input, Placeholder, Static, Rule, Button
from textual.widget import Widget from textual.widget import Widget
from textual.containers import Horizontal, Vertical, Container, Center from textual.containers import Horizontal, Vertical, Container, Center
from textual.screen import Screen from textual.screen import Screen, ModalScreen
from textual.widgets.option_list import Option from textual.widgets.option_list import Option
from textual.timer import Timer from textual.timer import Timer
@@ -959,14 +959,24 @@ class MainView(Screen):
queue_table.update_queue() queue_table.update_queue()
app.update_now_playing() app.update_now_playing()
class QueueScreen(ModalScreen):
BINDINGS = [
('escape', 'back()', 'Go Back')
]
def compose(self) -> ComposeResult:
with Container(id='queueModal'):
yield QueueTable(id='queue')
yield Footer()
def action_back(self) -> None:
app.pop_screen()
class CurrentPlace(Static): class CurrentPlace(Static):
place: reactive[int] = reactive(0) place: reactive[int] = reactive(0)
def render(self) -> RenderResult: def render(self) -> RenderResult:
# if app.currently_playing:
# duration_min, duration_sec = divmod(app.currently_playing.duration, 60)
# duration_formatted = f"{duration_min:02d}:{duration_sec:02d}"
place_in_seconds = self.place // 1000 place_in_seconds = self.place // 1000
place_min, place_sec = divmod(place_in_seconds, 60) place_min, place_sec = divmod(place_in_seconds, 60)
place_formatted = f"{place_min:02d}:{place_sec:02d}" place_formatted = f"{place_min:02d}:{place_sec:02d}"
@@ -984,18 +994,23 @@ class TotalDuration(Static):
class Player(Screen): class Player(Screen):
CSS_PATH = 'main.tcss' CSS_PATH = 'main.tcss'
BINDINGS = [
('q', 'view_queue()', 'View Queue')
]
def on_mount(self) -> None:
app.sub_title = "Player"
def update_song(self, song: SubSonic.Song) -> None: def update_song(self, song: SubSonic.Song) -> None:
# info = self.query_one(NowPlayingInfo) if song.album and song.title and song.artist:
# info.song = song
if song.albumId:
track_title_label: Label = self.query_one('#trackTitle', Label) track_title_label: Label = self.query_one('#trackTitle', Label)
track_artist_album_label: Label = self.query_one('#trackAlbumArtist', Label) track_artist_album_label: Label = self.query_one('#trackAlbumArtist', Label)
track_title_label.update(song.title) track_title_label.update(song.title)
track_artist_album_label.update(f'{song.album} by {song.artist}') track_artist_album_label.update(f'{song.album} by {song.artist}')
if song.albumId:
cover_art = self.query_one(CoverArtPixels) cover_art = self.query_one(CoverArtPixels)
album = conn.getAlbumSongs(song.albumId) album = conn.getAlbumSongs(song.albumId)
@@ -1035,9 +1050,7 @@ class Player(Screen):
@on(events.ScreenResume) @on(events.ScreenResume)
def screen_resumed(self, event: events.ScreenResume) -> None: def screen_resumed(self, event: events.ScreenResume) -> None:
app.sub_title = "Overview" app.sub_title = "Player"
# queue_table = self.query_one(QueueTable)
# queue_table.update_queue()
app.update_now_playing() app.update_now_playing()
@on(Button.Pressed, "#prev_track") @on(Button.Pressed, "#prev_track")
@@ -1052,6 +1065,10 @@ class Player(Screen):
def next_track_pressed(self) -> None: def next_track_pressed(self) -> None:
app.action_skip() app.action_skip()
def action_view_queue(self) -> None:
# app.install_screen(QueueScreen, 'queue')
app.push_screen(QueueScreen())
# Startup keyboard listener for media keys # Startup keyboard listener for media keys
def listen_media_keys(queue: multiprocessing.Queue): def listen_media_keys(queue: multiprocessing.Queue):
+13 -1
View File
@@ -154,6 +154,18 @@
} }
.playerButton { .playerButton {
width: 10%; height: 5;
max-width: 12;
max-height: 12;
}
QueueScreen {
align: center middle;
}
#queueModal {
height: 75%;
width: 75%;
border: grey;
} }