chore(release): v2.0.0
This commit is contained in:
parent
a6f33284a7
commit
7fbf34ff2e
81 changed files with 16727 additions and 3280 deletions
|
|
@ -8,6 +8,7 @@ pub enum NativeEvent {
|
|||
ShowWindow,
|
||||
ToggleWindow,
|
||||
CheckUpdates,
|
||||
OpenUrl(&'static str),
|
||||
QuitApp,
|
||||
Play,
|
||||
Pause,
|
||||
|
|
@ -18,12 +19,79 @@ pub enum NativeEvent {
|
|||
SeekMs(u64),
|
||||
}
|
||||
|
||||
/// Exact external URLs from `original_yandex_music/beautified/js/index.js` (lines 89, 2525-2534).
|
||||
pub const TERMS_OF_USE_URL: &str = "https://yandex.ru/legal/music_mobile_agreement/";
|
||||
pub const RECOMMENDATIONS_URL: &str = "https://music.yandex.ru/legal/recommendations/ru/#music";
|
||||
pub const SUPPORT_CHAT_URL: &str =
|
||||
"https://yandex.ru/chat?context=%7B%22entrypoint%22%3A%22web_desktop%22%7D#/user/ee219503-b69b-9484-405b-6877a510e13c";
|
||||
|
||||
/// Exact tray menu strings from `original_yandex_music/beautified/js/index.js`:
|
||||
/// `translationsRU` (lines 1753-1807), `translationsEN` (lines 1808-1862), `createContextMenu$1` (lines 2588-2753).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct TrayLabels {
|
||||
pub tooltip: &'static str,
|
||||
pub roll_up: &'static str,
|
||||
pub unwrap: &'static str,
|
||||
pub check_updates: &'static str,
|
||||
pub play: &'static str,
|
||||
pub pause: &'static str,
|
||||
pub prev: &'static str,
|
||||
pub next: &'static str,
|
||||
pub about: &'static str,
|
||||
pub terms: &'static str,
|
||||
pub recommendations: &'static str,
|
||||
pub support: &'static str,
|
||||
pub quit: &'static str,
|
||||
}
|
||||
|
||||
impl TrayLabels {
|
||||
pub const fn for_lang(is_ru: bool) -> Self {
|
||||
if is_ru {
|
||||
Self {
|
||||
tooltip: "Яндекс Музыка",
|
||||
roll_up: "Свернуть",
|
||||
unwrap: "Развернуть",
|
||||
check_updates: "Проверить обновления",
|
||||
play: "Воспроизведение",
|
||||
pause: "Пауза",
|
||||
prev: "Предыдущая песня",
|
||||
next: "Следующая песня",
|
||||
about: "О приложении",
|
||||
terms: "Пользовательское соглашение",
|
||||
recommendations: "Правила рекомендаций",
|
||||
support: "Чат с поддержкой",
|
||||
quit: "Закрыть приложение",
|
||||
}
|
||||
} else {
|
||||
Self {
|
||||
tooltip: "Yandex Music",
|
||||
roll_up: "Hide",
|
||||
unwrap: "Expand",
|
||||
check_updates: "Check updates",
|
||||
play: "Playback",
|
||||
pause: "Pause",
|
||||
prev: "Previous song",
|
||||
next: "Next song",
|
||||
about: "About the app",
|
||||
terms: "User agreement",
|
||||
recommendations: "Recommendation rules",
|
||||
support: "Support chat",
|
||||
quit: "Close app",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
mod tray_menu_win;
|
||||
|
||||
// =============================================================================
|
||||
// WINDOWS IMPLEMENTATION
|
||||
// =============================================================================
|
||||
#[cfg(windows)]
|
||||
mod imp {
|
||||
use super::NativeEvent;
|
||||
use super::tray_menu_win;
|
||||
use super::{NativeEvent, TrayLabels};
|
||||
use crate::api::models::Track;
|
||||
use crate::api::signing::extract_oauth_token;
|
||||
use crate::api::YANDEX_OAUTH_URL;
|
||||
|
|
@ -37,7 +105,6 @@ mod imp {
|
|||
use std::io::{BufRead, BufReader, Write};
|
||||
use std::process::{Command, Stdio};
|
||||
use std::time::Duration;
|
||||
use tray_icon::menu::{Menu, MenuEvent, MenuId, MenuItem, PredefinedMenuItem, Submenu};
|
||||
use tray_icon::{MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent};
|
||||
use winit::application::ApplicationHandler;
|
||||
use winit::dpi::LogicalSize;
|
||||
|
|
@ -48,98 +115,42 @@ mod imp {
|
|||
const OAUTH_TOKEN_PREFIX: &str = "YM_OAUTH_TOKEN:";
|
||||
|
||||
pub struct NativeDesktop {
|
||||
_tray: Option<TrayIcon>,
|
||||
item_toggle_win: Option<MenuItem>,
|
||||
item_play: Option<MenuItem>,
|
||||
menu_toggle_win_id: Option<MenuId>,
|
||||
menu_updates_id: Option<MenuId>,
|
||||
menu_play_id: Option<MenuId>,
|
||||
menu_prev_id: Option<MenuId>,
|
||||
menu_next_id: Option<MenuId>,
|
||||
menu_quit_id: Option<MenuId>,
|
||||
tray: Option<TrayIcon>,
|
||||
is_ru: bool,
|
||||
is_dark: bool,
|
||||
window_visible: bool,
|
||||
smtc: Option<MediaControls>,
|
||||
rx_smtc: Receiver<NativeEvent>,
|
||||
tx_events: Sender<NativeEvent>,
|
||||
rx_events: Receiver<NativeEvent>,
|
||||
last_track_id: Option<String>,
|
||||
last_playing: Option<bool>,
|
||||
can_prev: bool,
|
||||
can_next: bool,
|
||||
}
|
||||
|
||||
impl Drop for NativeDesktop {
|
||||
fn drop(&mut self) {
|
||||
tray_menu_win::close_tray_menu();
|
||||
}
|
||||
}
|
||||
|
||||
impl NativeDesktop {
|
||||
pub fn new(window: &Window, is_ru: bool) -> Self {
|
||||
// 1. Build System Tray icon + exact 5.129.0 menu matching Yandex Music Desktop!
|
||||
let mut item_toggle_win_slot = None;
|
||||
let mut item_play_slot = None;
|
||||
let mut menu_toggle_win_id = None;
|
||||
let mut menu_updates_id = None;
|
||||
let mut menu_play_id = None;
|
||||
let mut menu_prev_id = None;
|
||||
let mut menu_next_id = None;
|
||||
let mut menu_quit_id = None;
|
||||
|
||||
let labels = TrayLabels::for_lang(is_ru);
|
||||
let tray = (|| -> Option<TrayIcon> {
|
||||
let menu = Menu::new();
|
||||
let item_toggle_win = MenuItem::new(if is_ru { "Скрыть" } else { "Hide" }, true, None);
|
||||
let item_updates = MenuItem::new(
|
||||
if is_ru { "Проверить обновления" } else { "Check updates" },
|
||||
true,
|
||||
None,
|
||||
);
|
||||
let item_play = MenuItem::new(if is_ru { "Играть" } else { "Play" }, true, None);
|
||||
let item_prev = MenuItem::new(
|
||||
if is_ru { "Предыдущий трек" } else { "Previous song" },
|
||||
true,
|
||||
None,
|
||||
);
|
||||
let item_next = MenuItem::new(
|
||||
if is_ru { "Следующий трек" } else { "Next song" },
|
||||
true,
|
||||
None,
|
||||
);
|
||||
let about_sub = Submenu::new(if is_ru { "О приложении" } else { "About the app" }, true);
|
||||
let about_ver = MenuItem::new(
|
||||
if is_ru { "Яндекс Музыка 5.129.0" } else { "Yandex Music 5.129.0" },
|
||||
false,
|
||||
None,
|
||||
);
|
||||
let _ = about_sub.append(&about_ver);
|
||||
let item_quit = MenuItem::new(
|
||||
if is_ru { "Закрыть приложение" } else { "Close app" },
|
||||
true,
|
||||
None,
|
||||
);
|
||||
|
||||
menu_toggle_win_id = Some(item_toggle_win.id().clone());
|
||||
menu_updates_id = Some(item_updates.id().clone());
|
||||
menu_play_id = Some(item_play.id().clone());
|
||||
menu_prev_id = Some(item_prev.id().clone());
|
||||
menu_next_id = Some(item_next.id().clone());
|
||||
menu_quit_id = Some(item_quit.id().clone());
|
||||
|
||||
let _ = menu.append(&item_toggle_win);
|
||||
let _ = menu.append(&item_updates);
|
||||
let _ = menu.append(&PredefinedMenuItem::separator());
|
||||
let _ = menu.append(&item_play);
|
||||
let _ = menu.append(&item_prev);
|
||||
let _ = menu.append(&item_next);
|
||||
let _ = menu.append(&PredefinedMenuItem::separator());
|
||||
let _ = menu.append(&about_sub);
|
||||
let _ = menu.append(&PredefinedMenuItem::separator());
|
||||
let _ = menu.append(&item_quit);
|
||||
|
||||
item_toggle_win_slot = Some(item_toggle_win);
|
||||
item_play_slot = Some(item_play);
|
||||
|
||||
let icon = build_tray_icon()?;
|
||||
// No `.with_menu(...)`: right-click opens our pixel-accurate Win32 Chromium-style
|
||||
// popup menu (`tray_menu_win`) matching Yandex Music Desktop 5.129.0 1-to-1.
|
||||
TrayIconBuilder::new()
|
||||
.with_menu(Box::new(menu))
|
||||
.with_tooltip(if is_ru { "Яндекс Музыка" } else { "Yandex Music" })
|
||||
.with_tooltip(labels.tooltip)
|
||||
.with_icon(icon)
|
||||
.build()
|
||||
.ok()
|
||||
})();
|
||||
|
||||
// 2. Build Windows SMTC (`souvlaki::MediaControls`) bound to our Win32 HWND
|
||||
let (tx_smtc, rx_smtc): (Sender<NativeEvent>, Receiver<NativeEvent>) = unbounded();
|
||||
let (tx_events, rx_events): (Sender<NativeEvent>, Receiver<NativeEvent>) = unbounded();
|
||||
let tx_smtc = tx_events.clone();
|
||||
let smtc = (|| -> Option<MediaControls> {
|
||||
let hwnd = match window.window_handle().ok()?.as_raw() {
|
||||
RawWindowHandle::Win32(h) => h.hwnd.get() as *mut std::ffi::c_void,
|
||||
|
|
@ -174,37 +185,43 @@ mod imp {
|
|||
})();
|
||||
|
||||
Self {
|
||||
_tray: tray,
|
||||
item_toggle_win: item_toggle_win_slot,
|
||||
item_play: item_play_slot,
|
||||
menu_toggle_win_id,
|
||||
menu_updates_id,
|
||||
menu_play_id,
|
||||
menu_prev_id,
|
||||
menu_next_id,
|
||||
menu_quit_id,
|
||||
tray,
|
||||
is_ru,
|
||||
is_dark: true,
|
||||
window_visible: true,
|
||||
smtc,
|
||||
rx_smtc,
|
||||
tx_events,
|
||||
rx_events,
|
||||
last_track_id: None,
|
||||
last_playing: None,
|
||||
can_prev: false,
|
||||
can_next: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_window_visible_label(&self, visible: bool) {
|
||||
if let Some(ref item) = self.item_toggle_win {
|
||||
item.set_text(if visible {
|
||||
if self.is_ru { "Скрыть" } else { "Hide" }
|
||||
} else {
|
||||
if self.is_ru { "Показать" } else { "Show" }
|
||||
});
|
||||
pub fn set_dark_mode(&mut self, is_dark: bool) {
|
||||
self.is_dark = is_dark;
|
||||
}
|
||||
|
||||
pub fn set_language(&mut self, is_ru: bool) {
|
||||
if self.is_ru == is_ru {
|
||||
return;
|
||||
}
|
||||
self.is_ru = is_ru;
|
||||
let labels = TrayLabels::for_lang(is_ru);
|
||||
if let Some(ref tray) = self.tray {
|
||||
let _ = tray.set_tooltip(Some(labels.tooltip));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_window_visible_label(&mut self, visible: bool) {
|
||||
self.window_visible = visible;
|
||||
}
|
||||
|
||||
pub fn poll_events(&self) -> Vec<NativeEvent> {
|
||||
let mut out = Vec::new();
|
||||
|
||||
while let Ok(ev) = self.rx_smtc.try_recv() {
|
||||
while let Ok(ev) = self.rx_events.try_recv() {
|
||||
out.push(ev);
|
||||
}
|
||||
|
||||
|
|
@ -214,33 +231,29 @@ mod imp {
|
|||
button: MouseButton::Left,
|
||||
button_state: MouseButtonState::Up,
|
||||
..
|
||||
} => {
|
||||
tray_menu_win::close_tray_menu();
|
||||
out.push(NativeEvent::ToggleWindow);
|
||||
}
|
||||
| TrayIconEvent::DoubleClick {
|
||||
button: MouseButton::Left,
|
||||
TrayIconEvent::Click {
|
||||
button: MouseButton::Right,
|
||||
button_state: MouseButtonState::Up,
|
||||
..
|
||||
} => {
|
||||
out.push(NativeEvent::ShowWindow);
|
||||
tray_menu_win::show_tray_menu(
|
||||
self.tx_events.clone(),
|
||||
self.is_ru,
|
||||
self.is_dark,
|
||||
self.window_visible,
|
||||
self.last_playing.unwrap_or(false),
|
||||
self.can_prev,
|
||||
self.can_next,
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
while let Ok(ev) = MenuEvent::receiver().try_recv() {
|
||||
if self.menu_toggle_win_id.as_ref() == Some(&ev.id) {
|
||||
out.push(NativeEvent::ToggleWindow);
|
||||
} else if self.menu_updates_id.as_ref() == Some(&ev.id) {
|
||||
out.push(NativeEvent::CheckUpdates);
|
||||
} else if self.menu_play_id.as_ref() == Some(&ev.id) {
|
||||
out.push(NativeEvent::TogglePlay);
|
||||
} else if self.menu_next_id.as_ref() == Some(&ev.id) {
|
||||
out.push(NativeEvent::Next);
|
||||
} else if self.menu_prev_id.as_ref() == Some(&ev.id) {
|
||||
out.push(NativeEvent::Prev);
|
||||
} else if self.menu_quit_id.as_ref() == Some(&ev.id) {
|
||||
out.push(NativeEvent::QuitApp);
|
||||
}
|
||||
}
|
||||
|
||||
out
|
||||
}
|
||||
|
||||
|
|
@ -249,16 +262,11 @@ mod imp {
|
|||
track: Option<&Track>,
|
||||
is_playing: bool,
|
||||
position_ms: u64,
|
||||
can_prev: bool,
|
||||
can_next: bool,
|
||||
) {
|
||||
if self.last_playing != Some(is_playing) {
|
||||
if let Some(ref item) = self.item_play {
|
||||
item.set_text(if is_playing {
|
||||
if self.is_ru { "Пауза" } else { "Pause" }
|
||||
} else {
|
||||
if self.is_ru { "Играть" } else { "Play" }
|
||||
});
|
||||
}
|
||||
}
|
||||
self.can_prev = can_prev;
|
||||
self.can_next = can_next;
|
||||
let Some(ref mut smtc) = self.smtc else {
|
||||
self.last_playing = Some(is_playing);
|
||||
return;
|
||||
|
|
@ -449,7 +457,9 @@ mod imp {
|
|||
|
||||
#[cfg(target_os = "linux")]
|
||||
mod imp {
|
||||
use super::NativeEvent;
|
||||
use super::{
|
||||
NativeEvent, TrayLabels, RECOMMENDATIONS_URL, SUPPORT_CHAT_URL, TERMS_OF_USE_URL,
|
||||
};
|
||||
use crate::api::models::Track;
|
||||
use crossbeam_channel::{unbounded, Receiver, Sender};
|
||||
use ksni::blocking::{Handle, TrayMethods};
|
||||
|
|
@ -466,6 +476,8 @@ mod imp {
|
|||
is_ru: bool,
|
||||
window_visible: bool,
|
||||
is_playing: bool,
|
||||
can_prev: bool,
|
||||
can_next: bool,
|
||||
track_summary: String,
|
||||
}
|
||||
|
||||
|
|
@ -479,11 +491,7 @@ mod imp {
|
|||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
if self.is_ru {
|
||||
"Яндекс Музыка".into()
|
||||
} else {
|
||||
"Yandex Music".into()
|
||||
}
|
||||
TrayLabels::for_lang(self.is_ru).tooltip.into()
|
||||
}
|
||||
|
||||
fn icon_name(&self) -> String {
|
||||
|
|
@ -509,24 +517,16 @@ mod imp {
|
|||
|
||||
fn menu(&self) -> Vec<ksni::MenuItem<Self>> {
|
||||
use ksni::menu::*;
|
||||
let labels = TrayLabels::for_lang(self.is_ru);
|
||||
let toggle_label = if self.window_visible {
|
||||
if self.is_ru { "Скрыть" } else { "Hide" }
|
||||
} else if self.is_ru {
|
||||
"Показать"
|
||||
labels.roll_up
|
||||
} else {
|
||||
"Show"
|
||||
labels.unwrap
|
||||
};
|
||||
let play_label = if self.is_playing {
|
||||
if self.is_ru { "Пауза" } else { "Pause" }
|
||||
} else if self.is_ru {
|
||||
"Играть"
|
||||
labels.pause
|
||||
} else {
|
||||
"Play"
|
||||
};
|
||||
let ver_label = if self.is_ru {
|
||||
format!("Яндекс Музыка {}", env!("CARGO_PKG_VERSION"))
|
||||
} else {
|
||||
format!("Yandex Music {}", env!("CARGO_PKG_VERSION"))
|
||||
labels.play
|
||||
};
|
||||
|
||||
vec![
|
||||
|
|
@ -539,11 +539,7 @@ mod imp {
|
|||
}
|
||||
.into(),
|
||||
StandardItem {
|
||||
label: if self.is_ru {
|
||||
"Проверить обновления".into()
|
||||
} else {
|
||||
"Check updates".into()
|
||||
},
|
||||
label: labels.check_updates.into(),
|
||||
activate: Box::new(|this: &mut Self| {
|
||||
let _ = this.tx.send(NativeEvent::CheckUpdates);
|
||||
}),
|
||||
|
|
@ -560,11 +556,8 @@ mod imp {
|
|||
}
|
||||
.into(),
|
||||
StandardItem {
|
||||
label: if self.is_ru {
|
||||
"Предыдущий трек".into()
|
||||
} else {
|
||||
"Previous song".into()
|
||||
},
|
||||
label: labels.prev.into(),
|
||||
enabled: self.can_prev,
|
||||
activate: Box::new(|this: &mut Self| {
|
||||
let _ = this.tx.send(NativeEvent::Prev);
|
||||
}),
|
||||
|
|
@ -572,11 +565,8 @@ mod imp {
|
|||
}
|
||||
.into(),
|
||||
StandardItem {
|
||||
label: if self.is_ru {
|
||||
"Следующий трек".into()
|
||||
} else {
|
||||
"Next song".into()
|
||||
},
|
||||
label: labels.next.into(),
|
||||
enabled: self.can_next,
|
||||
activate: Box::new(|this: &mut Self| {
|
||||
let _ = this.tx.send(NativeEvent::Next);
|
||||
}),
|
||||
|
|
@ -585,27 +575,39 @@ mod imp {
|
|||
.into(),
|
||||
MenuItem::Separator,
|
||||
SubMenu {
|
||||
label: if self.is_ru {
|
||||
"О приложении".into()
|
||||
} else {
|
||||
"About the app".into()
|
||||
},
|
||||
submenu: vec![StandardItem {
|
||||
label: ver_label,
|
||||
enabled: false,
|
||||
..Default::default()
|
||||
}
|
||||
.into()],
|
||||
label: labels.about.into(),
|
||||
submenu: vec![
|
||||
StandardItem {
|
||||
label: labels.terms.into(),
|
||||
activate: Box::new(|this: &mut Self| {
|
||||
let _ = this.tx.send(NativeEvent::OpenUrl(TERMS_OF_USE_URL));
|
||||
}),
|
||||
..Default::default()
|
||||
}
|
||||
.into(),
|
||||
StandardItem {
|
||||
label: labels.recommendations.into(),
|
||||
activate: Box::new(|this: &mut Self| {
|
||||
let _ = this.tx.send(NativeEvent::OpenUrl(RECOMMENDATIONS_URL));
|
||||
}),
|
||||
..Default::default()
|
||||
}
|
||||
.into(),
|
||||
StandardItem {
|
||||
label: labels.support.into(),
|
||||
activate: Box::new(|this: &mut Self| {
|
||||
let _ = this.tx.send(NativeEvent::OpenUrl(SUPPORT_CHAT_URL));
|
||||
}),
|
||||
..Default::default()
|
||||
}
|
||||
.into(),
|
||||
],
|
||||
..Default::default()
|
||||
}
|
||||
.into(),
|
||||
MenuItem::Separator,
|
||||
StandardItem {
|
||||
label: if self.is_ru {
|
||||
"Закрыть приложение".into()
|
||||
} else {
|
||||
"Close app".into()
|
||||
},
|
||||
label: labels.quit.into(),
|
||||
activate: Box::new(|this: &mut Self| {
|
||||
let _ = this.tx.send(NativeEvent::QuitApp);
|
||||
}),
|
||||
|
|
@ -633,8 +635,11 @@ mod imp {
|
|||
pub struct NativeDesktop {
|
||||
handle: Option<Handle<LinuxTray>>,
|
||||
rx: Receiver<NativeEvent>,
|
||||
is_ru: bool,
|
||||
last_playing: Option<bool>,
|
||||
last_track_id: Option<String>,
|
||||
last_can_prev: Option<bool>,
|
||||
last_can_next: Option<bool>,
|
||||
}
|
||||
|
||||
impl Drop for NativeDesktop {
|
||||
|
|
@ -661,18 +666,37 @@ mod imp {
|
|||
is_ru,
|
||||
window_visible: true,
|
||||
is_playing: false,
|
||||
can_prev: false,
|
||||
can_next: false,
|
||||
track_summary: String::new(),
|
||||
};
|
||||
let handle = tray.assume_sni_available(true).spawn().ok();
|
||||
Self {
|
||||
handle,
|
||||
rx,
|
||||
is_ru,
|
||||
last_playing: None,
|
||||
last_track_id: None,
|
||||
last_can_prev: Some(false),
|
||||
last_can_next: Some(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_window_visible_label(&self, visible: bool) {
|
||||
pub fn set_dark_mode(&mut self, _is_dark: bool) {}
|
||||
|
||||
pub fn set_language(&mut self, is_ru: bool) {
|
||||
if self.is_ru == is_ru {
|
||||
return;
|
||||
}
|
||||
self.is_ru = is_ru;
|
||||
if let Some(ref handle) = self.handle {
|
||||
handle.update(move |t| {
|
||||
t.is_ru = is_ru;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_window_visible_label(&mut self, visible: bool) {
|
||||
if let Some(ref handle) = self.handle {
|
||||
handle.update(move |t| {
|
||||
t.window_visible = visible;
|
||||
|
|
@ -688,13 +712,26 @@ mod imp {
|
|||
out
|
||||
}
|
||||
|
||||
pub fn sync_playback(&mut self, track: Option<&Track>, is_playing: bool, _pos_ms: u64) {
|
||||
pub fn sync_playback(
|
||||
&mut self,
|
||||
track: Option<&Track>,
|
||||
is_playing: bool,
|
||||
_pos_ms: u64,
|
||||
can_prev: bool,
|
||||
can_next: bool,
|
||||
) {
|
||||
let track_id = track.map(|t| t.id.as_str());
|
||||
if self.last_playing == Some(is_playing) && self.last_track_id.as_deref() == track_id {
|
||||
if self.last_playing == Some(is_playing)
|
||||
&& self.last_track_id.as_deref() == track_id
|
||||
&& self.last_can_prev == Some(can_prev)
|
||||
&& self.last_can_next == Some(can_next)
|
||||
{
|
||||
return;
|
||||
}
|
||||
self.last_playing = Some(is_playing);
|
||||
self.last_track_id = track_id.map(String::from);
|
||||
self.last_can_prev = Some(can_prev);
|
||||
self.last_can_next = Some(can_next);
|
||||
let summary = track
|
||||
.map(|tr| {
|
||||
let artists = tr.artists_string();
|
||||
|
|
@ -708,6 +745,8 @@ mod imp {
|
|||
if let Some(ref handle) = self.handle {
|
||||
handle.update(move |t| {
|
||||
t.is_playing = is_playing;
|
||||
t.can_prev = can_prev;
|
||||
t.can_next = can_next;
|
||||
t.track_summary = summary;
|
||||
});
|
||||
}
|
||||
|
|
@ -869,11 +908,21 @@ mod imp {
|
|||
pub fn new(_window: &Window, _is_ru: bool) -> Self {
|
||||
Self
|
||||
}
|
||||
pub fn set_window_visible_label(&self, _visible: bool) {}
|
||||
pub fn set_dark_mode(&mut self, _is_dark: bool) {}
|
||||
pub fn set_language(&mut self, _is_ru: bool) {}
|
||||
pub fn set_window_visible_label(&mut self, _visible: bool) {}
|
||||
pub fn poll_events(&self) -> Vec<NativeEvent> {
|
||||
Vec::new()
|
||||
}
|
||||
pub fn sync_playback(&mut self, _track: Option<&Track>, _is_playing: bool, _pos_ms: u64) {}
|
||||
pub fn sync_playback(
|
||||
&mut self,
|
||||
_track: Option<&Track>,
|
||||
_is_playing: bool,
|
||||
_pos_ms: u64,
|
||||
_can_prev: bool,
|
||||
_can_next: bool,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_window_icon() -> Option<winit::window::Icon> {
|
||||
|
|
@ -886,3 +935,39 @@ mod imp {
|
|||
}
|
||||
|
||||
pub use imp::{load_window_icon, run_auth_webview_subprocess, spawn_auth_webview_subprocess, NativeDesktop};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn tray_labels_match_original_desktop_index_js() {
|
||||
let ru = TrayLabels::for_lang(true);
|
||||
assert_eq!(ru.roll_up, "Свернуть");
|
||||
assert_eq!(ru.unwrap, "Развернуть");
|
||||
assert_eq!(ru.check_updates, "Проверить обновления");
|
||||
assert_eq!(ru.play, "Воспроизведение");
|
||||
assert_eq!(ru.pause, "Пауза");
|
||||
assert_eq!(ru.prev, "Предыдущая песня");
|
||||
assert_eq!(ru.next, "Следующая песня");
|
||||
assert_eq!(ru.about, "О приложении");
|
||||
assert_eq!(ru.terms, "Пользовательское соглашение");
|
||||
assert_eq!(ru.recommendations, "Правила рекомендаций");
|
||||
assert_eq!(ru.support, "Чат с поддержкой");
|
||||
assert_eq!(ru.quit, "Закрыть приложение");
|
||||
|
||||
let en = TrayLabels::for_lang(false);
|
||||
assert_eq!(en.roll_up, "Hide");
|
||||
assert_eq!(en.unwrap, "Expand");
|
||||
assert_eq!(en.check_updates, "Check updates");
|
||||
assert_eq!(en.play, "Playback");
|
||||
assert_eq!(en.pause, "Pause");
|
||||
assert_eq!(en.prev, "Previous song");
|
||||
assert_eq!(en.next, "Next song");
|
||||
assert_eq!(en.about, "About the app");
|
||||
assert_eq!(en.terms, "User agreement");
|
||||
assert_eq!(en.recommendations, "Recommendation rules");
|
||||
assert_eq!(en.support, "Support chat");
|
||||
assert_eq!(en.quit, "Close app");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue