Skip to content
Permalink
Browse files

gui: Added basic gui based on PyQt5 that can open, and display, a col…

…lection given the database and the songs directory.
  • Loading branch information...
Kurocon committed Dec 28, 2015
1 parent 61584cb commit f3bd93ea3f93eb5aa2e38dff0e90d1e400624e07
@@ -59,3 +59,5 @@ docs/_build/
# PyBuilder
target/

# Project specific gitignores
ui_designs/icons/
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'loading.ui'
#
# Created by: PyQt5 UI code generator 5.5.1
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_LoadingDialog(object):
def setupUi(self, LoadingDialog):
LoadingDialog.setObjectName("LoadingDialog")
LoadingDialog.resize(424, 83)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("icons/oce.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
LoadingDialog.setWindowIcon(icon)
self.verticalLayout = QtWidgets.QVBoxLayout(LoadingDialog)
self.verticalLayout.setObjectName("verticalLayout")
self.loading_label = QtWidgets.QLabel(LoadingDialog)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.loading_label.setFont(font)
self.loading_label.setObjectName("loading_label")
self.verticalLayout.addWidget(self.loading_label)
self.loading_current_label = QtWidgets.QLabel(LoadingDialog)
self.loading_current_label.setObjectName("loading_current_label")
self.verticalLayout.addWidget(self.loading_current_label)
self.progressbar = QtWidgets.QProgressBar(LoadingDialog)
self.progressbar.setProperty("value", 0)
self.progressbar.setObjectName("progressbar")
self.verticalLayout.addWidget(self.progressbar)

self.retranslateUi(LoadingDialog)
QtCore.QMetaObject.connectSlotsByName(LoadingDialog)

def retranslateUi(self, LoadingDialog):
_translate = QtCore.QCoreApplication.translate
LoadingDialog.setWindowTitle(_translate("LoadingDialog", "Loading..."))
self.loading_label.setText(_translate("LoadingDialog", "Loading loading dialog..."))
self.loading_current_label.setText(_translate("LoadingDialog", "..."))

Large diffs are not rendered by default.

@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'notification.ui'
#
# Created by: PyQt5 UI code generator 5.5.1
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_NotificationDialog(object):
def setupUi(self, NotificationDialog):
NotificationDialog.setObjectName("NotificationDialog")
NotificationDialog.resize(400, 100)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("icons/oce.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
NotificationDialog.setWindowIcon(icon)
self.verticalLayout = QtWidgets.QVBoxLayout(NotificationDialog)
self.verticalLayout.setObjectName("verticalLayout")
self.label = QtWidgets.QLabel(NotificationDialog)
self.label.setWordWrap(True)
self.label.setObjectName("label")
self.verticalLayout.addWidget(self.label)
self.buttonBox = QtWidgets.QDialogButtonBox(NotificationDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox)

self.retranslateUi(NotificationDialog)
self.buttonBox.accepted.connect(NotificationDialog.accept)
self.buttonBox.rejected.connect(NotificationDialog.reject)
QtCore.QMetaObject.connectSlotsByName(NotificationDialog)

def retranslateUi(self, NotificationDialog):
_translate = QtCore.QCoreApplication.translate
NotificationDialog.setWindowTitle(_translate("NotificationDialog", "Notification"))
self.label.setText(_translate("NotificationDialog", "Something happened."))

@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'question.ui'
#
# Created by: PyQt5 UI code generator 5.5.1
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_QuestionDialog(object):
def setupUi(self, QuestionDialog):
QuestionDialog.setObjectName("QuestionDialog")
QuestionDialog.resize(400, 100)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("icons/oce.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
QuestionDialog.setWindowIcon(icon)
self.verticalLayout = QtWidgets.QVBoxLayout(QuestionDialog)
self.verticalLayout.setObjectName("verticalLayout")
self.label = QtWidgets.QLabel(QuestionDialog)
self.label.setWordWrap(True)
self.label.setObjectName("label")
self.verticalLayout.addWidget(self.label)
self.buttonBox = QtWidgets.QDialogButtonBox(QuestionDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.No|QtWidgets.QDialogButtonBox.Yes)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox)

self.retranslateUi(QuestionDialog)
self.buttonBox.accepted.connect(QuestionDialog.accept)
self.buttonBox.rejected.connect(QuestionDialog.reject)
QtCore.QMetaObject.connectSlotsByName(QuestionDialog)

def retranslateUi(self, QuestionDialog):
_translate = QtCore.QCoreApplication.translate
QuestionDialog.setWindowTitle(_translate("QuestionDialog", "Question"))
self.label.setText(_translate("QuestionDialog", "Would you like to do something?"))

@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'startup.ui'
#
# Created by: PyQt5 UI code generator 5.5.1
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_LoadDialog(object):
def setupUi(self, LoadDialog):
LoadDialog.setObjectName("LoadDialog")
LoadDialog.resize(599, 160)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("icons/oce.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
LoadDialog.setWindowIcon(icon)
self.verticalLayout = QtWidgets.QVBoxLayout(LoadDialog)
self.verticalLayout.setObjectName("verticalLayout")
self.grid_layout = QtWidgets.QGridLayout()
self.grid_layout.setObjectName("grid_layout")
self.songdir_label = QtWidgets.QLabel(LoadDialog)
self.songdir_label.setObjectName("songdir_label")
self.grid_layout.addWidget(self.songdir_label, 1, 0, 1, 1)
self.collection_label = QtWidgets.QLabel(LoadDialog)
self.collection_label.setObjectName("collection_label")
self.grid_layout.addWidget(self.collection_label, 2, 0, 1, 1)
self.songdir_edit = QtWidgets.QLineEdit(LoadDialog)
self.songdir_edit.setObjectName("songdir_edit")
self.grid_layout.addWidget(self.songdir_edit, 1, 1, 1, 1)
self.collectionfile_edit = QtWidgets.QLineEdit(LoadDialog)
self.collectionfile_edit.setObjectName("collectionfile_edit")
self.grid_layout.addWidget(self.collectionfile_edit, 2, 1, 1, 1)
self.songdir_button = QtWidgets.QPushButton(LoadDialog)
self.songdir_button.setStatusTip("")
self.songdir_button.setObjectName("songdir_button")
self.grid_layout.addWidget(self.songdir_button, 1, 2, 1, 1)
self.collectionfile_button = QtWidgets.QPushButton(LoadDialog)
self.collectionfile_button.setStatusTip("")
self.collectionfile_button.setObjectName("collectionfile_button")
self.grid_layout.addWidget(self.collectionfile_button, 2, 2, 1, 1)
self.help_label = QtWidgets.QLabel(LoadDialog)
self.help_label.setTextFormat(QtCore.Qt.PlainText)
self.help_label.setScaledContents(False)
self.help_label.setAlignment(QtCore.Qt.AlignCenter)
self.help_label.setWordWrap(True)
self.help_label.setObjectName("help_label")
self.grid_layout.addWidget(self.help_label, 0, 0, 1, 3)
self.verticalLayout.addLayout(self.grid_layout)
self.button_box = QtWidgets.QDialogButtonBox(LoadDialog)
self.button_box.setStatusTip("")
self.button_box.setOrientation(QtCore.Qt.Horizontal)
self.button_box.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.button_box.setObjectName("button_box")
self.verticalLayout.addWidget(self.button_box)

self.retranslateUi(LoadDialog)
self.button_box.accepted.connect(LoadDialog.accept)
self.button_box.rejected.connect(LoadDialog.reject)
QtCore.QMetaObject.connectSlotsByName(LoadDialog)

def retranslateUi(self, LoadDialog):
_translate = QtCore.QCoreApplication.translate
LoadDialog.setWindowTitle(_translate("LoadDialog", "Open collection"))
self.songdir_label.setText(_translate("LoadDialog", "Songs directory"))
self.collection_label.setText(_translate("LoadDialog", "collection.db"))
self.songdir_button.setText(_translate("LoadDialog", "Browse"))
self.collectionfile_button.setText(_translate("LoadDialog", "Browse"))
self.help_label.setText(_translate("LoadDialog", "Please locate your osu! Songs directory and the collection.db file you wish to edit."))

@@ -0,0 +1,84 @@
from logging.config import logging
from PyQt5 import QtWidgets, QtCore, QtGui
import gui.loading
import settings
import util.collections_parser as cp
import util.osu_parser as op
import util.song_collection_matcher as scm
from gui_controller.simpledialogs import QuestionDialog, NotificationDialog


class Loading(QtWidgets.QDialog):
progress = QtCore.pyqtSignal(int)
current = QtCore.pyqtSignal(str)
text = QtCore.pyqtSignal(str)
done = QtCore.pyqtSignal()

def __init__(self, collectionfile, songdir):
super(Loading, self).__init__()
self.log = logging.getLogger(__name__)

self.ui = gui.loading.Ui_LoadingDialog()
self.ui.setupUi(self)

self.collections = None
self.songs = None
self.collection_file = collectionfile
self.song_directory = songdir

self.progress.connect(self.update_precentage)
self.current.connect(self.update_current)
self.text.connect(self.update_text)
self.done.connect(self.dismiss)

self.ui.progressbar.setRange(0, 100)

self.thread = QtCore.QThread()

def update_precentage(self, percentage):
self.ui.progressbar.setValue(percentage)
QtWidgets.qApp.processEvents()

def update_text(self, text):
if len(text) > 33:
text = text[:30] + "..."
self.ui.loading_label.setText(text)

def update_current(self, text):
if len(text) > 33:
text = text[:30] + "..."
self.ui.loading_current_label.setText(text)

def exec_(self):
w = LoadTask(self.collection_file, self.song_directory, self)
w.moveToThread(self.thread)
self.thread.started.connect(w.work)
self.thread.start()
super(Loading, self).exec_()

def dismiss(self):
self.hide()


class LoadTask(QtCore.QObject):
def __init__(self, cf, sd, dialog):
super(LoadTask, self).__init__()
self.collection_file = cf
self.song_directory = sd
self.dialog = dialog
self.settings = settings.Settings.get_instance()
self.log = logging.getLogger(__name__)

def work(self):
# Load collections from file
self.log.debug("Loading collections...")
self.dialog.text.emit("Loading collections...")
self.dialog.collections = cp.parse_collections_gui(self.collection_file, self.dialog)

# Load songs from dir
self.log.debug("Loading songs...")
self.dialog.text.emit("Loading songs...")
self.dialog.songs = op.load_songs_from_dir_gui(self.song_directory, self.dialog)

# Notify we're done.
self.dialog.done.emit()

0 comments on commit f3bd93e

Please sign in to comment.
You can’t perform that action at this time.