Skip to content

Commit

Permalink
use new API
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven committed Aug 26, 2024
1 parent 771c96f commit d49e899
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions feeluown/gui/pages/song_explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

from feeluown.excs import ResourceNotFound
from feeluown.library import (
SupportsSongHotComments, SupportsSongSimilar, SupportsSongWebUrl,
ModelFlags,
SupportsSongHotComments, SupportsSongSimilar, ModelFlags,
)
from feeluown.player import Lyric
from feeluown.library import reverse, resolve
Expand Down Expand Up @@ -278,22 +277,24 @@ def _setup_ui(self):
self._right_layout.addWidget(self.lyric_view)

async def maybe_show_web_url_btn(self, provider, song):
if isinstance(provider, SupportsSongWebUrl):
async def copy_song_web_url():
web_url = await aio.run_fn(provider.song_get_web_url, song)
QGuiApplication.clipboard().setText(web_url)
self._app.show_msg(f'已经复制:{web_url}')

self.copy_web_url_btn.clicked.connect(lambda: aio.run_afn(copy_song_web_url))
try:
web_url = self._app.library.song_get_web_url(song)
except ResourceNotFound:
self.copy_web_url_btn.hide()
else:
# TODO: Open url in browser when alt key is pressed. Use
# QDesktopServices.openUrl to open url in browser, and
# you may use QGuiApplication::keyboardModifiers to check
# if alt key is pressed.
#
# NOTE(cosven): Since switching from applications is inconvenience,
# the default behaviour of button is url-copy instead of url-open.
else:
self.copy_web_url_btn.hide()

async def copy_song_web_url():
QGuiApplication.clipboard().setText(web_url)
self._app.show_msg(f'已经复制:{web_url}')

self.copy_web_url_btn.clicked.connect(lambda: aio.run_afn(copy_song_web_url))

async def show_song_wiki(self, song, album):
aio.run_afn(self.song_wiki_label.show_song, song, album)
Expand Down

0 comments on commit d49e899

Please sign in to comment.