Rebase dev onto v2_id
This commit is contained in:
parent
cf58932fca
commit
281a1d40bf
@ -5,6 +5,7 @@ import os
|
|||||||
class Config(object):
|
class Config(object):
|
||||||
AUDACITY_COMMAND = "/usr/bin/audacity"
|
AUDACITY_COMMAND = "/usr/bin/audacity"
|
||||||
AUDIO_SEGMENT_CHUNK_SIZE = 10
|
AUDIO_SEGMENT_CHUNK_SIZE = 10
|
||||||
|
CHECK_AUDACITY_AT_STARTUP = True
|
||||||
COLOUR_CURRENT_HEADER = "#d4edda"
|
COLOUR_CURRENT_HEADER = "#d4edda"
|
||||||
COLOUR_CURRENT_PLAYLIST = "#7eca8f"
|
COLOUR_CURRENT_PLAYLIST = "#7eca8f"
|
||||||
COLOUR_CURRENT_TAB = "#248f24"
|
COLOUR_CURRENT_TAB = "#248f24"
|
||||||
@ -50,6 +51,7 @@ class Config(object):
|
|||||||
MILLISECOND_SIGFIGS = 0
|
MILLISECOND_SIGFIGS = 0
|
||||||
MYSQL_CONNECT = os.environ.get('MYSQL_CONNECT') or "mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_v2" # noqa E501
|
MYSQL_CONNECT = os.environ.get('MYSQL_CONNECT') or "mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_v2" # noqa E501
|
||||||
NORMALISE_ON_IMPORT = True
|
NORMALISE_ON_IMPORT = True
|
||||||
|
NOTE_TIME_FORMAT = "%H:%M:%S"
|
||||||
ROOT = os.environ.get('ROOT') or "/home/kae/music"
|
ROOT = os.environ.get('ROOT') or "/home/kae/music"
|
||||||
TESTMODE = True
|
TESTMODE = True
|
||||||
TIMER_MS = 500
|
TIMER_MS = 500
|
||||||
|
|||||||
@ -160,6 +160,10 @@ def open_in_audacity(path):
|
|||||||
if "audacity" not in [i.name() for i in psutil.process_iter()]:
|
if "audacity" not in [i.name() for i in psutil.process_iter()]:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# Return if path not given
|
||||||
|
if not path:
|
||||||
|
return False
|
||||||
|
|
||||||
to_pipe = '/tmp/audacity_script_pipe.to.' + str(os.getuid())
|
to_pipe = '/tmp/audacity_script_pipe.to.' + str(os.getuid())
|
||||||
from_pipe = '/tmp/audacity_script_pipe.from.' + str(os.getuid())
|
from_pipe = '/tmp/audacity_script_pipe.from.' + str(os.getuid())
|
||||||
EOL = '\n'
|
EOL = '\n'
|
||||||
|
|||||||
@ -6,8 +6,6 @@ import re
|
|||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from mutagen.flac import FLAC
|
|
||||||
from mutagen.mp3 import MP3
|
|
||||||
from sqlalchemy.ext.associationproxy import association_proxy
|
from sqlalchemy.ext.associationproxy import association_proxy
|
||||||
from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta
|
from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta
|
||||||
from sqlalchemy import (
|
from sqlalchemy import (
|
||||||
@ -30,7 +28,6 @@ from helpers import (
|
|||||||
fade_point,
|
fade_point,
|
||||||
get_audio_segment,
|
get_audio_segment,
|
||||||
leading_silence,
|
leading_silence,
|
||||||
show_warning,
|
|
||||||
trailing_silence,
|
trailing_silence,
|
||||||
)
|
)
|
||||||
from log import DEBUG, ERROR
|
from log import DEBUG, ERROR
|
||||||
|
|||||||
@ -36,23 +36,6 @@ from ui.dlg_SelectPlaylist_ui import Ui_dlgSelectPlaylist
|
|||||||
from ui.main_window_ui import Ui_MainWindow
|
from ui.main_window_ui import Ui_MainWindow
|
||||||
|
|
||||||
|
|
||||||
class ElideLabel(QLabel):
|
|
||||||
"""
|
|
||||||
From https://stackoverflow.com/questions/11446478/
|
|
||||||
pyside-pyqt-truncate-text-in-qlabel-based-on-minimumsize
|
|
||||||
"""
|
|
||||||
|
|
||||||
def paintEvent(self, event):
|
|
||||||
#TODO: V2 check
|
|
||||||
painter = QPainter(self)
|
|
||||||
|
|
||||||
metrics = QFontMetrics(self.font())
|
|
||||||
elided = metrics.elidedText(self.text(), Qt.ElideRight, self.width())
|
|
||||||
|
|
||||||
painter.drawText(self.rect(), self.alignment(), elided)
|
|
||||||
#TODO: V2 check
|
|
||||||
|
|
||||||
|
|
||||||
class Window(QMainWindow, Ui_MainWindow):
|
class Window(QMainWindow, Ui_MainWindow):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
#TODO: V2 check
|
#TODO: V2 check
|
||||||
@ -120,8 +103,10 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.setGeometry(x, y, width, height)
|
self.setGeometry(x, y, width, height)
|
||||||
|
|
||||||
def check_audacity(self):
|
def check_audacity(self):
|
||||||
#TODO: V2 check
|
"""Offer to run Audacity if not running"""
|
||||||
"Offer to run Audacity if not running"
|
|
||||||
|
if not Config.CHECK_AUDACITY_AT_STARTUP:
|
||||||
|
return
|
||||||
|
|
||||||
if "audacity" in [i.name() for i in psutil.process_iter()]:
|
if "audacity" in [i.name() for i in psutil.process_iter()]:
|
||||||
return
|
return
|
||||||
@ -427,15 +412,16 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
for playlist_db in Playlists.get_open(session):
|
for playlist_db in Playlists.get_open(session):
|
||||||
self.create_playlist_tab(session, playlist_db)
|
self.create_playlist_tab(session, playlist_db)
|
||||||
|
|
||||||
def create_playlist_tab(self, session, playlist_db):
|
def create_playlist_tab(self, session, playlist):
|
||||||
#TODO: V2 check
|
#TODO: V2 check
|
||||||
"""
|
"""
|
||||||
Take the passed database object, create a playlist tab and add tab
|
Take the passed playlist database object, create a playlist tab and
|
||||||
to display.
|
add tab to display.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
playlist_tab = PlaylistTab(self, session, playlist_db)
|
playlist_tab = PlaylistTab(parent=self,
|
||||||
idx = self.tabPlaylist.addTab(playlist_tab, playlist_db.name)
|
session=session, playlist=playlist)
|
||||||
|
idx = self.tabPlaylist.addTab(playlist_tab, playlist.name)
|
||||||
self.tabPlaylist.setCurrentIndex(idx)
|
self.tabPlaylist.setCurrentIndex(idx)
|
||||||
|
|
||||||
def move_selected(self):
|
def move_selected(self):
|
||||||
@ -466,11 +452,10 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
break
|
break
|
||||||
|
|
||||||
rows = []
|
rows = []
|
||||||
for (row, track_id) in (
|
for (row, track) in (
|
||||||
self.visible_playlist_tab().get_selected_rows_and_tracks()
|
self.visible_playlist_tab().get_selected_rows_and_tracks()
|
||||||
):
|
):
|
||||||
rows.append(row)
|
rows.append(row)
|
||||||
track = Tracks.get_by_id(session, track_id)
|
|
||||||
if destination_visible_playlist_tab:
|
if destination_visible_playlist_tab:
|
||||||
# Insert with repaint=False to not update database
|
# Insert with repaint=False to not update database
|
||||||
destination_visible_playlist_tab.insert_track(
|
destination_visible_playlist_tab.insert_track(
|
||||||
@ -538,7 +523,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
# no automatic next track, and may later be overriden by
|
# no automatic next track, and may later be overriden by
|
||||||
# user selecting a different track on this or another
|
# user selecting a different track on this or another
|
||||||
# playlist.
|
# playlist.
|
||||||
next_track_id = self.current_track_playlist_tab.play_started()
|
***KAE won't return next_track_id *** = self.current_track_playlist_tab.play_started()
|
||||||
|
|
||||||
if next_track_id is not None:
|
if next_track_id is not None:
|
||||||
self.next_track = Tracks.get_by_id(session, next_track_id)
|
self.next_track = Tracks.get_by_id(session, next_track_id)
|
||||||
@ -1019,6 +1004,5 @@ def main():
|
|||||||
EXCEPTION("Unhandled Exception caught by musicmuster.main()")
|
EXCEPTION("Unhandled Exception caught by musicmuster.main()")
|
||||||
|
|
||||||
|
|
||||||
print(f"{__name__=}")
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
814
app/playlists.py
814
app/playlists.py
File diff suppressed because it is too large
Load Diff
@ -175,7 +175,7 @@ border: 1px solid rgb(85, 87, 83);</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="ElideLabel" name="hdrNextTrack">
|
<widget class="QLabel" name="hdrNextTrack">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>0</width>
|
||||||
@ -1014,13 +1014,6 @@ border: 1px solid rgb(85, 87, 83);</string>
|
|||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>ElideLabel</class>
|
|
||||||
<extends>QLabel</extends>
|
|
||||||
<header>musicmuster</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources>
|
<resources>
|
||||||
<include location="icons.qrc"/>
|
<include location="icons.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'ui/main_window.ui'
|
# Form implementation generated from reading ui file 'ui/main_window.ui'
|
||||||
#
|
#
|
||||||
# Created by: PyQt5 UI code generator 5.15.4
|
# Created by: PyQt5 UI code generator 5.15.6
|
||||||
#
|
#
|
||||||
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
||||||
# run again. Do not edit this file unless you know what you are doing.
|
# run again. Do not edit this file unless you know what you are doing.
|
||||||
@ -99,7 +99,7 @@ class Ui_MainWindow(object):
|
|||||||
self.hdrCurrentTrack.setWordWrap(True)
|
self.hdrCurrentTrack.setWordWrap(True)
|
||||||
self.hdrCurrentTrack.setObjectName("hdrCurrentTrack")
|
self.hdrCurrentTrack.setObjectName("hdrCurrentTrack")
|
||||||
self.verticalLayout.addWidget(self.hdrCurrentTrack)
|
self.verticalLayout.addWidget(self.hdrCurrentTrack)
|
||||||
self.hdrNextTrack = ElideLabel(self.centralwidget)
|
self.hdrNextTrack = QtWidgets.QLabel(self.centralwidget)
|
||||||
self.hdrNextTrack.setMinimumSize(QtCore.QSize(0, 39))
|
self.hdrNextTrack.setMinimumSize(QtCore.QSize(0, 39))
|
||||||
self.hdrNextTrack.setMaximumSize(QtCore.QSize(16777215, 39))
|
self.hdrNextTrack.setMaximumSize(QtCore.QSize(16777215, 39))
|
||||||
font = QtGui.QFont()
|
font = QtGui.QFont()
|
||||||
@ -478,7 +478,7 @@ class Ui_MainWindow(object):
|
|||||||
|
|
||||||
self.retranslateUi(MainWindow)
|
self.retranslateUi(MainWindow)
|
||||||
self.tabPlaylist.setCurrentIndex(-1)
|
self.tabPlaylist.setCurrentIndex(-1)
|
||||||
self.actionE_xit.triggered.connect(MainWindow.close)
|
self.actionE_xit.triggered.connect(MainWindow.close) # type: ignore
|
||||||
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||||
|
|
||||||
def retranslateUi(self, MainWindow):
|
def retranslateUi(self, MainWindow):
|
||||||
@ -550,5 +550,4 @@ class Ui_MainWindow(object):
|
|||||||
self.actionSelect_unplayed_tracks.setText(_translate("MainWindow", "Select unplayed tracks"))
|
self.actionSelect_unplayed_tracks.setText(_translate("MainWindow", "Select unplayed tracks"))
|
||||||
self.actionAdd_note.setText(_translate("MainWindow", "Add note..."))
|
self.actionAdd_note.setText(_translate("MainWindow", "Add note..."))
|
||||||
self.actionAdd_note.setShortcut(_translate("MainWindow", "Ctrl+T"))
|
self.actionAdd_note.setShortcut(_translate("MainWindow", "Ctrl+T"))
|
||||||
from musicmuster import ElideLabel
|
|
||||||
import icons_rc
|
import icons_rc
|
||||||
|
|||||||
16
app/ui_helpers.py
Normal file
16
app/ui_helpers.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from PyQt5.QtCore import Qt
|
||||||
|
from PyQt5.QtGui import QFontMetrics, QPainter
|
||||||
|
|
||||||
|
|
||||||
|
class ElideLabel(QLabel):
|
||||||
|
"""
|
||||||
|
From https://stackoverflow.com/questions/11446478/
|
||||||
|
pyside-pyqt-truncate-text-in-qlabel-based-on-minimumsize
|
||||||
|
"""
|
||||||
|
|
||||||
|
def paintEvent(self, event):
|
||||||
|
painter = QPainter(self)
|
||||||
|
metrics = QFontMetrics(self.font())
|
||||||
|
elided = metrics.elidedText(self.text(), Qt.ElideRight, self.width())
|
||||||
|
|
||||||
|
painter.drawText(self.rect(), self.alignment(), elided)
|
||||||
@ -1,4 +1,4 @@
|
|||||||
from app.playlists import PlaylistTab
|
from app.playlists import Notes, PlaylistTab, Tracks
|
||||||
from app.models import Playlists
|
from app.models import Playlists
|
||||||
|
|
||||||
|
|
||||||
@ -8,3 +8,32 @@ def test_init(qtbot, session):
|
|||||||
playlist = Playlists(session, "my playlist")
|
playlist = Playlists(session, "my playlist")
|
||||||
playlist_tab = PlaylistTab(None, session, playlist)
|
playlist_tab = PlaylistTab(None, session, playlist)
|
||||||
assert playlist_tab
|
assert playlist_tab
|
||||||
|
|
||||||
|
|
||||||
|
def test_save_and_restore(qtbot, session):
|
||||||
|
"""Playlist with one track, one note, save and restore"""
|
||||||
|
|
||||||
|
# Create playlist
|
||||||
|
playlist = Playlists(session, "my playlist")
|
||||||
|
playlist_tab = PlaylistTab(None, session, playlist)
|
||||||
|
|
||||||
|
# Insert a note
|
||||||
|
note_text = "my note"
|
||||||
|
note_row = 7
|
||||||
|
note = Notes(session, playlist.id, note_row, note_text)
|
||||||
|
playlist_tab._insert_note(session, note)
|
||||||
|
|
||||||
|
# Add a track
|
||||||
|
track_path = "/a/b/c"
|
||||||
|
track = Tracks(session, track_path)
|
||||||
|
playlist_tab._insert_track(session, track)
|
||||||
|
|
||||||
|
# Save playlist
|
||||||
|
playlist_tab.save_playlist(session)
|
||||||
|
|
||||||
|
# Retrieve playlist
|
||||||
|
playlists = Playlists.get_open(session)
|
||||||
|
assert len(playlists) == 1
|
||||||
|
retrieved_playlist = playlists[0]
|
||||||
|
assert track_path in [a.path for a in retrieved_playlist.tracks.values()]
|
||||||
|
assert note_text in [a.note for a in retrieved_playlist.notes]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user