def create_converted_version(self): debug("BeatmapControl.create_converted_version: started.") audio = Audio(self.beatmap_audio_path) start = time.time() audio.convert_nc_to_dt(self.nc2dt_audio_path) end = time.time() debug("BeatmapControl.create_converted_version: NC2DT in ", end - start, "seconds")
def onBeatmapSearchEnter(self): search_term = self.ui.beatmapSearchLineEdit.text() debug("MainWindow: searching for ", search_term) results = self.osu_db.search_beatmap(search_term) debug("MainWindow: found {} results".format(len(results))) self.itemModel.clear() for beatmap in results: item = QtGui.QStandardItem("{} - {} ({}) [{}]".format( beatmap.artist, beatmap.title, beatmap.creator, beatmap.difficulty)) item.setData(beatmap) self.itemModel.appendRow(item)
def __init__(self, osu_db: OsuDB): super().__init__() self.osu_db = osu_db self.ui = Ui_MainWindow() self.ui.setupUi(self) debug("Loading icon from", str(resource_path(Path("icon/nc2dt.png")))) self.setWindowIcon( QtGui.QIcon(str(resource_path(Path("icon/nc2dt.png"))))) self.ui.beatmapSearchLineEdit.returnPressed.connect( self.onBeatmapSearchEnter) self.ui.beatmapsListView.doubleClicked.connect( self.onBeatmapResultDoubleClick) self.ui.actionChangeOsuPath.triggered.connect(self.onChangeOsuPath) self.itemModel = QtGui.QStandardItemModel(self.ui.beatmapsListView) self.ui.beatmapsListView.setModel(self.itemModel)
def onCreateConvertedAudioClicked(self): # This will block... Find a way to smoothly do this, unblocking. progress_dialog = QtWidgets.QProgressDialog("Converting...", None, 0, 0, self) progress_dialog.setWindowTitle("Conversion in progress...") def run_conversion(): debug("Starting conversion...") self.beatmapControl.create_converted_version() debug("Closing progress dialog...") progress_dialog.close() t = Thread(target=run_conversion) t.start() progress_dialog.exec() debug("Past progress dialog...") t.join() self.updateUi()
def onBeatmapResultDoubleClick(self, index): item = self.itemModel.itemFromIndex(index) beatmap = item.data() debug("MainWindow.onBeatmapResultDoubleClick: got", beatmap) BeatmapDetails(self, beatmap).exec()
def run_conversion(): debug("Starting conversion...") self.beatmapControl.create_converted_version() debug("Closing progress dialog...") progress_dialog.close()