En del opdateringer

This commit is contained in:
2026-04-19 00:58:48 +02:00
parent efe3739626
commit e4ab9caab6
14 changed files with 3412 additions and 189 deletions

View File

@@ -162,6 +162,15 @@ class MainWindow(QMainWindow):
act_quit.triggered.connect(self.close)
file_menu.addAction(act_quit)
# ── Danse ─────────────────────────────────────────────────────────────
dance_menu = menubar.addMenu("Danse")
act_new_dance = QAction("Opret dans...", self)
act_new_dance.setShortcut("Ctrl+D")
act_new_dance.setToolTip("Opret en dans i databasen uden at knytte den til musik")
act_new_dance.triggered.connect(self._create_dance_dialog)
dance_menu.addAction(act_new_dance)
# ── Ingen Danseliste- eller Visning-menu ──────────────────────────────
# Ny/Gem/Hent ligger direkte i danseliste-panelet
# Tema-skift ligger i topbar-knappen
@@ -178,6 +187,16 @@ class MainWindow(QMainWindow):
self.setStatusBar(self._statusbar)
self._statusbar.showMessage("Klar")
# Versionsnummer permanent til højre
try:
from main import APP_VERSION
except Exception:
APP_VERSION = "0.8.1"
version_lbl = QLabel(f"v{APP_VERSION}")
version_lbl.setObjectName("result_count")
version_lbl.setContentsMargins(0, 0, 8, 0)
self._statusbar.addPermanentWidget(version_lbl)
def _set_status(self, text: str, timeout_ms: int = 0):
"""Vis besked i statuslinjen. timeout_ms=0 = permanent."""
self._statusbar.showMessage(text, timeout_ms)
@@ -481,9 +500,10 @@ 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(d.name, ',') AS dance_names,
GROUP_CONCAT(COALESCE(dl.name,''), ',') AS dance_levels,
GROUP_CONCAT(DISTINCT ad.name) AS alt_dance_names
GROUP_CONCAT(d.name, ',') AS dance_names,
GROUP_CONCAT(COALESCE(dl.name,''), ',') AS dance_levels,
GROUP_CONCAT(COALESCE(d.choreographer,''), ',') AS dance_choreographers,
GROUP_CONCAT(DISTINCT ad.name) AS alt_dance_names
FROM songs s
LEFT JOIN song_dances sd ON sd.song_id = s.id
LEFT JOIN dances d ON d.id = sd.dance_id
@@ -498,22 +518,24 @@ class MainWindow(QMainWindow):
songs = []
for row in rows:
dances = row["dance_names"].split(",") if row["dance_names"] else []
levels = row["dance_levels"].split(",") if row["dance_levels"] else []
alt_dances = row["alt_dance_names"].split(",") if row["alt_dance_names"] else []
dances = row["dance_names"].split(",") if row["dance_names"] else []
levels = row["dance_levels"].split(",") if row["dance_levels"] else []
choreos = row["dance_choreographers"].split(",") if row["dance_choreographers"] else []
alt_dances = row["alt_dance_names"].split(",") if row["alt_dance_names"] else []
songs.append({
"id": row["id"],
"title": row["title"],
"artist": row["artist"],
"album": row["album"],
"bpm": row["bpm"],
"duration_sec": row["duration_sec"],
"local_path": row["local_path"],
"file_format": row["file_format"],
"file_missing": bool(row["file_missing"]),
"dances": dances,
"dance_levels": levels,
"alt_dances": alt_dances,
"id": row["id"],
"title": row["title"],
"artist": row["artist"],
"album": row["album"],
"bpm": row["bpm"],
"duration_sec": row["duration_sec"],
"local_path": row["local_path"],
"file_format": row["file_format"],
"file_missing": bool(row["file_missing"]),
"dances": dances,
"dance_levels": levels,
"dance_choreographers": choreos,
"alt_dances": alt_dances,
})
self._library_loaded.emit(songs)
except Exception:
@@ -652,6 +674,66 @@ class MainWindow(QMainWindow):
except Exception as e:
self._set_status(f"Fejl ved tilføjelse: {e}")
def _create_dance_dialog(self):
"""Opret en dans i databasen — fritliggende, uden tilknytning til musik."""
from PyQt6.QtWidgets import (
QDialog, QVBoxLayout, QFormLayout, QLineEdit,
QComboBox, QDialogButtonBox, QMessageBox
)
try:
from local.local_db import get_dance_levels, get_or_create_dance
except Exception as e:
QMessageBox.warning(self, "Fejl", str(e))
return
levels = [dict(r) for r in get_dance_levels()]
dlg = QDialog(self)
dlg.setWindowTitle("Opret dans")
dlg.setFixedWidth(380)
layout = QVBoxLayout(dlg)
layout.setSpacing(8)
layout.setContentsMargins(14, 14, 14, 14)
form = QFormLayout()
form.setSpacing(8)
name_edit = QLineEdit()
name_edit.setPlaceholderText("f.eks. Cowboy Cha Cha")
form.addRow("Dans-navn:", name_edit)
level_cb = QComboBox()
level_cb.addItem("— intet niveau —", None)
for lvl in levels:
level_cb.addItem(lvl["name"], lvl["id"])
form.addRow("Niveau:", level_cb)
choreo_edit = QLineEdit()
choreo_edit.setPlaceholderText("Koreografens navn (valgfri)")
form.addRow("Koreograf:", choreo_edit)
layout.addLayout(form)
btns = QDialogButtonBox(
QDialogButtonBox.StandardButton.Ok |
QDialogButtonBox.StandardButton.Cancel
)
btns.accepted.connect(dlg.accept)
btns.rejected.connect(dlg.reject)
layout.addWidget(btns)
name_edit.setFocus()
if dlg.exec():
name = name_edit.text().strip()
choreo = choreo_edit.text().strip()
level = level_cb.currentData()
if name:
try:
get_or_create_dance(name, level, choreographer=choreo)
self._set_status(f'Dans "{name}" oprettet', 3000)
except Exception as e:
QMessageBox.warning(self, "Fejl", f"Kunne ikke oprette dans:\n{e}")
def _open_settings(self):
dialog = SettingsDialog(parent=self)
if dialog.exec():