Bedre sync

This commit is contained in:
2026-04-13 14:22:27 +02:00
parent e86173f7ec
commit cb204baa50
7 changed files with 53 additions and 12 deletions

View File

@@ -466,8 +466,8 @@ class MainWindow(QMainWindow):
SELECT s.id, s.title, s.artist, s.album, s.bpm,
s.duration_sec, s.local_path, s.file_format,
s.file_missing,
GROUP_CONCAT(DISTINCT d.name) AS dance_names,
GROUP_CONCAT(DISTINCT COALESCE(dl.name,'')) AS dance_levels,
GROUP_CONCAT(d.name, ',') AS dance_names,
GROUP_CONCAT(COALESCE(dl.name,''), ',') AS dance_levels,
GROUP_CONCAT(DISTINCT ad.name) AS alt_dance_names
FROM songs s
LEFT JOIN song_dances sd ON sd.song_id = s.id

View File

@@ -41,7 +41,10 @@ class PlaylistInfoWindow(QWidget):
playlist_panel.playlist_changed.connect(self._update)
playlist_panel.status_changed.connect(lambda *_: self._update())
def _build_ui(self):
def moveEvent(self, event):
from PyQt6.QtCore import QSettings
QSettings("LineDance", "Player").setValue("window/info_pos", self.pos())
super().moveEvent(event)
layout = QVBoxLayout(self)
layout.setContentsMargins(12, 12, 12, 12)
layout.setSpacing(8)

View File

@@ -668,12 +668,26 @@ class PlaylistPanel(QWidget):
from ui.playlist_info_dialog import PlaylistInfoWindow
from PyQt6.QtWidgets import QApplication
from PyQt6.QtCore import QSettings
main = self.window()
self._info_window = PlaylistInfoWindow(self, parent=main)
QApplication.instance().aboutToQuit.connect(self._info_window.close)
if main:
# Gendan gemt position eller placer ved siden af hovedvindue
s = QSettings("LineDance", "Player")
pos = s.value("window/info_pos")
if pos:
self._info_window.move(pos)
elif main:
geo = main.geometry()
self._info_window.move(geo.right() + 10, geo.top() + 100)
self._info_window.move(geo.right() + 10, geo.top())
# Sikr at vinduet er på skærmen
screen = QApplication.primaryScreen().availableGeometry()
w_geo = self._info_window.frameGeometry()
x = max(0, min(w_geo.x(), screen.right() - w_geo.width()))
y = max(0, min(w_geo.y(), screen.bottom() - w_geo.height()))
self._info_window.move(x, y)
self._info_window.show()
def _change_dance(self, idx: int, song: dict):

View File

@@ -437,9 +437,14 @@ class TagEditorDialog(QDialog):
# Skriv danse-navne til filen
if local_path and can_write_dances(local_path):
dance_names = [d["name"] for d in dances]
if not write_dances(local_path, dance_names):
try:
if not write_dances(local_path, dance_names):
QMessageBox.warning(self, "Advarsel",
"Gemt i database, men kunne ikke skrive til mp3-filen.\n"
"(Filen understøtter ikke dans-tags)")
except Exception as write_err:
QMessageBox.warning(self, "Advarsel",
"Gemt i database, men kunne ikke skrive til filen.")
f"Gemt i database, men fejl ved skrivning til fil:\n{write_err}")
self.accept()