deblur thumbnails
This commit is contained in:
parent
d37ec6a19a
commit
418cf01884
2 changed files with 6 additions and 5 deletions
|
@ -64,7 +64,6 @@ use crate::subsonic;
|
||||||
use adw::{prelude::*, subclass::prelude::*};
|
use adw::{prelude::*, subclass::prelude::*};
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
use gtk::{gdk, glib};
|
use gtk::{gdk, glib};
|
||||||
use std::rc::Rc;
|
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
pub struct Song(ObjectSubclass<imp::Song>);
|
pub struct Song(ObjectSubclass<imp::Song>);
|
||||||
|
@ -72,10 +71,11 @@ glib::wrapper! {
|
||||||
|
|
||||||
impl Song {
|
impl Song {
|
||||||
pub fn from_child(
|
pub fn from_child(
|
||||||
api: &Rc<subsonic::Client>,
|
window: &crate::ui::Window,
|
||||||
song: &subsonic::schema::Child,
|
song: &subsonic::schema::Child,
|
||||||
load_thumbnail: bool,
|
load_thumbnail: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
let api = window.api();
|
||||||
let song: Song = Object::builder()
|
let song: Song = Object::builder()
|
||||||
.property("id", &song.id)
|
.property("id", &song.id)
|
||||||
.property("title", &song.title)
|
.property("title", &song.title)
|
||||||
|
@ -88,14 +88,15 @@ impl Song {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if load_thumbnail {
|
if load_thumbnail {
|
||||||
let api = Rc::clone(api);
|
|
||||||
let id = song.id();
|
let id = song.id();
|
||||||
let song_weak = song.downgrade();
|
let song_weak = song.downgrade();
|
||||||
|
let scale_factor = window.scale_factor() as u32; // NOTE: assumed constant
|
||||||
song.imp()
|
song.imp()
|
||||||
.thumbnail_loading
|
.thumbnail_loading
|
||||||
.replace(Some(glib::spawn_future_local(async move {
|
.replace(Some(glib::spawn_future_local(async move {
|
||||||
let bytes = api
|
let bytes = api
|
||||||
.cover_art(&id, Some(50)) // TODO: WidgetExt::scale_factor
|
.cover_art(&id, Some(50 * scale_factor)) // see pixel-size in
|
||||||
|
// play_queue_song.blp
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let song = match song_weak.upgrade() {
|
let song = match song_weak.upgrade() {
|
||||||
|
|
|
@ -301,7 +301,7 @@ mod imp {
|
||||||
Rc::clone(api.as_ref().unwrap())
|
Rc::clone(api.as_ref().unwrap())
|
||||||
};
|
};
|
||||||
for song in api.random_songs(10).await.unwrap().into_iter() {
|
for song in api.random_songs(10).await.unwrap().into_iter() {
|
||||||
let song = Song::from_child(&api, &song, true);
|
let song = Song::from_child(&self.obj(), &song, true);
|
||||||
self.mpv
|
self.mpv
|
||||||
.command(["loadfile", &song.stream_url(), "append-play"])
|
.command(["loadfile", &song.stream_url(), "append-play"])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
Loading…
Reference in a new issue