Compare commits
No commits in common. "e4984573956aad3e67939dd91b5d60c38ff48a68" and "e1b9dacd3463dfbad8c562e92be5e52c4e0ed0e2" have entirely different histories.
e498457395
...
e1b9dacd34
@ -20,7 +20,7 @@ class Config(object):
|
||||
ERRORS_TO = ['kae@midnighthax.com']
|
||||
FADE_STEPS = 20
|
||||
FADE_TIME = 3000
|
||||
LOG_LEVEL_STDERR = logging.INFO
|
||||
LOG_LEVEL_STDERR = logging.DEBUG
|
||||
LOG_LEVEL_SYSLOG = logging.DEBUG
|
||||
LOG_NAME = "musicmuster"
|
||||
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
|
||||
|
||||
16
app/log.py
16
app/log.py
@ -59,20 +59,8 @@ def log_uncaught_exceptions(ex_cls, ex, tb):
|
||||
sys.excepthook = log_uncaught_exceptions
|
||||
|
||||
|
||||
def DEBUG(msg, force_stderr=False):
|
||||
"""
|
||||
Outupt a log message at level DEBUG. If force_stderr is True,
|
||||
output this message to stderr regardless of default stderr level
|
||||
setting.
|
||||
"""
|
||||
|
||||
if force_stderr:
|
||||
old_level = stderr.level
|
||||
stderr.setLevel(logging.DEBUG)
|
||||
log.debug(msg)
|
||||
stderr.setLevel(old_level)
|
||||
else:
|
||||
log.debug(msg)
|
||||
def DEBUG(msg):
|
||||
log.debug(msg)
|
||||
|
||||
|
||||
def EXCEPTION(msg):
|
||||
|
||||
@ -402,9 +402,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
pass
|
||||
|
||||
def search_database(self):
|
||||
with Session() as session:
|
||||
dlg = DbDialog(self, session)
|
||||
dlg.exec()
|
||||
dlg = DbDialog(self)
|
||||
dlg.exec()
|
||||
|
||||
def open_playlist(self):
|
||||
with Session() as session:
|
||||
@ -627,9 +626,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
|
||||
|
||||
class DbDialog(QDialog):
|
||||
def __init__(self, parent, session):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.session = session
|
||||
self.ui = Ui_Dialog()
|
||||
self.ui.setupUi(self)
|
||||
self.ui.searchString.textEdited.connect(self.chars_typed)
|
||||
@ -639,20 +637,22 @@ class DbDialog(QDialog):
|
||||
self.ui.btnClose.clicked.connect(self.close)
|
||||
self.ui.matchList.itemSelectionChanged.connect(self.selection_changed)
|
||||
|
||||
record = Settings.get_int(self.session, "dbdialog_width")
|
||||
width = record.f_int or 800
|
||||
record = Settings.get_int(self.session, "dbdialog_height")
|
||||
height = record.f_int or 600
|
||||
self.resize(width, height)
|
||||
with Session() as session:
|
||||
record = Settings.get_int(session, "dbdialog_width")
|
||||
width = record.f_int or 800
|
||||
record = Settings.get_int(session, "dbdialog_height")
|
||||
height = record.f_int or 600
|
||||
self.resize(width, height)
|
||||
|
||||
def __del__(self):
|
||||
record = Settings.get_int(self.session, "dbdialog_height")
|
||||
if record.f_int != self.height():
|
||||
record.update(self.session, {'f_int': self.height()})
|
||||
with Session() as session:
|
||||
record = Settings.get_int(session, "dbdialog_height")
|
||||
if record.f_int != self.height():
|
||||
record.update(session, {'f_int': self.height()})
|
||||
|
||||
record = Settings.get_int(self.session, "dbdialog_width")
|
||||
if record.f_int != self.width():
|
||||
record.update(self.session, {'f_int': self.width()})
|
||||
record = Settings.get_int(session, "dbdialog_width")
|
||||
if record.f_int != self.width():
|
||||
record.update(session, {'f_int': self.width()})
|
||||
|
||||
def add_selected(self):
|
||||
if not self.ui.matchList.selectedItems():
|
||||
@ -660,7 +660,8 @@ class DbDialog(QDialog):
|
||||
|
||||
item = self.ui.matchList.currentItem()
|
||||
track_id = item.data(Qt.UserRole)
|
||||
self.add_track(track_id)
|
||||
with Session() as session:
|
||||
self.add_track(session, track_id)
|
||||
|
||||
def add_selected_and_close(self):
|
||||
self.add_selected()
|
||||
@ -668,27 +669,29 @@ class DbDialog(QDialog):
|
||||
|
||||
def chars_typed(self, s):
|
||||
if len(s) > 0:
|
||||
matches = Tracks.search_titles(self.session, s)
|
||||
self.ui.matchList.clear()
|
||||
if matches:
|
||||
for track in matches:
|
||||
t = QListWidgetItem()
|
||||
t.setText(
|
||||
f"{track.title} - {track.artist} "
|
||||
f"[{helpers.ms_to_mmss(track.duration)}]"
|
||||
)
|
||||
t.setData(Qt.UserRole, track.id)
|
||||
self.ui.matchList.addItem(t)
|
||||
with Session() as session:
|
||||
matches = Tracks.search_titles(session, s)
|
||||
self.ui.matchList.clear()
|
||||
if matches:
|
||||
for track in matches:
|
||||
t = QListWidgetItem()
|
||||
t.setText(
|
||||
f"{track.title} - {track.artist} "
|
||||
f"[{helpers.ms_to_mmss(track.duration)}]"
|
||||
)
|
||||
t.setData(Qt.UserRole, track.id)
|
||||
self.ui.matchList.addItem(t)
|
||||
|
||||
def double_click(self, entry):
|
||||
track_id = entry.data(Qt.UserRole)
|
||||
self.add_track(track_id)
|
||||
with Session() as session:
|
||||
self.add_track(session, track_id)
|
||||
# Select search text to make it easier for next search
|
||||
self.select_searchtext()
|
||||
|
||||
def add_track(self, track_id):
|
||||
track = Tracks.track_from_id(self.session, track_id)
|
||||
self.parent().visible_playlist().add_to_playlist(self.session, track)
|
||||
def add_track(self, session, track_id):
|
||||
track = Tracks.track_from_id(session, track_id)
|
||||
self.parent().visible_playlist().add_to_playlist(session, track)
|
||||
# Select search text to make it easier for next search
|
||||
self.select_searchtext()
|
||||
|
||||
@ -702,7 +705,8 @@ class DbDialog(QDialog):
|
||||
|
||||
item = self.ui.matchList.currentItem()
|
||||
track_id = item.data(Qt.UserRole)
|
||||
self.ui.dbPath.setText(Tracks.get_path(self.session, track_id))
|
||||
with Session() as session:
|
||||
self.ui.dbPath.setText(Tracks.get_path(session, track_id))
|
||||
|
||||
|
||||
class SelectPlaylistDialog(QDialog):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user