220 lines
12 KiB
Python
220 lines
12 KiB
Python
# -*- coding: utf-8 -*-
|
|
import qtawesome as qta
|
|
from PyQt5 import QtCore, QtWidgets
|
|
|
|
LIST_WIDGET_STYLES = """
|
|
QListWidget {
|
|
border: 0;
|
|
}
|
|
"""
|
|
|
|
|
|
class UiMainWindow(object):
|
|
def setup_ui(self):
|
|
self.setObjectName("MainWindow")
|
|
self.resize(719, 574)
|
|
self.setStyleSheet(LIST_WIDGET_STYLES)
|
|
self.centralwidget = QtWidgets.QWidget(self)
|
|
self.centralwidget.setObjectName("centralwidget")
|
|
self.centralLayout = QtWidgets.QVBoxLayout(self.centralwidget)
|
|
self.centralLayout.setContentsMargins(0, 0, 0, 0)
|
|
self.centralLayout.setSpacing(0)
|
|
self.centralLayout.setObjectName("centralLayout")
|
|
self.playbackWidget = QtWidgets.QWidget(self.centralwidget)
|
|
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
|
|
sizePolicy.setHorizontalStretch(0)
|
|
sizePolicy.setVerticalStretch(0)
|
|
sizePolicy.setHeightForWidth(self.playbackWidget.sizePolicy().hasHeightForWidth())
|
|
self.playbackWidget.setSizePolicy(sizePolicy)
|
|
self.playbackWidget.setMinimumSize(QtCore.QSize(0, 36))
|
|
self.playbackWidget.setObjectName("playbackWidget")
|
|
self.playbackLayout = QtWidgets.QHBoxLayout(self.playbackWidget)
|
|
self.playbackLayout.setContentsMargins(0, 0, 0, 0)
|
|
self.playbackLayout.setSpacing(0)
|
|
self.playbackLayout.setObjectName("playbackLayout")
|
|
self.toggleButton = QtWidgets.QToolButton(self.playbackWidget)
|
|
self.toggleButton.setIcon(qta.icon("mdi.chevron-down"))
|
|
self.toggleButton.setAutoRaise(True)
|
|
self.toggleButton.setObjectName("toggleButton")
|
|
self.playbackLayout.addWidget(self.toggleButton)
|
|
self.previousButton = QtWidgets.QToolButton(self.playbackWidget)
|
|
self.previousButton.setIcon(qta.icon("mdi.skip-previous"))
|
|
self.previousButton.setAutoRaise(True)
|
|
self.previousButton.setObjectName("previousButton")
|
|
self.playbackLayout.addWidget(self.previousButton)
|
|
self.playButton = QtWidgets.QToolButton(self.playbackWidget)
|
|
self.playButton.setIcon(qta.icon("mdi.play"))
|
|
self.playButton.setAutoRaise(True)
|
|
self.playButton.setObjectName("playButton")
|
|
self.playbackLayout.addWidget(self.playButton)
|
|
self.nextButton = QtWidgets.QToolButton(self.playbackWidget)
|
|
self.nextButton.setIcon(qta.icon("mdi.skip-next"))
|
|
self.nextButton.setAutoRaise(True)
|
|
self.nextButton.setObjectName("nextButton")
|
|
self.playbackLayout.addWidget(self.nextButton)
|
|
self.positionLabel = QtWidgets.QLabel(self.playbackWidget)
|
|
self.positionLabel.setAlignment(QtCore.Qt.AlignCenter)
|
|
self.positionLabel.setObjectName("positionLabel")
|
|
self.playbackLayout.addWidget(self.positionLabel)
|
|
self.positionSlider = QtWidgets.QSlider(self.playbackWidget)
|
|
self.positionSlider.setOrientation(QtCore.Qt.Horizontal)
|
|
self.positionSlider.setObjectName("positionSlider")
|
|
self.playbackLayout.addWidget(self.positionSlider)
|
|
self.shuffleButton = QtWidgets.QToolButton(self.playbackWidget)
|
|
self.shuffleButton.setIcon(qta.icon("mdi.shuffle"))
|
|
self.shuffleButton.setAutoRaise(True)
|
|
self.shuffleButton.setObjectName("shuffleButton")
|
|
self.playbackLayout.addWidget(self.shuffleButton)
|
|
self.repeatButton = QtWidgets.QToolButton(self.playbackWidget)
|
|
self.repeatButton.setIcon(qta.icon("mdi.repeat"))
|
|
self.repeatButton.setAutoRaise(True)
|
|
self.repeatButton.setObjectName("repeatButton")
|
|
self.playbackLayout.addWidget(self.repeatButton)
|
|
self.muteButton = QtWidgets.QToolButton(self.playbackWidget)
|
|
self.muteButton.setIcon(qta.icon("mdi.volume-high"))
|
|
self.muteButton.setCheckable(True)
|
|
self.muteButton.setAutoRaise(True)
|
|
self.muteButton.setObjectName("muteButton")
|
|
self.playbackLayout.addWidget(self.muteButton)
|
|
self.volumeSlider = QtWidgets.QSlider(self.playbackWidget)
|
|
self.volumeSlider.setOrientation(QtCore.Qt.Horizontal)
|
|
self.volumeSlider.setObjectName("volumeSlider")
|
|
self.playbackLayout.addWidget(self.volumeSlider)
|
|
self.menuButton = QtWidgets.QToolButton(self.playbackWidget)
|
|
self.menuButton.setIcon(qta.icon("mdi.menu"))
|
|
self.menuButton.setPopupMode(QtWidgets.QToolButton.DelayedPopup)
|
|
self.menuButton.setAutoRaise(True)
|
|
self.menuButton.setObjectName("menuButton")
|
|
self.playbackLayout.addWidget(self.menuButton)
|
|
self.centralLayout.addWidget(self.playbackWidget)
|
|
self.splitter = QtWidgets.QSplitter(self.centralwidget)
|
|
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
sizePolicy.setHorizontalStretch(0)
|
|
sizePolicy.setVerticalStretch(0)
|
|
sizePolicy.setHeightForWidth(self.splitter.sizePolicy().hasHeightForWidth())
|
|
self.splitter.setSizePolicy(sizePolicy)
|
|
self.splitter.setOrientation(QtCore.Qt.Horizontal)
|
|
self.splitter.setHandleWidth(1)
|
|
self.splitter.setObjectName("splitter")
|
|
self.viewListWidget = QtWidgets.QListWidget(self.splitter)
|
|
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding)
|
|
sizePolicy.setHorizontalStretch(0)
|
|
sizePolicy.setVerticalStretch(0)
|
|
sizePolicy.setHeightForWidth(self.viewListWidget.sizePolicy().hasHeightForWidth())
|
|
self.viewListWidget.setSizePolicy(sizePolicy)
|
|
self.viewListWidget.setObjectName("viewListWidget")
|
|
self.stackedWidget = QtWidgets.QStackedWidget(self.splitter)
|
|
self.stackedWidget.setObjectName("stackedWidget")
|
|
self.albumPage = QtWidgets.QWidget()
|
|
self.albumPage.setObjectName("albumPage")
|
|
self.albumPageLayout = QtWidgets.QVBoxLayout(self.albumPage)
|
|
self.albumPageLayout.setContentsMargins(0, 0, 0, 0)
|
|
self.albumPageLayout.setSpacing(0)
|
|
self.albumPageLayout.setObjectName("albumPageLayout")
|
|
self.albumPageTitleLayout = QtWidgets.QHBoxLayout()
|
|
self.albumPageTitleLayout.setContentsMargins(0, 0, 0, 0)
|
|
self.albumPageTitleLayout.setSpacing(0)
|
|
self.albumPageTitleLayout.setObjectName("albumPageTitleLayout")
|
|
self.albumPageIconLabel = QtWidgets.QLabel(self.albumPage)
|
|
self.albumPageIconLabel.setPixmap(
|
|
qta.icon('mdi.album').pixmap(self.albumPageIconLabel.geometry().height()))
|
|
self.albumPageTitleLayout.addWidget(self.albumPageIconLabel)
|
|
self.albumPageTitleLabel = QtWidgets.QLabel(self.albumPage)
|
|
self.albumPageTitleLayout.addWidget(self.albumPageTitleLabel)
|
|
self.albumPageLayout.addLayout(self.albumPageTitleLayout)
|
|
self.albumListWidget = QtWidgets.QListWidget(self.albumPage)
|
|
self.albumListWidget.setObjectName("albumListWidget")
|
|
self.albumListWidget.setSortingEnabled(True)
|
|
# self.albumListWidget.setViewMode(QtWidgets.QListView.IconMode)
|
|
# self.albumListWidget.setMovement(QtWidgets.QListView.Static)
|
|
self.albumListWidget.setIconSize(QtCore.QSize(100, 100))
|
|
# self.albumListWidget.setGridSize(QtCore.QSize(128, 128))
|
|
self.albumPageLayout.addWidget(self.albumListWidget)
|
|
self.stackedWidget.addWidget(self.albumPage)
|
|
self.artistPage = QtWidgets.QWidget()
|
|
self.artistPage.setObjectName("artistPage")
|
|
self.artistPageLayout = QtWidgets.QVBoxLayout(self.artistPage)
|
|
self.artistPageLayout.setContentsMargins(0, 0, 0, 0)
|
|
self.artistPageLayout.setSpacing(0)
|
|
self.artistPageLayout.setObjectName("artistPageLayout")
|
|
self.artistListWidget = QtWidgets.QListWidget(self.artistPage)
|
|
self.artistListWidget.setObjectName("artistListWidget")
|
|
self.artistListWidget.setSortingEnabled(True)
|
|
self.artistListWidget.setViewMode(QtWidgets.QListView.IconMode)
|
|
self.artistListWidget.setMovement(QtWidgets.QListView.Static)
|
|
self.artistPageLayout.addWidget(self.artistListWidget)
|
|
self.stackedWidget.addWidget(self.artistPage)
|
|
self.trackPage = QtWidgets.QWidget()
|
|
self.trackPage.setObjectName("trackPage")
|
|
self.trackPageLayout = QtWidgets.QVBoxLayout(self.trackPage)
|
|
self.trackPageLayout.setContentsMargins(0, 0, 0, 0)
|
|
self.trackPageLayout.setSpacing(0)
|
|
self.trackPageLayout.setObjectName("trackPageLayout")
|
|
self.trackListWidget = QtWidgets.QListWidget(self.trackPage)
|
|
self.trackListWidget.setObjectName("trackListWidget")
|
|
self.trackListWidget.setSortingEnabled(True)
|
|
self.trackListWidget.setViewMode(QtWidgets.QListView.IconMode)
|
|
self.trackListWidget.setMovement(QtWidgets.QListView.Static)
|
|
self.trackPageLayout.addWidget(self.trackListWidget)
|
|
self.stackedWidget.addWidget(self.trackPage)
|
|
self.playlistListWidget = QtWidgets.QListWidget(self.splitter)
|
|
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.MinimumExpanding)
|
|
sizePolicy.setHorizontalStretch(0)
|
|
sizePolicy.setVerticalStretch(0)
|
|
sizePolicy.setHeightForWidth(self.playlistListWidget.sizePolicy().hasHeightForWidth())
|
|
self.playlistListWidget.setSizePolicy(sizePolicy)
|
|
self.playlistListWidget.setObjectName("playlistListWidget")
|
|
self.centralLayout.addWidget(self.splitter)
|
|
self.setCentralWidget(self.centralwidget)
|
|
self.statusbar = QtWidgets.QStatusBar(self)
|
|
self.statusbar.setObjectName("statusbar")
|
|
self.setStatusBar(self.statusbar)
|
|
self.actionPlay = QtWidgets.QAction(self)
|
|
self.actionPlay.setObjectName("actionPlay")
|
|
|
|
self.mainMenu = QtWidgets.QMenu(self)
|
|
self.settingsAction = self.mainMenu.addAction(qta.icon('mdi.application-settings'), '')
|
|
|
|
self.albumsListItem = QtWidgets.QListWidgetItem(qta.icon('mdi.album'), '')
|
|
self.artistsListItem = QtWidgets.QListWidgetItem(qta.icon('mdi.account'), '')
|
|
self.tracksListItem = QtWidgets.QListWidgetItem(qta.icon('mdi.music'), '')
|
|
for item in [self.albumsListItem, self.artistsListItem, self.tracksListItem]:
|
|
self.viewListWidget.addItem(item)
|
|
|
|
self.splitter.setStretchFactor(1, 1)
|
|
self.retranslate_ui()
|
|
self.menuButton.clicked.connect(self.on_menu_button_clicked)
|
|
self.viewListWidget.currentRowChanged.connect(self.on_view_list_current_row_changed)
|
|
self.viewListWidget.setCurrentRow(0)
|
|
QtCore.QMetaObject.connectSlotsByName(self)
|
|
|
|
self.viewListWidget.setFocus()
|
|
|
|
def retranslate_ui(self):
|
|
_translate = QtCore.QCoreApplication.translate
|
|
self.setWindowTitle(_translate("MainWindow", "PyFunkwhale"))
|
|
self.toggleButton.setText(_translate("MainWindow", "..."))
|
|
self.previousButton.setText(_translate("MainWindow", "..."))
|
|
self.playButton.setText(_translate("MainWindow", "..."))
|
|
self.nextButton.setText(_translate("MainWindow", "..."))
|
|
self.positionLabel.setText(_translate("MainWindow", "01:43"))
|
|
self.shuffleButton.setText(_translate("MainWindow", "..."))
|
|
self.repeatButton.setText(_translate("MainWindow", "..."))
|
|
self.muteButton.setText(_translate("MainWindow", "..."))
|
|
self.menuButton.setText(_translate("MainWindow", "..."))
|
|
self.actionPlay.setText(_translate("MainWindow", "&Play"))
|
|
self.actionPlay.setToolTip(_translate("MainWindow", "Play"))
|
|
self.settingsAction.setText(_translate("MainWindow", "&Configure"))
|
|
self.albumsListItem.setText(_translate("MainWindow", "Albums"))
|
|
self.albumPageTitleLabel.setText(_translate("MainWindow", "Albums"))
|
|
self.artistsListItem.setText(_translate("MainWindow", "Artists"))
|
|
self.tracksListItem.setText(_translate("MainWindow", "Tracks"))
|
|
|
|
def on_menu_button_clicked(self):
|
|
pos = self.mapToGlobal(self.menuButton.geometry().bottomRight())
|
|
pos.setX(pos.x() - self.mainMenu.geometry().width())
|
|
self.mainMenu.exec(pos)
|
|
|
|
def on_view_list_current_row_changed(self, current_row):
|
|
self.stackedWidget.setCurrentIndex(current_row)
|