qml: main: Qt6 fixes, formatting

This commit is contained in:
Tom Dewey 2024-07-17 11:07:54 +01:00 committed by Tom Dewey
parent 094142ae8e
commit 3d56ecf88c

View file

@ -442,91 +442,89 @@ ApplicationWindow {
// background of title // background of title
Rectangle { Rectangle {
id: hwpopup_title_background
color: "#f5f5f5" color: "#f5f5f5"
anchors.right: parent.right anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
height: 35 height: 35
width: parent.width width: parent.width
}
// line under title
Rectangle {
color: "#afafaf"
width: parent.width
y: 35
implicitHeight: 1
}
Text {
text: "X"
anchors.right: parent.right
anchors.top: parent.top
anchors.rightMargin: 25
anchors.topMargin: 10
font.family: roboto.name
font.bold: true
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
hwpopup.close()
}
}
}
ColumnLayout {
spacing: 10
Text { Text {
text: qsTr("Raspberry Pi Device") text: qsTr("Raspberry Pi Device")
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter anchors.fill: parent
Layout.fillWidth: true anchors.topMargin: 10
Layout.topMargin: 10
font.family: roboto.name font.family: roboto.name
font.bold: true font.bold: true
} }
Item { Text {
clip: true text: "X"
Layout.preferredWidth: hwlist.width Layout.alignment: Qt.AlignRight
Layout.preferredHeight: hwlist.height horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
anchors.right: parent.right
anchors.top: parent.top
anchors.rightMargin: 25
anchors.topMargin: 10
font.family: roboto.name
font.bold: true
ListView { MouseArea {
id: hwlist anchors.fill: parent
model: ListModel { cursorShape: Qt.PointingHandCursor
id: deviceModel onClicked: {
ListElement { hwpopup.close()
name: qsTr("[ All ]")
tags: "[]"
icon: ""
description: ""
matching_type: "exclusive"
}
} }
currentIndex: -1
delegate: hwdelegate
width: window.width-100
height: window.height-100
boundsBehavior: Flickable.StopAtBounds
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
ScrollBar.vertical: ScrollBar {
width: 10
policy: hwlist.contentHeight > hwlist.height ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded
}
Keys.onSpacePressed: {
if (currentIndex != -1)
selectHWitem(model.get(currentIndex))
}
Accessible.onPressAction: {
if (currentIndex != -1)
selectHWitem(model.get(currentIndex))
}
Keys.onEnterPressed: Keys.onSpacePressed(event)
Keys.onReturnPressed: Keys.onSpacePressed(event)
} }
} }
} }
// line under title
Rectangle {
id: hwpopup_title_separator
color: "#afafaf"
width: parent.width
anchors.top: hwpopup_title_background.bottom
height: 1
}
ListView {
id: hwlist
clip: true
model: ListModel {
id: deviceModel
ListElement {
name: qsTr("[ All ]")
tags: "[]"
icon: ""
description: ""
matching_type: "exclusive"
}
}
currentIndex: -1
delegate: hwdelegate
anchors.top: hwpopup_title_separator.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
boundsBehavior: Flickable.StopAtBounds
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
ScrollBar.vertical: ScrollBar {
anchors.right: parent.right
width: 10
policy: hwlist.contentHeight > hwlist.height ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded
}
Keys.onSpacePressed: {
if (currentIndex != -1)
selectHWitem(model.get(currentIndex))
}
Accessible.onPressAction: {
if (currentIndex != -1)
selectHWitem(model.get(currentIndex))
}
Keys.onEnterPressed: Keys.onSpacePressed(event)
Keys.onReturnPressed: Keys.onSpacePressed(event)
}
} }
/* /*
@ -544,93 +542,95 @@ ApplicationWindow {
// background of title // background of title
Rectangle { Rectangle {
id: ospopup_title_background
color: "#f5f5f5" color: "#f5f5f5"
anchors.right: parent.right anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
height: 35 height: 35
width: parent.width width: parent.width
}
// line under title
Rectangle {
color: "#afafaf"
width: parent.width
y: 35
implicitHeight: 1
}
Text {
text: "X"
anchors.right: parent.right
anchors.top: parent.top
anchors.rightMargin: 25
anchors.topMargin: 10
font.family: roboto.name
font.bold: true
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
ospopup.close()
osswipeview.decrementCurrentIndex()
}
}
}
ColumnLayout {
spacing: 10
Text { Text {
text: qsTr("Operating System") text: qsTr("Operating System")
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter anchors.fill: parent
Layout.fillWidth: true anchors.topMargin: 10
Layout.topMargin: 10
font.family: roboto.name font.family: roboto.name
font.bold: true font.bold: true
} }
Item { Text {
clip: true text: "X"
Layout.preferredWidth: oslist.width Layout.alignment: Qt.AlignRight
Layout.preferredHeight: oslist.height horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
anchors.right: parent.right
anchors.top: parent.top
anchors.rightMargin: 25
anchors.topMargin: 10
font.family: roboto.name
font.bold: true
SwipeView { MouseArea {
id: osswipeview anchors.fill: parent
interactive: false cursorShape: Qt.PointingHandCursor
onClicked: {
ListView { ospopup.close()
id: oslist osswipeview.decrementCurrentIndex()
model: osmodel
currentIndex: -1
delegate: osdelegate
width: window.width-100
height: window.height-100
boundsBehavior: Flickable.StopAtBounds
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
ScrollBar.vertical: ScrollBar {
width: 10
policy: oslist.contentHeight > oslist.height ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded
}
Keys.onSpacePressed: {
if (currentIndex != -1)
selectOSitem(model.get(currentIndex), true)
}
Accessible.onPressAction: {
if (currentIndex != -1)
selectOSitem(model.get(currentIndex), true)
}
Keys.onEnterPressed: Keys.onSpacePressed(event)
Keys.onReturnPressed: Keys.onSpacePressed(event)
Keys.onRightPressed: {
// Navigate into sublists but don't select an OS entry
if (currentIndex != -1 && isOSsublist(model.get(currentIndex)))
selectOSitem(model.get(currentIndex), true)
}
} }
} }
} }
} }
// line under title
Rectangle {
id: ospopup_title_separator
color: "#afafaf"
width: parent.width
anchors.top: ospopup_title_background.bottom
height: 1
}
SwipeView {
anchors.top: ospopup_title_separator.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
id: osswipeview
interactive: false
clip: true
ListView {
id: oslist
model: osmodel
currentIndex: -1
delegate: osdelegate
anchors.top: parent.top
anchors.left: parent.left
anchors.bottom: parent.bottom
width: ospopup.width
boundsBehavior: Flickable.StopAtBounds
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
ScrollBar.vertical: ScrollBar {
anchors.right: parent.right
width: 10
policy: oslist.contentHeight > oslist.height ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded
}
Keys.onSpacePressed: {
if (currentIndex != -1)
selectOSitem(model.get(currentIndex), true)
}
Accessible.onPressAction: {
if (currentIndex != -1)
selectOSitem(model.get(currentIndex), true)
}
Keys.onEnterPressed: Keys.onSpacePressed(event)
Keys.onReturnPressed: Keys.onSpacePressed(event)
Keys.onRightPressed: {
// Navigate into sublists but don't select an OS entry
if (currentIndex != -1 && isOSsublist(model.get(currentIndex)))
selectOSitem(model.get(currentIndex), true)
}
}
}
} }
Component { Component {
@ -658,8 +658,7 @@ ApplicationWindow {
currentIndex: -1 currentIndex: -1
delegate: osdelegate delegate: osdelegate
width: window.width-100
height: window.height-100
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
highlight: Rectangle { color: "lightsteelblue"; radius: 5 } highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
ScrollBar.vertical: ScrollBar { ScrollBar.vertical: ScrollBar {
@ -726,18 +725,18 @@ ApplicationWindow {
} }
Rectangle { Rectangle {
id: bgrect id: bgrect
anchors.fill: parent anchors.fill: parent
color: "#f5f5f5" color: "#f5f5f5"
visible: mouseOver && parent.ListView.view.currentIndex !== index visible: mouseOver && parent.ListView.view.currentIndex !== index
property bool mouseOver: false property bool mouseOver: false
} }
Rectangle { Rectangle {
id: borderrect id: borderrect
implicitHeight: 1 implicitHeight: 1
implicitWidth: parent.width implicitWidth: parent.width
color: "#dcdcdc" color: "#dcdcdc"
y: parent.height y: parent.height
} }
RowLayout { RowLayout {
@ -817,18 +816,18 @@ ApplicationWindow {
} }
Rectangle { Rectangle {
id: bgrect id: bgrect
anchors.fill: parent anchors.fill: parent
color: "#f5f5f5" color: "#f5f5f5"
visible: mouseOver && parent.ListView.view.currentIndex !== index visible: mouseOver && parent.ListView.view.currentIndex !== index
property bool mouseOver: false property bool mouseOver: false
} }
Rectangle { Rectangle {
id: borderrect id: borderrect
implicitHeight: 1 implicitHeight: 1
implicitWidth: parent.width implicitWidth: parent.width
color: "#dcdcdc" color: "#dcdcdc"
y: parent.height y: parent.height
} }
RowLayout { RowLayout {
@ -900,11 +899,11 @@ ApplicationWindow {
font.weight: Font.Light font.weight: Font.Light
visible: typeof(url) == "string" && url != "" && url != "internal://format" visible: typeof(url) == "string" && url != "" && url != "internal://format"
text: !url ? "" : text: !url ? "" :
typeof(extract_sha256) != "undefined" && imageWriter.isCached(url,extract_sha256) typeof(extract_sha256) != "undefined" && imageWriter.isCached(url,extract_sha256)
? qsTr("Cached on your computer") ? qsTr("Cached on your computer")
: url.startsWith("file://") : url.startsWith("file://")
? qsTr("Local file") ? qsTr("Local file")
: qsTr("Online - %1 GB download").arg((image_download_size/1073741824).toFixed(1)) : qsTr("Online - %1 GB download").arg((image_download_size/1073741824).toFixed(1))
} }
ToolTip { ToolTip {
@ -940,102 +939,101 @@ ApplicationWindow {
// background of title // background of title
Rectangle { Rectangle {
id: dstpopup_title_background
color: "#f5f5f5" color: "#f5f5f5"
anchors.right: parent.right anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
height: 35 height: 35
width: parent.width width: parent.width
}
// line under title
Rectangle {
color: "#afafaf"
width: parent.width
y: 35
implicitHeight: 1
}
Text {
text: "X"
anchors.right: parent.right
anchors.top: parent.top
anchors.rightMargin: 25
anchors.topMargin: 10
font.family: roboto.name
font.bold: true
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
dstpopup.close()
}
}
}
ColumnLayout {
spacing: 10
Text { Text {
text: qsTr("Storage") text: qsTr("Storage")
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter anchors.fill: parent
Layout.fillWidth: true anchors.topMargin: 10
Layout.topMargin: 10
font.family: roboto.name font.family: roboto.name
font.bold: true font.bold: true
} }
Item { Text {
clip: true text: "X"
Layout.preferredWidth: dstlist.width Layout.alignment: Qt.AlignRight
Layout.preferredHeight: dstlist.height horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
anchors.right: parent.right
anchors.top: parent.top
anchors.rightMargin: 25
anchors.topMargin: 10
font.family: roboto.name
font.bold: true
ListView { MouseArea {
id: dstlist anchors.fill: parent
model: driveListModel cursorShape: Qt.PointingHandCursor
delegate: dstdelegate onClicked: {
width: window.width-100 dstpopup.close()
height: window.height-100
boundsBehavior: Flickable.StopAtBounds
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
Label {
anchors.fill: parent
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
visible: parent.count == 0
text: qsTr("No storage devices found")
font.bold: true
} }
ScrollBar.vertical: ScrollBar {
width: 10
policy: dstlist.contentHeight > dstlist.height ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded
}
Keys.onSpacePressed: {
if (currentIndex == -1)
return
selectDstItem(currentItem)
}
Accessible.onPressAction: {
if (currentIndex == -1)
return
selectDstItem(currentItem)
}
Keys.onEnterPressed: Keys.onSpacePressed(event)
Keys.onReturnPressed: Keys.onSpacePressed(event)
} }
} }
} }
// line under title
Rectangle {
id: dstpopup_title_separator
color: "#afafaf"
width: parent.width
anchors.top: dstpopup_title_background.bottom
height: 1
}
ListView {
id: dstlist
model: driveListModel
delegate: dstdelegate
anchors.top: dstpopup_title_separator.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
boundsBehavior: Flickable.StopAtBounds
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
clip: true
Label {
anchors.fill: parent
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
visible: parent.count == 0
text: qsTr("No storage devices found")
font.bold: true
}
ScrollBar.vertical: ScrollBar {
width: 10
policy: dstlist.contentHeight > dstlist.height ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded
}
Keys.onSpacePressed: {
if (currentIndex == -1)
return
selectDstItem(currentItem)
}
Accessible.onPressAction: {
if (currentIndex == -1)
return
selectDstItem(currentItem)
}
Keys.onEnterPressed: Keys.onSpacePressed(event)
Keys.onReturnPressed: Keys.onSpacePressed(event)
}
} }
Component { Component {
id: dstdelegate id: dstdelegate
Item { Item {
width: window.width-100 anchors.left: parent.left
height: 60 anchors.right: parent.right
Layout.topMargin: 1
height: 61
Accessible.name: { Accessible.name: {
var txt = description+" - "+(size/1000000000).toFixed(1)+" gigabytes" var txt = description+" - "+(size/1000000000).toFixed(1)+" gigabytes"
if (mountpoints.length > 0) { if (mountpoints.length > 0) {
@ -1048,62 +1046,76 @@ ApplicationWindow {
property string size: model.size property string size: model.size
Rectangle { Rectangle {
id: dstbgrect id: dstbgrect
anchors.fill: parent anchors.top: parent.top
color: "#f5f5f5" anchors.left: parent.left
visible: mouseOver && parent.ListView.view.currentIndex !== index anchors.right: parent.right
property bool mouseOver: false height: 60
} color: mouseOver ? "#f5f5f5" : "#ffffff"
Rectangle { property bool mouseOver: false
id: dstborderrect
implicitHeight: 1
implicitWidth: parent.width
color: "#dcdcdc"
y: parent.height
}
Row { RowLayout {
leftPadding: 25 anchors.fill: parent
Column { Item {
width: 64 width: 25
}
Image { Image {
id: dstitem_image
source: isUsb ? "icons/ic_usb_40px.svg" : isScsi ? "icons/ic_storage_40px.svg" : "icons/ic_sd_storage_40px.svg" source: isUsb ? "icons/ic_usb_40px.svg" : isScsi ? "icons/ic_storage_40px.svg" : "icons/ic_sd_storage_40px.svg"
verticalAlignment: Image.AlignVCenter verticalAlignment: Image.AlignVCenter
height: parent.parent.parent.height
fillMode: Image.Pad fillMode: Image.Pad
width: 64
height: 60
} }
}
Column {
width: parent.parent.width-64
Text { Item {
textFormat: Text.StyledText width: 25
height: parent.parent.parent.height }
verticalAlignment: Text.AlignVCenter
font.family: roboto.name ColumnLayout {
text: { Text {
var sizeStr = (size/1000000000).toFixed(1)+" GB"; textFormat: Text.StyledText
var txt; verticalAlignment: Text.AlignVCenter
if (isReadOnly) { Layout.fillWidth: true
txt = "<p><font size='4' color='grey'>"+description+" - "+sizeStr+"</font></p>" font.family: roboto.name
txt += "<font color='grey'>" font.pointSize: 16
if (mountpoints.length > 0) { color: isReadOnly ? "grey" : "";
txt += qsTr("Mounted as %1").arg(mountpoints.join(", "))+" " text: {
} var sizeStr = (size/1000000000).toFixed(1)+ " " + qsTr("GB");
txt += qsTr("[WRITE PROTECTED]")+"</font>" return description + " - " + sizeStr;
} else { }
txt = "<p><font size='4'>"+description+" - "+sizeStr+"</font></p>"
if (mountpoints.length > 0) { }
txt += "<font color='grey'>"+qsTr("Mounted as %1").arg(mountpoints.join(", "))+"</font>" Text {
} textFormat: Text.StyledText
height: parent.height
verticalAlignment: Text.AlignVCenter
Layout.fillWidth: true
font.family: roboto.name
font.pointSize: 12
color: "grey"
text: {
var txt= qsTr("Mounted as %1").arg(mountpoints.join(", "));
if (isReadOnly) {
txt += " " + qsTr("[WRITE PROTECTED]")
}
return txt;
} }
return txt;
} }
} }
} }
}
Rectangle {
id: dstborderrect
anchors.top: dstbgrect.bottom
anchors.left: parent.left
anchors.right: parent.right
height: 1
color: "#dcdcdc"
} }
MouseArea { MouseArea {
@ -1196,6 +1208,8 @@ ApplicationWindow {
} }
OptionsPopup { OptionsPopup {
minimumWidth: 450
minimumHeight: 400
id: optionspopup id: optionspopup
onSaveSettingsSignal: { onSaveSettingsSignal: {
imageWriter.setSavedCustomizationSettings(settings) imageWriter.setSavedCustomizationSettings(settings)
@ -1376,61 +1390,61 @@ ApplicationWindow {
var foundTag = false var foundTag = false
switch(matchingType) { switch(matchingType) {
case 0: /* exact matching */ case 0: /* exact matching */
case 2: /* exact matching */ case 2: /* exact matching */
for (var j in tags) for (var j in tags)
{
if (entry["devices"].includes(tags[j]))
{ {
if (entry["devices"].includes(tags[j])) foundTag = true
{ break
}
}
/* If there's no match, remove this item from the list. */
if (!foundTag)
{
list.splice(i, 1)
continue
}
break
case 1: /* Exlusive by prefix matching */
case 3: /* Inclusive by prefix matching */
for (var deviceTypePrefix in tags) {
for (var deviceSpec in entry["devices"]) {
if (deviceSpec.startsWith(deviceTypePrefix)) {
foundTag = true foundTag = true
break break
} }
} }
/* If there's no match, remove this item from the list. */ /* Terminate outer loop early if we've already
if (!foundTag)
{
list.splice(i, 1)
continue
}
break
case 1: /* Exlusive by prefix matching */
case 3: /* Inclusive by prefix matching */
for (var deviceTypePrefix in tags) {
for (var deviceSpec in entry["devices"]) {
if (deviceSpec.startsWith(deviceTypePrefix)) {
foundTag = true
break
}
}
/* Terminate outer loop early if we've already
* decided it's a match * decided it's a match
*/ */
if (foundTag) { if (foundTag) {
break break
}
} }
/* If there's no match, remove this item from the list. */ }
if (!foundTag) /* If there's no match, remove this item from the list. */
{ if (!foundTag)
list.splice(i, 1) {
continue list.splice(i, 1)
} continue
break }
break
} }
} else { } else {
/* No device list attached? If we're in an exclusive mode that's bad news indeed. */ /* No device list attached? If we're in an exclusive mode that's bad news indeed. */
switch (matchingType) { switch (matchingType) {
case 0: case 0:
case 1: case 1:
if (!("subitems" in entry)) { if (!("subitems" in entry)) {
/* If you're not carrying subitems, you're not going in. */ /* If you're not carrying subitems, you're not going in. */
list.splice(i, 1) list.splice(i, 1)
} }
break break
case 2: case 2:
case 3: case 3:
/* Inclusive filtering. We're keeping this one. */ /* Inclusive filtering. We're keeping this one. */
break; break;
} }
} }
@ -1559,11 +1573,11 @@ ApplicationWindow {
fetch data by numeric role number */ fetch data by numeric role number */
if (driveListModel.data(driveListModel.index(i,0), 0x101) === drive) { if (driveListModel.data(driveListModel.index(i,0), 0x101) === drive) {
selectDstItem({ selectDstItem({
device: drive, device: drive,
description: driveListModel.data(driveListModel.index(i,0), 0x102), description: driveListModel.data(driveListModel.index(i,0), 0x102),
size: driveListModel.data(driveListModel.index(i,0), 0x103), size: driveListModel.data(driveListModel.index(i,0), 0x103),
readonly: false readonly: false
}) })
break break
} }
} }
@ -1593,11 +1607,11 @@ ApplicationWindow {
if (hwmodel.matching_type) { if (hwmodel.matching_type) {
switch (hwmodel.matching_type) { switch (hwmodel.matching_type) {
case "exclusive": case "exclusive":
break; break;
case "inclusive": case "inclusive":
inclusive = true inclusive = true
break; break;
} }
} }
@ -1655,7 +1669,7 @@ ApplicationWindow {
// Sub-category // Sub-category
if (typeof(d.subitems_url) == "string" && d.subitems_url !== "" if (typeof(d.subitems_url) == "string" && d.subitems_url !== ""
&& d.subitems_url !== "internal://back") && d.subitems_url !== "internal://back")
{ {
return true return true
} }