mobile-widgets/qml: add TemplateButton

Do "git mv SsrfButton TemplateButton", and search/replace
all uses.

The general idea of the templates are to secure common layout,
but also to isolate the Kirigami parts (slowly) in the templates.

Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
jan Iversen 2019-02-11 17:09:51 +01:00 committed by Dirk Hohndel
parent fb7920ef58
commit 3aa43f3ea5
8 changed files with 24 additions and 24 deletions

View file

@ -56,7 +56,7 @@ Kirigami.ScrollablePage {
anchors.horizontalCenter: parent.Center anchors.horizontalCenter: parent.Center
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
} }
SsrfButton { TemplateButton {
id: copyAppLogToClipboard id: copyAppLogToClipboard
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
text: qsTr("Copy logs to clipboard") text: qsTr("Copy logs to clipboard")

View file

@ -95,7 +95,7 @@ Item {
Layout.margins: Kirigami.Units.smallSpacing Layout.margins: Kirigami.Units.smallSpacing
spacing: Kirigami.Units.smallSpacing spacing: Kirigami.Units.smallSpacing
visible: showPin visible: showPin
SsrfButton { TemplateButton {
id: registerpin id: registerpin
text: qsTr("Register") text: qsTr("Register")
onClicked: { onClicked: {
@ -106,7 +106,7 @@ Item {
text: "" // Spacer between 2 button groups text: "" // Spacer between 2 button groups
Layout.fillWidth: true Layout.fillWidth: true
} }
SsrfButton { TemplateButton {
id: cancelpin id: cancelpin
text: qsTr("Cancel") text: qsTr("Cancel")
onClicked: { onClicked: {
@ -122,7 +122,7 @@ Item {
spacing: Kirigami.Units.smallSpacing spacing: Kirigami.Units.smallSpacing
visible: !showPin visible: !showPin
SsrfButton { TemplateButton {
id: signin_register_normal id: signin_register_normal
text: qsTr("Sign-in or Register") text: qsTr("Sign-in or Register")
onClicked: { onClicked: {
@ -133,7 +133,7 @@ Item {
text: "" // Spacer between 2 button groups text: "" // Spacer between 2 button groups
Layout.fillWidth: true Layout.fillWidth: true
} }
SsrfButton { TemplateButton {
id: toNoCloudMode id: toNoCloudMode
text: qsTr("No cloud mode") text: qsTr("No cloud mode")
onClicked: { onClicked: {
@ -146,7 +146,7 @@ Item {
} }
} }
} }
SsrfButton { TemplateButton {
id: signin_forgot_password id: signin_forgot_password
text: qsTr("Forgot password?") text: qsTr("Forgot password?")
onClicked: { onClicked: {

View file

@ -56,7 +56,7 @@ Item {
} }
} }
} }
SsrfButton { TemplateButton {
id: gpsButton id: gpsButton
anchors.right: parent.right anchors.right: parent.right
enabled: gps !== "" enabled: gps !== ""

View file

@ -245,7 +245,7 @@ Kirigami.Page {
} }
} }
SsrfButton { TemplateButton {
id: dc1 id: dc1
visible: PrefDiveComputer.vendor1 !== "" visible: PrefDiveComputer.vendor1 !== ""
text: PrefDiveComputer.vendor1 + " - " + PrefDiveComputer.product1 text: PrefDiveComputer.vendor1 + " - " + PrefDiveComputer.product1
@ -254,7 +254,7 @@ Kirigami.Page {
rememberedDCsGrid.setDC(PrefDiveComputer.vendor1, PrefDiveComputer.product1, PrefDiveComputer.device1) rememberedDCsGrid.setDC(PrefDiveComputer.vendor1, PrefDiveComputer.product1, PrefDiveComputer.device1)
} }
} }
SsrfButton { TemplateButton {
id: dc2 id: dc2
visible: PrefDiveComputer.vendor2 !== "" visible: PrefDiveComputer.vendor2 !== ""
text: PrefDiveComputer.vendor2 + " - " + PrefDiveComputer.product2 text: PrefDiveComputer.vendor2 + " - " + PrefDiveComputer.product2
@ -263,7 +263,7 @@ Kirigami.Page {
rememberedDCsGrid.setDC(PrefDiveComputer.vendor2, PrefDiveComputer.product2, PrefDiveComputer.device2) rememberedDCsGrid.setDC(PrefDiveComputer.vendor2, PrefDiveComputer.product2, PrefDiveComputer.device2)
} }
} }
SsrfButton { TemplateButton {
id: dc3 id: dc3
visible: PrefDiveComputer.vendor3 !== "" visible: PrefDiveComputer.vendor3 !== ""
text: PrefDiveComputer.vendor3 + " - " + PrefDiveComputer.product3 text: PrefDiveComputer.vendor3 + " - " + PrefDiveComputer.product3
@ -272,7 +272,7 @@ Kirigami.Page {
rememberedDCsGrid.setDC(PrefDiveComputer.vendor3, PrefDiveComputer.product3, PrefDiveComputer.device3) rememberedDCsGrid.setDC(PrefDiveComputer.vendor3, PrefDiveComputer.product3, PrefDiveComputer.device3)
} }
} }
SsrfButton { TemplateButton {
id: dc4 id: dc4
visible: PrefDiveComputer.vendor4 !== "" visible: PrefDiveComputer.vendor4 !== ""
text: PrefDiveComputer.vendor4 + " - " + PrefDiveComputer.product4 text: PrefDiveComputer.vendor4 + " - " + PrefDiveComputer.product4
@ -296,7 +296,7 @@ Kirigami.Page {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: Kirigami.Units.smallSpacing Layout.topMargin: Kirigami.Units.smallSpacing
spacing: Kirigami.Units.smallSpacing spacing: Kirigami.Units.smallSpacing
SsrfButton { TemplateButton {
id: download id: download
text: qsTr("Download") text: qsTr("Download")
enabled: comboVendor.currentIndex != -1 && comboProduct.currentIndex != -1 && enabled: comboVendor.currentIndex != -1 && comboProduct.currentIndex != -1 &&
@ -332,7 +332,7 @@ Kirigami.Page {
importModel.startDownload() importModel.startDownload()
} }
} }
SsrfButton { TemplateButton {
id:quitbutton id:quitbutton
text: progressBar.visible ? qsTr("Cancel") : qsTr("Quit") text: progressBar.visible ? qsTr("Cancel") : qsTr("Quit")
onClicked: { onClicked: {
@ -346,7 +346,7 @@ Kirigami.Page {
manager.appendTextToLog("exit DCDownload screen") manager.appendTextToLog("exit DCDownload screen")
} }
} }
SsrfButton { TemplateButton {
id:rescanbutton id:rescanbutton
text: qsTr("Rescan") text: qsTr("Rescan")
enabled: manager.btEnabled enabled: manager.btEnabled
@ -421,7 +421,7 @@ Kirigami.Page {
text: "" // Spacer on the left for hamburger menu text: "" // Spacer on the left for hamburger menu
width: Kirigami.Units.gridUnit * 2.5 width: Kirigami.Units.gridUnit * 2.5
} }
SsrfButton { TemplateButton {
id: acceptButton id: acceptButton
property bool busy: false property bool busy: false
enabled: divesDownloaded enabled: divesDownloaded
@ -456,7 +456,7 @@ Kirigami.Page {
text: "" // Spacer between 2 button groups text: "" // Spacer between 2 button groups
Layout.fillWidth: true Layout.fillWidth: true
} }
SsrfButton { TemplateButton {
id: select id: select
enabled: divesDownloaded enabled: divesDownloaded
text: qsTr("Select All") text: qsTr("Select All")
@ -465,7 +465,7 @@ Kirigami.Page {
importModel.selectAll() importModel.selectAll()
} }
} }
SsrfButton { TemplateButton {
id: unselect id: unselect
enabled: divesDownloaded enabled: divesDownloaded
text: qsTr("Unselect All") text: qsTr("Unselect All")

View file

@ -249,7 +249,7 @@ Kirigami.ScrollablePage {
Layout.fillWidth: true Layout.fillWidth: true
text: qsTr("Anonymize") text: qsTr("Anonymize")
} }
SsrfButton { TemplateButton {
text: qsTr("Next") text: qsTr("Next")
onClicked: { onClicked: {
if (selectedExport === ExportType.EX_DIVELOGS_DE) { if (selectedExport === ExportType.EX_DIVELOGS_DE) {

View file

@ -50,7 +50,7 @@ Kirigami.ScrollablePage {
text: Backend.cloud_verification_status === Enums.CS_NOCLOUD ? qsTr("Not applicable") : PrefCloudStorage.cloud_storage_email text: Backend.cloud_verification_status === Enums.CS_NOCLOUD ? qsTr("Not applicable") : PrefCloudStorage.cloud_storage_email
Layout.preferredWidth: gridWidth * 0.60 Layout.preferredWidth: gridWidth * 0.60
} }
SsrfButton { TemplateButton {
id: changeCloudSettings id: changeCloudSettings
text: qsTr("Change") text: qsTr("Change")
onClicked: { onClicked: {
@ -120,7 +120,7 @@ Kirigami.ScrollablePage {
text: qsTr("Forget remembered dive computers") text: qsTr("Forget remembered dive computers")
Layout.preferredWidth: gridWidth * 0.75 Layout.preferredWidth: gridWidth * 0.75
} }
SsrfButton { TemplateButton {
id: forgetDCButton id: forgetDCButton
text: qsTr("Forget") text: qsTr("Forget")
enabled: PrefDiveComputer.vendor1 !== "" enabled: PrefDiveComputer.vendor1 !== ""
@ -310,21 +310,21 @@ Kirigami.ScrollablePage {
Layout.preferredWidth: gridWidth * 0.8 Layout.preferredWidth: gridWidth * 0.8
Layout.columnSpan: 3 Layout.columnSpan: 3
spacing: Kirigami.Units.largeSpacing spacing: Kirigami.Units.largeSpacing
SsrfButton { TemplateButton {
text: qsTr("smaller") text: qsTr("smaller")
enabled: ThemeNew.currentScale !== 0.85 enabled: ThemeNew.currentScale !== 0.85
onClicked: { onClicked: {
ThemeNew.currentScale = 0.85 ThemeNew.currentScale = 0.85
} }
} }
SsrfButton { TemplateButton {
text: qsTr("regular") text: qsTr("regular")
enabled: ThemeNew.currentScale !== 1.0 enabled: ThemeNew.currentScale !== 1.0
onClicked: { onClicked: {
ThemeNew.currentScale = 1.0 ThemeNew.currentScale = 1.0
} }
} }
SsrfButton { TemplateButton {
text: qsTr("larger") text: qsTr("larger")
enabled: ThemeNew.currentScale !== 1.15 enabled: ThemeNew.currentScale !== 1.15
onClicked: { onClicked: {

View file

@ -1,6 +1,7 @@
<RCC> <RCC>
<qresource prefix="/qml"> <qresource prefix="/qml">
<!-- ********** Templates ********** --> <!-- ********** Templates ********** -->
<file>TemplateButton.qml</file>
<file>TemplateCheckBox.qml</file> <file>TemplateCheckBox.qml</file>
<file>TemplateComboBox.qml</file> <file>TemplateComboBox.qml</file>
<file>TemplateLabel.qml</file> <file>TemplateLabel.qml</file>
@ -36,7 +37,6 @@
<file>CopySettings.qml</file> <file>CopySettings.qml</file>
<file>ThemeTest.qml</file> <file>ThemeTest.qml</file>
<file>StartPage.qml</file> <file>StartPage.qml</file>
<file>SsrfButton.qml</file>
<file>SsrfCheckBox.qml</file> <file>SsrfCheckBox.qml</file>
<file>SsrfSwitch.qml</file> <file>SsrfSwitch.qml</file>
<file>SsrfTextField.qml</file> <file>SsrfTextField.qml</file>