Skip to content

Commit

Permalink
[QML] Align WepPatch Details design with Patch Details.
Browse files Browse the repository at this point in the history
  • Loading branch information
nephros committed May 5, 2024
1 parent d3679be commit f7bbc0f
Showing 1 changed file with 69 additions and 61 deletions.
130 changes: 69 additions & 61 deletions src/qml/WebPatchPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,36 @@ Page {
*/
property bool fetching: true

onPatchDataChanged: linksmodel.populate()
ListModel {
id: linksmodel
// simply defining the ListItems does not work, errors with "cannot assign a script item"
// so we append them when we're ready
function populate() {
if (patchData.discussion) {
linksmodel.append({
"link": patchData.discussion,
"linktext": qsTranslate("", "Discussion"),
"iconname": "icon-s-chat"
})
}
if (patchData.sources) {
linksmodel.append({
"link": patchData.sources,
"linktext": qsTranslate("", "Sources"),
"iconname": "icon-s-developer"
})
}
if (patchData.donations) {
linksmodel.append({
"link": patchData.donations,
"linktext": qsTranslate("", "Donations"),
"iconname": "icon-s-invitation"
})
}
}
}

onStatusChanged: {
if (status == PageStatus.Active) {
voteAction = PatchManager.checkVote(modelData.name)
Expand Down Expand Up @@ -257,82 +287,60 @@ Page {
}
}

SectionHeader {
text: qsTranslate("", "Description")
}

Label {
color: Theme.highlightColor
color: Theme.secondaryHighlightColor
anchors {
left: parent.left
right: parent.right
margins: Theme.horizontalPageMargin
}
horizontalAlignment: Text.AlignJustify
wrapMode: Text.WordWrap
text: !!patchData && patchData.description ? patchData.description : ""
}

SectionHeader {
text: qsTranslate("", "Links")
visible: !!patchData && (!!patchData.discussion || !!patchData.donations || !!patchData.sources)
}

BackgroundItem {
width: parent.width
height: Theme.itemSizeExtraSmall
visible: !!patchData && !!patchData.discussion

onClicked: {
Qt.openUrlExternally(patchData.discussion)
}

Label {
color: Theme.highlightColor
anchors {
left: parent.left
right: parent.right
margins: Theme.horizontalPageMargin
verticalCenter: parent.verticalCenter
}
text: !!patchData && patchData.discussion ? qsTranslate("", "Open discussion link") : ""
}
}

BackgroundItem {
width: parent.width
height: Theme.itemSizeExtraSmall
visible: !!patchData && !!patchData.donations

onClicked: {
Qt.openUrlExternally(patchData.donations)
}

Label {
color: Theme.highlightColor
anchors {
left: parent.left
right: parent.right
margins: Theme.horizontalPageMargin
verticalCenter: parent.verticalCenter
}
text: !!patchData && patchData.donations ? qsTranslate("", "Donate") : ""
}
visible: (linksmodel.count > 0)
}

BackgroundItem {
width: parent.width
height: Theme.itemSizeExtraSmall
visible: !!patchData && patchData.sources

onClicked: {
Qt.openUrlExternally(patchData.value.sources)
}

Label {
color: Theme.highlightColor
anchors {
left: parent.left
right: parent.right
margins: Theme.horizontalPageMargin
verticalCenter: parent.verticalCenter
Column {
id: links
visible: linksmodel.count > 0
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: Theme.horizontalPageMargin
spacing: Theme.paddingSmall
Repeater {
model: linksmodel
delegate: Component {
ListItem {
contentHeight: Theme.itemSizeExtraSmall
width: parent.width
Row {
width: parent.width
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.paddingMedium
Icon {
anchors.verticalCenter: parent.verticalCenter
source: "image://theme/" + iconname
sourceSize.width: Theme.iconSizeMedium
sourceSize.height: sourceSize.width
}
Label {
anchors.verticalCenter: parent.verticalCenter
color: Theme.secondaryHighlightColor
linkColor: Theme.highlightColor
text: linktext
}
}
onClicked: Qt.openUrlExternally(link)
}
}
text: !!patchData && patchData.sources ? qsTranslate("", "Sources") : ""
}
}

Expand Down

0 comments on commit f7bbc0f

Please sign in to comment.