Replace theme icons with standard icons
This commit is contained in:
parent
c2561e87ba
commit
9c417d7620
8
form.ui
8
form.ui
@ -79,10 +79,6 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="media-playback-start">
|
|
||||||
<normaloff>.</normaloff>.</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -116,10 +112,6 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="audio-volume-medium">
|
|
||||||
<normaloff>.</normaloff>.</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PySide6.QtCore import QUrl
|
from PySide6.QtCore import QUrl
|
||||||
from PySide6.QtWidgets import QApplication, QMainWindow, QMessageBox
|
from PySide6.QtWidgets import QApplication, QMainWindow, QMessageBox, QStyle
|
||||||
from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput
|
from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput
|
||||||
from PySide6.QtGui import QIcon
|
|
||||||
|
|
||||||
# Important:
|
# Important:
|
||||||
# You need to run the following command to generate the ui_form.py file
|
# You need to run the following command to generate the ui_form.py file
|
||||||
@ -26,12 +25,18 @@ class MainWindow(QMainWindow):
|
|||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.ui = Ui_MainWindow()
|
self.ui = Ui_MainWindow()
|
||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
|
volume_icon = self.style().standardIcon(QStyle.SP_MediaVolume)
|
||||||
|
playback_icon = self.style().standardIcon(QStyle.SP_MediaPlay)
|
||||||
|
self.ui.volumeToolButton.setIcon(volume_icon)
|
||||||
|
self.ui.playbackToolButton.setIcon(playback_icon)
|
||||||
|
|
||||||
self.__stations_data = self.getStationsData()
|
self.__stations_data = self.getStationsData()
|
||||||
self.__player = QMediaPlayer()
|
self.__player = QMediaPlayer()
|
||||||
self.__audio = QAudioOutput()
|
self.__audio = QAudioOutput()
|
||||||
self.__player.setAudioOutput(self.__audio)
|
self.__player.setAudioOutput(self.__audio)
|
||||||
self.setVolume(DEFAULT_VOLUME)
|
self.setVolume(DEFAULT_VOLUME)
|
||||||
self.printGroups()
|
self.printGroups()
|
||||||
|
|
||||||
self.ui.groupsListWidget.itemClicked.connect(self.printStations)
|
self.ui.groupsListWidget.itemClicked.connect(self.printStations)
|
||||||
self.ui.stationsListWidget.itemClicked.connect(self.playRadio)
|
self.ui.stationsListWidget.itemClicked.connect(self.playRadio)
|
||||||
self.ui.playbackToolButton.clicked.connect(self.togglePlayer)
|
self.ui.playbackToolButton.clicked.connect(self.togglePlayer)
|
||||||
@ -85,17 +90,15 @@ class MainWindow(QMainWindow):
|
|||||||
"""Toggle playback volume between 0 and DEFAULT_VOLUME."""
|
"""Toggle playback volume between 0 and DEFAULT_VOLUME."""
|
||||||
if self.ui.volumeHorizontalSlider.value() == 0:
|
if self.ui.volumeHorizontalSlider.value() == 0:
|
||||||
self.ui.volumeHorizontalSlider.setValue(DEFAULT_VOLUME)
|
self.ui.volumeHorizontalSlider.setValue(DEFAULT_VOLUME)
|
||||||
self.ui.volumeToolButton.setIcon(
|
icon = self.style().standardIcon(QStyle.SP_MediaVolume)
|
||||||
QIcon.fromTheme("audio-volume-medium")
|
|
||||||
)
|
|
||||||
self.setVolume(DEFAULT_VOLUME)
|
self.setVolume(DEFAULT_VOLUME)
|
||||||
else:
|
else:
|
||||||
self.ui.volumeHorizontalSlider.setValue(0)
|
self.ui.volumeHorizontalSlider.setValue(0)
|
||||||
self.ui.volumeToolButton.setIcon(
|
icon = self.style().standardIcon(QStyle.SP_MediaVolumeMuted)
|
||||||
QIcon.fromTheme("audio-volume-muted")
|
|
||||||
)
|
|
||||||
self.setVolume(0)
|
self.setVolume(0)
|
||||||
|
|
||||||
|
self.ui.volumeToolButton.setIcon(icon)
|
||||||
|
|
||||||
def playRadio(self) -> None:
|
def playRadio(self) -> None:
|
||||||
"""Play station selected by user."""
|
"""Play station selected by user."""
|
||||||
station = self.ui.stationsListWidget.selectedItems()[0].text()
|
station = self.ui.stationsListWidget.selectedItems()[0].text()
|
||||||
@ -105,9 +108,6 @@ class MainWindow(QMainWindow):
|
|||||||
stream_url = f"http://stream.open.fm/{e['id']}"
|
stream_url = f"http://stream.open.fm/{e['id']}"
|
||||||
|
|
||||||
self.__player.setSource(QUrl(stream_url))
|
self.__player.setSource(QUrl(stream_url))
|
||||||
self.ui.playbackToolButton.setIcon(
|
|
||||||
QIcon.fromTheme("media-playback-start")
|
|
||||||
)
|
|
||||||
self.togglePlayer()
|
self.togglePlayer()
|
||||||
|
|
||||||
def togglePlayer(self) -> None:
|
def togglePlayer(self) -> None:
|
||||||
@ -115,17 +115,15 @@ class MainWindow(QMainWindow):
|
|||||||
pb_state = QMediaPlayer.PlaybackState
|
pb_state = QMediaPlayer.PlaybackState
|
||||||
if self.__player.playbackState() == pb_state.PlayingState:
|
if self.__player.playbackState() == pb_state.PlayingState:
|
||||||
self.__player.stop()
|
self.__player.stop()
|
||||||
self.ui.playbackToolButton.setIcon(
|
icon = self.style().standardIcon(QStyle.SP_MediaPlay)
|
||||||
QIcon.fromTheme("media-playback-start")
|
|
||||||
)
|
|
||||||
elif self.__player.playbackState() == pb_state.StoppedState:
|
elif self.__player.playbackState() == pb_state.StoppedState:
|
||||||
self.__player.play()
|
self.__player.play()
|
||||||
self.ui.playbackToolButton.setIcon(
|
icon = self.style().standardIcon(QStyle.SP_MediaStop)
|
||||||
QIcon.fromTheme("media-playback-stop")
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
self.ui.playbackToolButton.setIcon(icon)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user