From ad9305e4223c73567c0f46152f5149fa60acce54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Delobel?= Date: Thu, 27 Mar 2025 08:49:34 +0100 Subject: [PATCH] Master/detail version brutasse --- 2024/idees_tp/flags/Country.qml | 32 ++++++++++++++++++++++++++++ 2024/idees_tp/flags/main.qml | 37 +++++++++++++++++++++------------ 2024/idees_tp/flags/qml.qrc | 1 + 3 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 2024/idees_tp/flags/Country.qml diff --git a/2024/idees_tp/flags/Country.qml b/2024/idees_tp/flags/Country.qml new file mode 100644 index 0000000..365b734 --- /dev/null +++ b/2024/idees_tp/flags/Country.qml @@ -0,0 +1,32 @@ +import QtQuick 2.15 + +Rectangle { + width: lv.width + height: 30 + + required property string name + required property string iso + + + Text { + text: parent.name + font.pixelSize: 20 + anchors.verticalCenter: parent.verticalCenter + } + + Image { + id: flag + source: "qrc:/assets/flags/"+parent.iso+".svg" + height: parent.height - 4 + anchors.right: parent.right + fillMode: Image.PreserveAspectFit + anchors.verticalCenter: parent.verticalCenter + } + MouseArea { + anchors.fill: parent + onClicked: { + choosenText.text = name + choosenFlag.source = flag.source + } + } +} diff --git a/2024/idees_tp/flags/main.qml b/2024/idees_tp/flags/main.qml index 4e15e64..380d7fc 100644 --- a/2024/idees_tp/flags/main.qml +++ b/2024/idees_tp/flags/main.qml @@ -9,24 +9,35 @@ Window { ListView { id: lv - anchors.fill: parent + anchors.left: parent.left + height: parent.height + width: parent.width / 3 model: countries - delegate: Rectangle { - width: lv.width/3 - height: 30 + delegate: Country { - Text { - text: name - font.pixelSize: 20 - anchors.verticalCenter: parent.verticalCenter - } + } + } + + Rectangle { + anchors.right: parent.right + anchors.left: lv.right + height: parent.height + color: "lightgrey" + Column { + width: parent.width Image { - source: "qrc:/assets/flags/"+iso+".svg" - height: parent.height - 4 - anchors.right: parent.right + id: choosenFlag + fillMode: Image.PreserveAspectFit - anchors.verticalCenter: parent.verticalCenter + width: parent.width + } + + Text { + id: choosenText + text: "" + font.pixelSize: 50 + anchors.horizontalCenter: parent.horizontalCenter } } } diff --git a/2024/idees_tp/flags/qml.qrc b/2024/idees_tp/flags/qml.qrc index 99c10ef..2b6dc06 100644 --- a/2024/idees_tp/flags/qml.qrc +++ b/2024/idees_tp/flags/qml.qrc @@ -203,5 +203,6 @@ assets/data_en-GB.xml assets/map.svg assets/map.svg.txt + Country.qml