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:
+31
-7
@@ -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
|
||||
|
||||
+36
-8
@@ -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) + "%";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user