Rebase from dev
This commit is contained in:
parent
9e65eef621
commit
f143bd7fe9
@ -20,6 +20,7 @@ from PyQt5.QtWidgets import (
|
||||
QFileDialog,
|
||||
QInputDialog,
|
||||
QLabel,
|
||||
QLineEdit,
|
||||
QListWidgetItem,
|
||||
QMainWindow,
|
||||
)
|
||||
@ -79,6 +80,9 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
self.set_main_window_size()
|
||||
self.lblSumPlaytime: QLabel = QLabel("")
|
||||
self.statusbar.addPermanentWidget(self.lblSumPlaytime)
|
||||
self.txtSearch = QLineEdit()
|
||||
self.statusbar.addWidget(self.txtSearch)
|
||||
self.txtSearch.setHidden(True)
|
||||
|
||||
self.visible_playlist_tab: Callable[[], PlaylistTab] = \
|
||||
self.tabPlaylist.currentWidget
|
||||
@ -91,6 +95,25 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
def set_main_window_size(self) -> None:
|
||||
"""Set size of window from database"""
|
||||
|
||||
def add_file(self):
|
||||
dlg = QFileDialog()
|
||||
dlg.setFileMode(QFileDialog.ExistingFiles)
|
||||
dlg.setViewMode(QFileDialog.Detail)
|
||||
dlg.setDirectory(Config.ROOT)
|
||||
dlg.setNameFilter("Music files (*.flac *.mp3)")
|
||||
|
||||
if dlg.exec_():
|
||||
with Session() as session:
|
||||
for fname in dlg.selectedFiles():
|
||||
track = create_track_from_file(session, fname)
|
||||
# Add to playlist on screen
|
||||
# If we don't specify "repaint=False", playlist will
|
||||
# also be saved to database
|
||||
self.visible_playlist_tab().insert_track(session, track)
|
||||
|
||||
def set_main_window_size(self):
|
||||
"Set size of window from database"
|
||||
|
||||
with Session() as session:
|
||||
record = Settings.get_int_settings(session, "mainwindow_x")
|
||||
x = record.f_int or 1
|
||||
@ -182,6 +205,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
self.actionNewPlaylist.triggered.connect(self.create_playlist)
|
||||
self.actionOpenPlaylist.triggered.connect(self.open_playlist)
|
||||
self.actionPlay_next.triggered.connect(self.play_next)
|
||||
self.actionSearch.triggered.connect(self.search_playlist)
|
||||
self.actionSearch_database.triggered.connect(self.search_database)
|
||||
self.actionSelect_next_track.triggered.connect(self.select_next_row)
|
||||
self.actionSelect_played_tracks.triggered.connect(self.select_played)
|
||||
@ -203,6 +227,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
self.btnStop.clicked.connect(self.stop)
|
||||
self.spnVolume.valueChanged.connect(self.change_volume)
|
||||
self.tabPlaylist.tabCloseRequested.connect(self.close_tab)
|
||||
self.txtSearch.returnPressed.connect(self.search_playlist_return)
|
||||
self.txtSearch.textChanged.connect(self.search_playlist_update)
|
||||
|
||||
self.timer.timeout.connect(self.tick)
|
||||
|
||||
@ -624,6 +650,18 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
def open_playlist(self) -> None:
|
||||
"""Select and activate existing playlist"""
|
||||
|
||||
def search_playlist(self):
|
||||
self.txtSearch.setHidden(False)
|
||||
self.txtSearch.setFocus()
|
||||
|
||||
def search_playlist_return(self):
|
||||
self.txtSearch.setHidden(True)
|
||||
# TODO show all of playlist again
|
||||
|
||||
def search_playlist_update(self):
|
||||
print("search_playlist_update")
|
||||
|
||||
def open_playlist(self):
|
||||
with Session() as session:
|
||||
playlists = Playlists.get_closed(session)
|
||||
dlg = SelectPlaylistDialog(self, playlists=playlists,
|
||||
|
||||
@ -792,6 +792,10 @@ border: 1px solid rgb(85, 87, 83);</string>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionDownload_CSV_of_played_tracks"/>
|
||||
<addaction name="actionExport_playlist"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSelect_next_track"/>
|
||||
<addaction name="actionSelect_previous_track"/>
|
||||
<addaction name="actionSearch"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Music">
|
||||
<property name="title">
|
||||
@ -1032,6 +1036,14 @@ border: 1px solid rgb(85, 87, 83);</string>
|
||||
<string>Download CSV of played tracks...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSearch">
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>/</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="icons.qrc"/>
|
||||
|
||||
@ -448,6 +448,8 @@ class Ui_MainWindow(object):
|
||||
self.actionImport.setObjectName("actionImport")
|
||||
self.actionDownload_CSV_of_played_tracks = QtWidgets.QAction(MainWindow)
|
||||
self.actionDownload_CSV_of_played_tracks.setObjectName("actionDownload_CSV_of_played_tracks")
|
||||
self.actionSearch = QtWidgets.QAction(MainWindow)
|
||||
self.actionSearch.setObjectName("actionSearch")
|
||||
self.menuFile.addAction(self.actionImport)
|
||||
self.menuFile.addSeparator()
|
||||
self.menuFile.addAction(self.actionE_xit)
|
||||
@ -472,6 +474,10 @@ class Ui_MainWindow(object):
|
||||
self.menuPlaylist.addSeparator()
|
||||
self.menuPlaylist.addAction(self.actionDownload_CSV_of_played_tracks)
|
||||
self.menuPlaylist.addAction(self.actionExport_playlist)
|
||||
self.menuPlaylist.addSeparator()
|
||||
self.menuPlaylist.addAction(self.actionSelect_next_track)
|
||||
self.menuPlaylist.addAction(self.actionSelect_previous_track)
|
||||
self.menuPlaylist.addAction(self.actionSearch)
|
||||
self.menu_Music.addAction(self.actionPlay_next)
|
||||
self.menu_Music.addAction(self.actionSkip_next)
|
||||
self.menu_Music.addAction(self.actionFade)
|
||||
@ -560,4 +566,6 @@ class Ui_MainWindow(object):
|
||||
self.actionImport.setText(_translate("MainWindow", "Import..."))
|
||||
self.actionImport.setShortcut(_translate("MainWindow", "Ctrl+Shift+I"))
|
||||
self.actionDownload_CSV_of_played_tracks.setText(_translate("MainWindow", "Download CSV of played tracks..."))
|
||||
self.actionSearch.setText(_translate("MainWindow", "Search"))
|
||||
self.actionSearch.setShortcut(_translate("MainWindow", "/"))
|
||||
import icons_rc
|
||||
|
||||
Loading…
Reference in New Issue
Block a user