Moved track and playlist opening related gui functions to the popups class.
This commit is contained in:
parent
cdabced202
commit
a4fa2c7f75
3 changed files with 54 additions and 38 deletions
|
@ -2,13 +2,17 @@
|
|||
|
||||
from PyQt6.QtCore import Qt, QTimer
|
||||
from PyQt6.QtWidgets import QDockWidget, QFileDialog
|
||||
|
||||
from .ui.main_window import MainWindow
|
||||
from .ui.popups import Popups
|
||||
|
||||
|
||||
class GUI:
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
|
||||
|
||||
|
||||
self.dropped = []
|
||||
|
||||
self.window = MainWindow(app, self)
|
||||
|
@ -17,6 +21,8 @@ class GUI:
|
|||
self.process_dock = self.window.process_dock
|
||||
self.track_info = self.window.track_info
|
||||
|
||||
self.popups = Popups(app, self)
|
||||
|
||||
self.window.addDockWidget(Qt.DockWidgetArea.LeftDockWidgetArea, self.app.library.main_library_dock)
|
||||
|
||||
self.app.library.main_library_dock.setFeatures(
|
||||
|
@ -30,16 +36,6 @@ class GUI:
|
|||
elif self.app.settings.window_size is not None:
|
||||
self.window.resize(*self.app.settings.window_size)
|
||||
|
||||
self.audio_file_selector = QFileDialog(self.window, "Select Audio Files")
|
||||
self.audio_file_selector.setFileMode(QFileDialog.FileMode.ExistingFiles)
|
||||
self.audio_file_selector.setNameFilters(["Audio Files (*.flac *.wav *.mp3 *.ogg *.opus)", "Any (*)"])
|
||||
self.audio_file_selector.setViewMode(QFileDialog.ViewMode.List)
|
||||
|
||||
self.playlist_file_selector = QFileDialog(self.window, "Select Playlist")
|
||||
self.playlist_file_selector.setFileMode(QFileDialog.FileMode.ExistingFile)
|
||||
self.playlist_file_selector.setNameFilters(["Playlists (*.wbz.m3u *.m3u)", "Any (*)"])
|
||||
self.playlist_file_selector.setViewMode(QFileDialog.ViewMode.List)
|
||||
|
||||
self.gui_update_timer = QTimer()
|
||||
self.gui_update_timer.timeout.connect(self.update_gui)
|
||||
self.gui_update_timer.start(1000 // self.app.settings.gui_update_rate)
|
||||
|
@ -82,31 +78,7 @@ class GUI:
|
|||
self.track_control.on_playstate_update()
|
||||
self.track_info.update_info()
|
||||
|
||||
def select_audio_files(self):
|
||||
if self.audio_file_selector.exec():
|
||||
return self.audio_file_selector.selectedFiles()
|
||||
|
||||
def select_playlist_file(self):
|
||||
if self.playlist_file_selector.exec():
|
||||
return self.playlist_file_selector.selectedFiles()[0]
|
||||
|
||||
def open_tracks(self):
|
||||
files = self.select_audio_files()
|
||||
|
||||
if files is not None and not files == []:
|
||||
self.app.library.open_tracks(files)
|
||||
|
||||
def import_tracks(self):
|
||||
self.open_tracks() # placeholder
|
||||
|
||||
def import_playlist(self):
|
||||
playlist_path = self.select_playlist_file()
|
||||
|
||||
if playlist_path is not None and not playlist_path == "":
|
||||
self.app.library.import_playlist(playlist_path)
|
||||
|
||||
def update_gui(self):
|
||||
self.track_control.track_progress_slider.update_progress()
|
||||
if self.process_dock.isVisible():
|
||||
self.process_dock.update_processes()
|
||||
|
||||
|
|
|
@ -60,7 +60,3 @@ class MainWindow(QMainWindow):
|
|||
|
||||
self.settings_action.triggered.connect(self.settings.show)
|
||||
self.processes_action.triggered.connect(self.process_dock.show)
|
||||
self.open_track_action.triggered.connect(self.gui.open_tracks)
|
||||
self.import_track_action.triggered.connect(self.gui.import_tracks)
|
||||
self.import_playlist_action.triggered.connect(self.gui.import_playlist)
|
||||
|
||||
|
|
48
wobuzz/ui/popups.py
Normal file
48
wobuzz/ui/popups.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from PyQt6.QtWidgets import QFileDialog
|
||||
|
||||
|
||||
class Popups:
|
||||
def __init__(self, app, gui):
|
||||
self.app = app
|
||||
self.gui = gui
|
||||
|
||||
self.window = gui.window
|
||||
|
||||
self.audio_file_selector = QFileDialog(self.window, "Select Audio Files")
|
||||
self.audio_file_selector.setFileMode(QFileDialog.FileMode.ExistingFiles)
|
||||
self.audio_file_selector.setNameFilters(["Audio Files (*.flac *.wav *.mp3 *.ogg *.opus)", "Any (*)"])
|
||||
self.audio_file_selector.setViewMode(QFileDialog.ViewMode.List)
|
||||
|
||||
self.playlist_file_selector = QFileDialog(self.window, "Select Playlist")
|
||||
self.playlist_file_selector.setFileMode(QFileDialog.FileMode.ExistingFile)
|
||||
self.playlist_file_selector.setNameFilters(["Playlists (*.wbz.m3u *.m3u)", "Any (*)"])
|
||||
self.playlist_file_selector.setViewMode(QFileDialog.ViewMode.List)
|
||||
|
||||
self.window.open_track_action.triggered.connect(self.open_tracks)
|
||||
self.window.import_track_action.triggered.connect(self.import_tracks)
|
||||
self.window.import_playlist_action.triggered.connect(self.import_playlist)
|
||||
|
||||
def select_audio_files(self):
|
||||
if self.audio_file_selector.exec():
|
||||
return self.audio_file_selector.selectedFiles()
|
||||
|
||||
def select_playlist_file(self):
|
||||
if self.playlist_file_selector.exec():
|
||||
return self.playlist_file_selector.selectedFiles()[0]
|
||||
|
||||
def open_tracks(self):
|
||||
files = self.select_audio_files()
|
||||
|
||||
if files is not None and not files == []:
|
||||
self.app.library.open_tracks(files)
|
||||
|
||||
def import_tracks(self):
|
||||
self.open_tracks() # placeholder
|
||||
|
||||
def import_playlist(self):
|
||||
playlist_path = self.select_playlist_file()
|
||||
|
||||
if playlist_path is not None and not playlist_path == "":
|
||||
self.app.library.import_playlist(playlist_path)
|
Loading…
Add table
Reference in a new issue