Have one "info" button for both Songfacts and Wikipedia
This commit is contained in:
parent
5492ad58d5
commit
00c9509c12
@ -139,9 +139,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
self.btnFade.clicked.connect(self.fade)
|
||||
self.btnPlay.clicked.connect(self.play_next)
|
||||
self.btnSetNext.clicked.connect(self.set_next_track)
|
||||
self.btnSongfacts.clicked.connect(self.songfacts_search)
|
||||
self.btnSongInfo.clicked.connect(self.song_info_search)
|
||||
self.btnStop.clicked.connect(self.stop)
|
||||
self.btnWikipedia.clicked.connect(self.wikipedia_search)
|
||||
self.spnVolume.valueChanged.connect(self.change_volume)
|
||||
self.tabPlaylist.currentChanged.connect(self.tab_change)
|
||||
|
||||
@ -407,11 +406,28 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
|
||||
QMessageBox.warning(None, title, msg, buttons=QMessageBox.Cancel)
|
||||
|
||||
def songfacts_search(self):
|
||||
"Open a browser window in Songfacts searching for selected title"
|
||||
def song_info_search(self):
|
||||
"""
|
||||
Open browser tabs for Wikipedia and Songfacts, searching for
|
||||
the first that exists of:
|
||||
- selected track
|
||||
- current track
|
||||
- next track
|
||||
"""
|
||||
|
||||
title = self.visible_playlist().get_selected_title()
|
||||
if not title:
|
||||
if self.current_track:
|
||||
title = self.current_track.title
|
||||
if not title:
|
||||
if self.next_track:
|
||||
title = self.next_track.title
|
||||
if title:
|
||||
# Wikipedia
|
||||
str = urllib.parse.quote_plus(title)
|
||||
url = f"https://www.wikipedia.org/w/index.php?search={str}"
|
||||
webbrowser.open(url, new=2)
|
||||
# Songfacts
|
||||
slug = slugify(title, replacements=([["'", ""]]))
|
||||
url = f"https://www.songfacts.com/search/songs/{slug}"
|
||||
webbrowser.open(url, new=2)
|
||||
@ -570,15 +586,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
except AttributeError:
|
||||
self.hdrNextTrack.setText("")
|
||||
|
||||
def wikipedia_search(self):
|
||||
"Open a browser window in Wikipedia searching for selected title"
|
||||
|
||||
title = self.visible_playlist().get_selected_title()
|
||||
if title:
|
||||
str = urllib.parse.quote_plus(title)
|
||||
url = f"https://www.wikipedia.org/w/index.php?search={str}"
|
||||
webbrowser.open(url, new=2)
|
||||
|
||||
|
||||
class DbDialog(QDialog):
|
||||
def __init__(self, parent=None):
|
||||
|
||||
@ -260,6 +260,36 @@ border: 1px solid rgb(85, 87, 83);</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>68</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnSongInfo">
|
||||
<property name="text">
|
||||
<string>Song info</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<normaloff>:/icons/wikipedia</normaloff>:/icons/wikipedia</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnSetNext">
|
||||
<property name="text">
|
||||
@ -278,43 +308,13 @@ border: 1px solid rgb(85, 87, 83);</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>68</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnWikipedia">
|
||||
<widget class="QPushButton" name="btnDatabase">
|
||||
<property name="text">
|
||||
<string>Wikipedia</string>
|
||||
<string>Database</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<normaloff>:/icons/wikipedia</normaloff>:/icons/wikipedia</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnSongfacts">
|
||||
<property name="text">
|
||||
<string>Songfacts</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<normaloff>:/icons/songsearch</normaloff>:/icons/songsearch</iconset>
|
||||
<normaloff>:/icons/search_db</normaloff>:/icons/search_db</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
@ -368,13 +368,13 @@ border: 1px solid rgb(85, 87, 83);</string>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnDatabase">
|
||||
<widget class="QPushButton" name="btnAddNote">
|
||||
<property name="text">
|
||||
<string>Database</string>
|
||||
<string>Add note</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<normaloff>:/icons/search_db</normaloff>:/icons/search_db</iconset>
|
||||
<normaloff>:/icons/note</normaloff>:/icons/note</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
@ -401,23 +401,6 @@ border: 1px solid rgb(85, 87, 83);</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnAddNote">
|
||||
<property name="text">
|
||||
<string>Add note</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<normaloff>:/icons/note</normaloff>:/icons/note</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
@ -751,7 +734,7 @@ border: 1px solid rgb(85, 87, 83);</string>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1164</width>
|
||||
<height>18</height>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user