From f27baeb6834a85285ce7b13c81f8609d3e6504e2 Mon Sep 17 00:00:00 2001 From: darklithium Date: Wed, 3 Jun 2026 01:33:31 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Multiple=20UI=20improvements=20und=20Bug?= =?UTF-8?q?fixes=20-=20Musik-Button:=20Gr=C3=B6=C3=9Fe=20von=2010GU=20auf?= =?UTF-8?q?=2014GU=20erh=C3=B6ht=20-=20Lautst=C3=A4rke:=20Sofortige=20?= =?UTF-8?q?=C3=84nderung=20durch=20root.setMusicVolume/root.setCrackVolume?= =?UTF-8?q?=20-=20Listenauswahl:=20Beschreibungen=20mit=20Spr=C3=BCchezahl?= =?UTF-8?q?=20hinzugef=C3=BCgt=20(fortune=20-=20Gl=C3=BCckskeks-Spr=C3=BCc?= =?UTF-8?q?he=20(139))=20-=20Listenwechsel:=20Sofortige=20Aktualisierung?= =?UTF-8?q?=20des=20Fortune-Textes=20via=20root.reloadFortune()=20-=20?= =?UTF-8?q?=C3=9Cberschrift:=20Spacer=20unter=20Header=20f=C3=BCr=20besser?= =?UTF-8?q?e=20Sichtbarkeit=20-=20Listenauswahl:=20Korrekte=20Auswahl=20tr?= =?UTF-8?q?otz=20formatierter=20Anzeige?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- qml/Main.qml | 38 +++++++++++++++++++++++++++++++------- qml/Settings.qml | 44 ++++++++++++++++++++++++++++++++++++-------- src/fortunecookie.py | 16 ++++++++++++++++ 3 files changed, 83 insertions(+), 15 deletions(-) diff --git a/qml/Main.qml b/qml/Main.qml index 03ee073..d3e993c 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -31,17 +31,41 @@ MainView { } } + property real musicVolume: 0.5 + property real crackVolume: 1.0 + + // Funktionen zum Setzen der Lautstärke + function setMusicVolume(volume) { + root.musicVolume = volume; + py.call("fortunecookie.set_music_volume", [volume]); + } + + function setCrackVolume(volume) { + root.crackVolume = volume; + py.call("fortunecookie.set_crack_volume", [volume]); + } + + function reloadFortune() { + currentFortune = py.call_sync("fortunecookie.get_current_fortune", []); + currentFortuneLabel.text = currentFortune; + if (fortuneOpened) { + currentFortuneLabel.visible = true; + } + } + MediaPlayer { id: mediaPlayer + objectName: "mediaPlayer" source: Qt.resolvedUrl("../assets/chinese_music.mp3") loops: MediaPlayer.Infinite - volume: 0.5 + volume: root.musicVolume } MediaPlayer { id: crackMediaPlayer + objectName: "crackMediaPlayer" source: Qt.resolvedUrl("../assets/cookie_crack.mp3") - volume: 1.0 + volume: root.crackVolume } // ==================================================================== @@ -95,11 +119,11 @@ MainView { mediaPlayer.play(); } - // Volumes laden und setzen + // Volumes laden und Properties setzen var musicVol = py.call_sync("fortunecookie.get_music_volume", []); var crackVol = py.call_sync("fortunecookie.get_crack_volume", []); - mediaPlayer.volume = musicVol; - crackMediaPlayer.volume = crackVol; + root.musicVolume = musicVol; + root.crackVolume = crackVol; appInitialized = true; @@ -201,8 +225,8 @@ MainView { bottom: parent.bottom margins: units.gu(2) } - width: units.gu(10) - height: units.gu(10) + width: units.gu(14) + height: units.gu(14) text: musicPlaying ? "\uD83D\uDD0A" : "\uD83D\uDD07" fontSize: "xx-large" horizontalAlignment: Text.AlignHCenter diff --git a/qml/Settings.qml b/qml/Settings.qml index 7efce8e..b89fd7e 100644 --- a/qml/Settings.qml +++ b/qml/Settings.qml @@ -36,13 +36,15 @@ Page { musicVolumeSlider.value = musicVolume; crackVolumeSlider.value = crackVolume; - // Spruchlisten ComboBox füllen - var lists = py.call_sync("fortunecookie.get_fortune_lists", []); + // Spruchlisten ComboBox füllen (mit Beschreibungen und Anzahl) + var lists = py.call_sync("fortunecookie.get_fortune_lists_with_description", []); fortuneListCombo.model = lists; - // Aktuelle Liste auswählen + // Aktuelle Liste auswählen (vergleiche nur den Listennamen, nicht die Beschreibung) for (var i = 0; i < fortuneListCombo.count; i++) { - if (fortuneListCombo.textAt(i) === currentFortuneList) { + var text = fortuneListCombo.textAt(i); + var listName = text.split(" - ")[0]; + if (listName === currentFortuneList) { fortuneListCombo.currentIndex = i; break; } @@ -56,15 +58,38 @@ Page { } } + // SPRUCHLISTEN-AUSWAHL + // ============================================================ + + Label { + text: "Spruchliste:" + Layout.fillWidth: true + fontSize: "large" + } +======= ColumnLayout { anchors.fill: parent anchors.margins: units.gu(2) spacing: units.gu(2) + // Spacer für Header + Item { + Layout.fillWidth: true + Layout.preferredHeight: units.gu(2) + } + // ============================================================ // SPRUCHLISTEN-AUSWAHL // ============================================================ + Label { + text: "Spruchliste:" + Layout.fillWidth: true + fontSize: "large" + }============================================================ + // SPRUCHLISTEN-AUSWAHL + // ============================================================ + Label { text: "Spruchliste:" Layout.fillWidth: true @@ -77,9 +102,12 @@ Page { Layout.preferredHeight: units.gu(8) onActivated: { - var newList = fortuneListCombo.currentText; + var newListFull = fortuneListCombo.currentText; + // Extrahiere den Listennamen (Teil vor " - ") + var newList = newListFull.split(" - ")[0]; py.call("fortunecookie.set_fortune_list", [newList], function() { - console.log("Spruchliste gewaehlt: " + newList); + console.log("Spruchliste gewählt: " + newList); + root.reloadFortune(); }); } } @@ -108,7 +136,7 @@ Page { onValueChanged: { var volume = musicVolumeSlider.value; - py.call("fortunecookie.set_music_volume", [volume]); + root.setMusicVolume(volume); musicVolumeLabel.text = Math.round(volume * 100) + "%"; } } @@ -146,7 +174,7 @@ Page { onValueChanged: { var volume = crackVolumeSlider.value; - py.call("fortunecookie.set_crack_volume", [volume]); + root.setCrackVolume(volume); crackVolumeLabel.text = Math.round(volume * 100) + "%"; } } diff --git a/src/fortunecookie.py b/src/fortunecookie.py index 244317f..c05e0d1 100644 --- a/src/fortunecookie.py +++ b/src/fortunecookie.py @@ -260,6 +260,22 @@ def get_fortune_lists(): return AVAILABLE_FORTUNE_LISTS +def get_fortune_lists_with_description(): + """Gibt die Liste mit Beschreibungen und Anzahl zurück.""" + _init() + result = [] + descriptions = { + "fortune": "Glückskeks-Sprüche", + "farmer wisdom": "Bauernweisheiten", + "UNfortune": "Darkside-Sprüche" + } + for list_name in AVAILABLE_FORTUNE_LISTS: + count = len(_fortunes.get(list_name, [])) + desc = descriptions.get(list_name, list_name) + result.append(f"{list_name} - {desc} ({count})") + return result + + def get_current_fortune_list(): """Gibt den Namen der aktuellen Spruchliste zurück.""" _init()