Getting closer, got an album view... ish
This commit is contained in:
parent
58f7cacec9
commit
cf9722516f
69
badwitch.py
69
badwitch.py
@ -13,7 +13,7 @@ from pathlib import Path
|
|||||||
from PyQt5.QtGui import QIcon
|
from PyQt5.QtGui import QIcon
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QAction, qApp, QApplication, QMainWindow, QWidget,
|
QAction, qApp, QApplication, QMainWindow, QWidget,
|
||||||
QPushButton,
|
QFrame, QLabel, QPushButton,
|
||||||
QGroupBox, QGridLayout, QHBoxLayout, QVBoxLayout
|
QGroupBox, QGridLayout, QHBoxLayout, QVBoxLayout
|
||||||
)
|
)
|
||||||
import argparse
|
import argparse
|
||||||
@ -143,6 +143,17 @@ class Library:
|
|||||||
except (KeyboardInterrupt, EOFError):
|
except (KeyboardInterrupt, EOFError):
|
||||||
logging.debug('Interrupt received, exiting')
|
logging.debug('Interrupt received, exiting')
|
||||||
|
|
||||||
|
class AlbumWidget(QFrame):
|
||||||
|
def __init__(self, album, albumcontent):
|
||||||
|
super().__init__()
|
||||||
|
self.album = albumcontent
|
||||||
|
self.title = album
|
||||||
|
self.initUI()
|
||||||
|
|
||||||
|
def initUI(self):
|
||||||
|
self.label = QLabel(self.title, self)
|
||||||
|
pass
|
||||||
|
|
||||||
class BadWitchGUI(QMainWindow):
|
class BadWitchGUI(QMainWindow):
|
||||||
# A Qt5 GUI
|
# A Qt5 GUI
|
||||||
def __init__(self, badwitch, library):
|
def __init__(self, badwitch, library):
|
||||||
@ -153,16 +164,30 @@ class BadWitchGUI(QMainWindow):
|
|||||||
# Set central widget to something blank
|
# Set central widget to something blank
|
||||||
# We don't care because we can access it later via method
|
# We don't care because we can access it later via method
|
||||||
self.setCentralWidget(QWidget())
|
self.setCentralWidget(QWidget())
|
||||||
# Init actions
|
# Initialize our UI
|
||||||
self.initActions()
|
self.initActions()
|
||||||
# Init UI
|
|
||||||
self.initUI()
|
self.initUI()
|
||||||
|
# Populate it
|
||||||
|
self.populateAlbums()
|
||||||
|
# Statusbar
|
||||||
|
self.statusBar().showMessage('Ready')
|
||||||
|
|
||||||
def initActions(self):
|
def initActions(self):
|
||||||
|
self.saveAct = QAction(QIcon.fromTheme('document-save'), '&Save', self)
|
||||||
|
saveAct = self.saveAct
|
||||||
|
saveAct.setShortcut('Ctrl+S')
|
||||||
|
saveAct.setStatusTip('Save outstanding library changes')
|
||||||
|
saveAct.triggered.connect(self.saveLib)
|
||||||
self.exitAct = QAction(QIcon.fromTheme('application-exit'), '&Exit', self)
|
self.exitAct = QAction(QIcon.fromTheme('application-exit'), '&Exit', self)
|
||||||
self.exitAct.setShortcut('Ctrl+Q')
|
exitAct = self.exitAct
|
||||||
self.exitAct.setStatusTip('Exit Bad Witch')
|
exitAct.setShortcut('Ctrl+Q')
|
||||||
self.exitAct.triggered.connect(qApp.quit)
|
exitAct.setStatusTip('Exit Bad Witch')
|
||||||
|
exitAct.triggered.connect(qApp.quit)
|
||||||
|
self.refreshAct = QAction(QIcon.fromTheme('view-refresh'), 'Reload Library', self)
|
||||||
|
refreshAct = self.refreshAct
|
||||||
|
refreshAct.setShortcut('Ctrl+R')
|
||||||
|
refreshAct.setStatusTip('Reload albums from library')
|
||||||
|
refreshAct.triggered.connect(self.populateAlbums)
|
||||||
|
|
||||||
def initUI(self):
|
def initUI(self):
|
||||||
# Main window shenanigans
|
# Main window shenanigans
|
||||||
@ -172,8 +197,11 @@ class BadWitchGUI(QMainWindow):
|
|||||||
# Menubar
|
# Menubar
|
||||||
menubar = self.menuBar()
|
menubar = self.menuBar()
|
||||||
fileMenu = menubar.addMenu('&File')
|
fileMenu = menubar.addMenu('&File')
|
||||||
|
fileMenu.addAction(self.saveAct)
|
||||||
|
fileMenu.addSeparator()
|
||||||
fileMenu.addAction(self.exitAct)
|
fileMenu.addAction(self.exitAct)
|
||||||
viewMenu = menubar.addMenu('&View')
|
viewMenu = menubar.addMenu('&View')
|
||||||
|
viewMenu.addAction(self.refreshAct)
|
||||||
|
|
||||||
# Container box
|
# Container box
|
||||||
self.containerBox = QGridLayout()
|
self.containerBox = QGridLayout()
|
||||||
@ -183,20 +211,35 @@ class BadWitchGUI(QMainWindow):
|
|||||||
# Song browser box
|
# Song browser box
|
||||||
self.libraryGroup = QGroupBox()
|
self.libraryGroup = QGroupBox()
|
||||||
self.libraryBox = QVBoxLayout()
|
self.libraryBox = QVBoxLayout()
|
||||||
libraryBox = self.libraryBox
|
self.libraryGroup.setLayout(self.libraryBox)
|
||||||
libraryBox.addWidget(self.libraryGroup)
|
containerBox.addWidget(self.libraryGroup, 0, 0)
|
||||||
containerBox.addLayout(libraryBox, 0, 0)
|
|
||||||
# Queue box
|
# Queue box
|
||||||
self.queueGroup = QGroupBox()
|
self.queueGroup = QGroupBox()
|
||||||
self.queueBox = QVBoxLayout()
|
self.queueBox = QVBoxLayout()
|
||||||
queueBox = self.queueBox
|
self.queueGroup.setLayout(self.queueBox)
|
||||||
testButton2 = QPushButton("queue")
|
containerBox.addWidget(self.queueGroup, 0, 1, 0, 2)
|
||||||
queueBox.addWidget(self.queueGroup)
|
|
||||||
containerBox.addLayout(queueBox, 0, 1, 0, 2)
|
|
||||||
|
|
||||||
# Show
|
# Show
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
def populateAlbums(self):
|
||||||
|
statusBar = self.statusBar()
|
||||||
|
# Remove all albums
|
||||||
|
statusBar.showMessage('Reloading library')
|
||||||
|
for widget in self.libraryGroup.findChildren(AlbumWidget):
|
||||||
|
widget.deleteLater()
|
||||||
|
self.lib.load()
|
||||||
|
for album, albumcontent in self.lib.albums.items():
|
||||||
|
albumWidget = AlbumWidget(album, albumcontent)
|
||||||
|
self.libraryBox.addWidget(albumWidget)
|
||||||
|
statusBar.showMessage('Library reloaded')
|
||||||
|
|
||||||
|
def saveLib(self):
|
||||||
|
statusBar = self.statusBar()
|
||||||
|
statusBar.showMessage('Saving library')
|
||||||
|
self.lib.save()
|
||||||
|
statusBar.showMessage('Library saved')
|
||||||
|
|
||||||
class BadWitch:
|
class BadWitch:
|
||||||
# Our program
|
# Our program
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user