From a0a4f9e0752d4de7349fa3567b63bf8c985b0b28 Mon Sep 17 00:00:00 2001 From: Alexis Drai Date: Wed, 31 May 2023 11:56:07 +0200 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ez=20votre=20famille=20de=20boutons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml/components/BigButton.qml | 27 +++++++++++++++++++++++++++ qml/pages/FirstPage.qml | 12 +++++++++--- qt2.pro | 1 + translations/qt2-de.ts | 4 ---- translations/qt2.ts | 4 ---- 5 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 qml/components/BigButton.qml diff --git a/qml/components/BigButton.qml b/qml/components/BigButton.qml new file mode 100644 index 0000000..912cb7b --- /dev/null +++ b/qml/components/BigButton.qml @@ -0,0 +1,27 @@ +// BigButton.qml: + +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +Rectangle { + id: customButton + width: parent.width + height: Theme.itemSizeExtraLarge + color: Theme.secondaryHighlightColor + MouseArea { + anchors.fill: parent + onClicked: customButton.clicked() + } + + signal clicked() + + property alias buttonText: buttonText + + Text { + id: buttonText + text: "Button Text" + font.pixelSize: Theme.fontSizeExtraLarge + color: Theme.primaryColor + anchors.centerIn: parent + } +} diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 8d7d96a..2f63f47 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import QtQuick.Layouts 1.1 +import "../components" Page { id: page @@ -83,9 +84,14 @@ Page { } } - Button { - text: qsTr("Quit") - onClicked: Qt.quit() + BigButton { + buttonText.text: "First Button" + onClicked: console.log("First Button clicked!") + } + + BigButton { + buttonText.text: "Second Button" + onClicked: console.log("Second Button clicked!") } } } diff --git a/qt2.pro b/qt2.pro index e906fc4..03be887 100644 --- a/qt2.pro +++ b/qt2.pro @@ -17,6 +17,7 @@ CONFIG += sailfishapp SOURCES += src/qt2.cpp DISTFILES += qml/qt2.qml \ + qml/components/BigButton.qml \ qml/cover/CoverPage.qml \ qml/pages/FirstPage.qml \ qml/pages/SecondPage.qml \ diff --git a/translations/qt2-de.ts b/translations/qt2-de.ts index a18ac17..63b1ad1 100644 --- a/translations/qt2-de.ts +++ b/translations/qt2-de.ts @@ -22,10 +22,6 @@ Argh - - Quit - - SecondPage diff --git a/translations/qt2.ts b/translations/qt2.ts index f2e8c4f..8683d7e 100644 --- a/translations/qt2.ts +++ b/translations/qt2.ts @@ -22,10 +22,6 @@ Argh - - Quit - - SecondPage