Implement test menu and functions

This commit is contained in:
Keith Edmunds 2021-04-10 13:54:04 +01:00
parent 0a09be839d
commit 00ebcb09ea
4 changed files with 65 additions and 3 deletions

View File

@ -92,3 +92,8 @@ class Music:
return self.player.is_playing()
else:
return False
def set_position(self, ms):
"Set current play time in milliseconds from start"
return self.player.set_time(ms)

View File

@ -4,7 +4,7 @@ import sys
from datetime import datetime, timedelta
from log import EXCEPTION
from log import DEBUG, EXCEPTION
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import (
@ -33,6 +33,8 @@ class Window(QMainWindow, Ui_MainWindow):
self.connect_signals_slots()
self.disable_play_next_controls()
self.menuTest.menuAction().setVisible(Config.TESTMODE)
record = Settings.get_int("mainwindow_x")
x = record.f_int or 1
record = Settings.get_int("mainwindow_y")
@ -89,9 +91,11 @@ class Window(QMainWindow, Ui_MainWindow):
"Don't allow window to close when a track is playing"
if self.playlist.music.playing():
DEBUG("closeEvent() ignored as music is playing")
event.ignore()
# TODO notify user
else:
DEBUG("closeEvent() accepted")
event.accept()
def connect_signals_slots(self):
@ -104,6 +108,9 @@ class Window(QMainWindow, Ui_MainWindow):
self.actionSearch_database.triggered.connect(self.search_database)
self.actionSelectPlaylist.triggered.connect(self.select_playlist)
self.actionSkip_next.triggered.connect(self.play_next)
self.actionSkipToEnd.triggered.connect(self.test_skip_to_end)
self.actionSkipToFade.triggered.connect(self.test_skip_to_fade)
self.actionTestFunction.triggered.connect(self.test_function)
self.btnAddFile.clicked.connect(self.add_file)
self.btnInsertNote.clicked.connect(self.insert_note)
self.btnPrevious.clicked.connect(self.play_previous)
@ -175,6 +182,31 @@ class Window(QMainWindow, Ui_MainWindow):
self.playlist.set_selected_as_next()
self.update_headers()
def test_function(self):
"Placeholder for test function"
pass
def test_skip_to_end(self):
"Skip current track to 1 second before silence"
if not self.playlist.music.playing():
return
self.playlist.music.set_position(
self.playlist.get_current_silence_at() - 1000
)
def test_skip_to_fade(self):
"Skip current track to 1 second before fade"
if not self.playlist.music.playing():
return
self.playlist.music.set_position(
self.playlist.get_current_fade_at() - 1000
)
def tick(self):
"""
Update screen

View File

@ -600,10 +600,10 @@ class Playlist(QTableWidget):
)
try:
running_end_time = datetime.strptime(self.item(
row, self.COL_ENDTIME).text(), "%H:%M:%S")
current, self.COL_ENDTIME).text(), "%H:%M:%S")
except AttributeError:
pass
self.set_row_bold(row)
self.set_row_bold(current)
for row in range(self.rowCount()):
if row == next:

View File

@ -741,9 +741,19 @@ border: 1px solid rgb(85, 87, 83);</string>
<addaction name="actionS_top"/>
<addaction name="action_Resume_previous"/>
</widget>
<widget class="QMenu" name="menuTest">
<property name="title">
<string>TestMode</string>
</property>
<addaction name="actionTestFunction"/>
<addaction name="separator"/>
<addaction name="actionSkipToFade"/>
<addaction name="actionSkipToEnd"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuPlaylist"/>
<addaction name="menu_Tracks"/>
<addaction name="menuTest"/>
</widget>
<widget class="QStatusBar" name="statusbar">
<property name="enabled">
@ -853,6 +863,21 @@ border: 1px solid rgb(85, 87, 83);</string>
<string>&amp;New playlist</string>
</property>
</action>
<action name="actionTestFunction">
<property name="text">
<string>Test function</string>
</property>
</action>
<action name="actionSkipToFade">
<property name="text">
<string>Skip to start of fade</string>
</property>
</action>
<action name="actionSkipToEnd">
<property name="text">
<string>Skip to end of track</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>