-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ListLink component to show either QR code or link button
Part of #1811
- Loading branch information
Showing
7 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
** Copyright (C) 2024 Victron Energy B.V. | ||
** See LICENSE.txt for license information. | ||
*/ | ||
|
||
import QtQuick | ||
import QtQuick.Controls.impl as CP | ||
import Victron.VenusOS | ||
|
||
ListItem { | ||
id: root | ||
|
||
property string url | ||
property string caption: root.mode === VenusOS.ListLink_Mode_LinkButton ? "" | ||
//: %1 = url text | ||
//% "Scan the QR code with your portable device.<br />Or insert the link: %1" | ||
: qsTrId("listlink_scan_qr_code").arg(formattedUrl) | ||
readonly property string formattedUrl: "<font color=\"%1\">%2</font>".arg(Theme.color_font_primary).arg(url) | ||
|
||
readonly property int mode: Qt.platform.os == "wasm" ? VenusOS.ListLink_Mode_LinkButton : VenusOS.ListLink_Mode_QRCode | ||
|
||
down: pressArea.containsPress | ||
|
||
content.children: [ | ||
SecondaryListLabel { | ||
visible: root.mode === VenusOS.ListLink_Mode_LinkButton | ||
anchors.verticalCenter: parent.verticalCenter | ||
width: Math.min(implicitWidth, root.maximumContentWidth - icon.width - root.content.spacing) | ||
//% "Open link" | ||
text: qsTrId("listlink_open_link") | ||
}, | ||
|
||
CP.ColorImage { | ||
id: icon | ||
|
||
visible: root.mode === VenusOS.ListLink_Mode_LinkButton | ||
anchors.verticalCenter: parent.verticalCenter | ||
source: "qrc:/images/icon_open_link_32.svg" | ||
rotation: 180 | ||
color: pressArea.containsPress ? Theme.color_listItem_down_forwardIcon : Theme.color_listItem_forwardIcon | ||
}, | ||
|
||
Item { | ||
visible: root.mode === VenusOS.ListLink_Mode_QRCode | ||
width: Theme.geometry_listLink_qrCodeSize | ||
height: Theme.geometry_listLink_qrCodeSize + (2 * Theme.geometry_listItem_content_verticalMargin) | ||
|
||
Image { | ||
anchors.centerIn: parent | ||
source: root.mode === VenusOS.ListLink_Mode_QRCode | ||
? `image://QZXing/encode/${root.url}?correctionLevel=M&format=qrcode` | ||
: "" | ||
sourceSize.width: Theme.geometry_listLink_qrCodeSize | ||
sourceSize.height: Theme.geometry_listLink_qrCodeSize | ||
} | ||
} | ||
] | ||
|
||
bottomContentChildren: [ | ||
PrimaryListLabel { | ||
font.pixelSize: Theme.font_size_body1 | ||
horizontalAlignment: Text.AlignLeft | ||
color: Theme.color_listItem_secondaryText | ||
text: root.caption | ||
visible: root.mode === VenusOS.ListLink_Mode_QRCode | ||
} | ||
] | ||
|
||
ListPressArea { | ||
id: pressArea | ||
|
||
enabled: root.mode === VenusOS.ListLink_Mode_LinkButton | ||
radius: backgroundRect.radius | ||
anchors.fill: root.backgroundRect | ||
onClicked: { | ||
BackendConnection.openUrl(root.url) | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -327,6 +327,11 @@ Page { | |
} | ||
] | ||
} | ||
|
||
ListLink { | ||
text: "Victron Energy" | ||
url: "https://www.victronenergy.com" | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters