fix: Multiple UI improvements und Bugfixes

- Musik-Button: Größe von 10GU auf 14GU erhöht
- Lautstärke: Sofortige Änderung durch root.setMusicVolume/root.setCrackVolume
- Listenauswahl: Beschreibungen mit Sprüchezahl hinzugefügt (fortune - Glückskeks-Sprüche (139))
- Listenwechsel: Sofortige Aktualisierung des Fortune-Textes via root.reloadFortune()
- Überschrift: Spacer unter Header für bessere Sichtbarkeit
- Listenauswahl: Korrekte Auswahl trotz formatierter Anzeige

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
darklithium
2026-06-03 01:33:31 +02:00
parent 61aaad7e42
commit f27baeb683
3 changed files with 83 additions and 15 deletions
+31 -7
View File
@@ -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 { MediaPlayer {
id: mediaPlayer id: mediaPlayer
objectName: "mediaPlayer"
source: Qt.resolvedUrl("../assets/chinese_music.mp3") source: Qt.resolvedUrl("../assets/chinese_music.mp3")
loops: MediaPlayer.Infinite loops: MediaPlayer.Infinite
volume: 0.5 volume: root.musicVolume
} }
MediaPlayer { MediaPlayer {
id: crackMediaPlayer id: crackMediaPlayer
objectName: "crackMediaPlayer"
source: Qt.resolvedUrl("../assets/cookie_crack.mp3") source: Qt.resolvedUrl("../assets/cookie_crack.mp3")
volume: 1.0 volume: root.crackVolume
} }
// ==================================================================== // ====================================================================
@@ -95,11 +119,11 @@ MainView {
mediaPlayer.play(); mediaPlayer.play();
} }
// Volumes laden und setzen // Volumes laden und Properties setzen
var musicVol = py.call_sync("fortunecookie.get_music_volume", []); var musicVol = py.call_sync("fortunecookie.get_music_volume", []);
var crackVol = py.call_sync("fortunecookie.get_crack_volume", []); var crackVol = py.call_sync("fortunecookie.get_crack_volume", []);
mediaPlayer.volume = musicVol; root.musicVolume = musicVol;
crackMediaPlayer.volume = crackVol; root.crackVolume = crackVol;
appInitialized = true; appInitialized = true;
@@ -201,8 +225,8 @@ MainView {
bottom: parent.bottom bottom: parent.bottom
margins: units.gu(2) margins: units.gu(2)
} }
width: units.gu(10) width: units.gu(14)
height: units.gu(10) height: units.gu(14)
text: musicPlaying ? "\uD83D\uDD0A" : "\uD83D\uDD07" text: musicPlaying ? "\uD83D\uDD0A" : "\uD83D\uDD07"
fontSize: "xx-large" fontSize: "xx-large"
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
+36 -8
View File
@@ -36,13 +36,15 @@ Page {
musicVolumeSlider.value = musicVolume; musicVolumeSlider.value = musicVolume;
crackVolumeSlider.value = crackVolume; crackVolumeSlider.value = crackVolume;
// Spruchlisten ComboBox füllen // Spruchlisten ComboBox füllen (mit Beschreibungen und Anzahl)
var lists = py.call_sync("fortunecookie.get_fortune_lists", []); var lists = py.call_sync("fortunecookie.get_fortune_lists_with_description", []);
fortuneListCombo.model = lists; 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++) { 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; fortuneListCombo.currentIndex = i;
break; break;
} }
@@ -56,15 +58,38 @@ Page {
} }
} }
// SPRUCHLISTEN-AUSWAHL
// ============================================================
Label {
text: "Spruchliste:"
Layout.fillWidth: true
fontSize: "large"
}
=======
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
anchors.margins: units.gu(2) anchors.margins: units.gu(2)
spacing: units.gu(2) spacing: units.gu(2)
// Spacer für Header
Item {
Layout.fillWidth: true
Layout.preferredHeight: units.gu(2)
}
// ============================================================ // ============================================================
// SPRUCHLISTEN-AUSWAHL // SPRUCHLISTEN-AUSWAHL
// ============================================================ // ============================================================
Label {
text: "Spruchliste:"
Layout.fillWidth: true
fontSize: "large"
}============================================================
// SPRUCHLISTEN-AUSWAHL
// ============================================================
Label { Label {
text: "Spruchliste:" text: "Spruchliste:"
Layout.fillWidth: true Layout.fillWidth: true
@@ -77,9 +102,12 @@ Page {
Layout.preferredHeight: units.gu(8) Layout.preferredHeight: units.gu(8)
onActivated: { 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() { 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: { onValueChanged: {
var volume = musicVolumeSlider.value; var volume = musicVolumeSlider.value;
py.call("fortunecookie.set_music_volume", [volume]); root.setMusicVolume(volume);
musicVolumeLabel.text = Math.round(volume * 100) + "%"; musicVolumeLabel.text = Math.round(volume * 100) + "%";
} }
} }
@@ -146,7 +174,7 @@ Page {
onValueChanged: { onValueChanged: {
var volume = crackVolumeSlider.value; var volume = crackVolumeSlider.value;
py.call("fortunecookie.set_crack_volume", [volume]); root.setCrackVolume(volume);
crackVolumeLabel.text = Math.round(volume * 100) + "%"; crackVolumeLabel.text = Math.round(volume * 100) + "%";
} }
} }
+16
View File
@@ -260,6 +260,22 @@ def get_fortune_lists():
return AVAILABLE_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(): def get_current_fortune_list():
"""Gibt den Namen der aktuellen Spruchliste zurück.""" """Gibt den Namen der aktuellen Spruchliste zurück."""
_init() _init()