1
0

qml: port PyQt5 to PyQt6

This commit is contained in:
Sander van Grieken
2023-07-14 13:51:08 +02:00
parent 0441cb0ad5
commit 6270eae5c9
41 changed files with 199 additions and 162 deletions

View File

@@ -1,8 +1,8 @@
import QtQuick 2.6
import QtQuick.Controls.Material 2.0
import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Material
Item {
readonly property int paddingTiny: 4 //deprecated
readonly property int paddingXXSmall: 4
readonly property int paddingXSmall: 6
readonly property int paddingSmall: 8

View File

@@ -27,12 +27,11 @@ Pane {
ColumnLayout {
id: rootLayout
width: parent.width
height: parent.height
anchors.fill: parent
spacing: 0
ColumnLayout {
Layout.preferredWidth: parent.width
Layout.fillWidth: true
Layout.margins: constants.paddingLarge
Heading {
@@ -41,7 +40,7 @@ Pane {
Frame {
id: detailsFrame
Layout.preferredWidth: parent.width
Layout.fillWidth: true
Layout.fillHeight: true
verticalPadding: 0
horizontalPadding: 0

View File

@@ -121,7 +121,7 @@ Item {
visible: delegate.ListView.section == delegate.ListView.nextSection
Layout.preferredWidth: parent.width * 2/3
Layout.alignment: Qt.AlignHCenter
Layout.preferredHeight: constants.paddingTiny
Layout.preferredHeight: constants.paddingXXSmall
color: Material.background
}

View File

@@ -31,7 +31,7 @@ ItemDelegate {
Rectangle {
Layout.columnSpan: 2
Layout.fillWidth: true
Layout.preferredHeight: constants.paddingTiny
Layout.preferredHeight: constants.paddingXXSmall
color: 'transparent'
}
@@ -133,7 +133,7 @@ ItemDelegate {
Rectangle {
Layout.columnSpan: 2
Layout.fillWidth: true
Layout.preferredHeight: constants.paddingTiny
Layout.preferredHeight: constants.paddingXXSmall
color: 'transparent'
}

View File

@@ -13,7 +13,7 @@ Image {
property bool proxy: connected && 'mode' in Network.proxy && Network.proxy.mode
// ?: in order to keep this a binding..
source: !connected
source: Qt.resolvedUrl(!connected
? '../../../icons/status_disconnected.png'
: syncing
? '../../../icons/status_waiting.png'
@@ -27,7 +27,7 @@ Image {
: '../../../icons/status_connected_fork.png'
: proxy
? '../../../icons/status_connected_proxy.png'
: '../../../icons/status_connected.png'
: '../../../icons/status_connected.png')
states: [

View File

@@ -1,6 +1,6 @@
import QtQuick 2.12
import QtQuick.Controls 2.0
import QtMultimedia 5.6
import QtMultimedia
import org.electrum 1.0
@@ -25,7 +25,7 @@ Item {
VideoOutput {
id: vo
anchors.fill: parent
source: camera
// source: camera
fillMode: VideoOutput.PreserveAspectCrop
Rectangle {
@@ -114,31 +114,41 @@ Item {
}
}
Camera {
id: camera
deviceId: QtMultimedia.defaultCamera.deviceId
viewfinder.resolution: "640x480"
MediaDevices {
id: mediaDevices
}
focus {
focusMode: Camera.FocusContinuous
focusPointMode: Camera.FocusPointCustom
customFocusPoint: Qt.point(0.5, 0.5)
}
CaptureSession {
videoOutput: VideoOutput
function dumpstats() {
console.log(camera.viewfinder.resolution)
console.log(camera.viewfinder.minimumFrameRate)
console.log(camera.viewfinder.maximumFrameRate)
var resolutions = camera.supportedViewfinderResolutions()
resolutions.forEach(function(item, i) {
console.log('' + item.width + 'x' + item.height)
})
// TODO
// pick a suitable resolution from the available resolutions
// problem: some cameras have no supportedViewfinderResolutions
// but still error out when an invalid resolution is set.
// 640x480 seems to be universally available, but this needs to
// be checked across a range of phone models.
camera: Camera {
id: camera
// deviceId: QtMultimedia.defaultCamera.deviceId
cameraDevice: mediaDevices.defaultVideoInput
// TODO QT6
// viewfinder.resolution: "640x480"
// focus {
// focusMode: Camera.FocusContinuous
// focusPointMode: Camera.FocusPointCustom
// customFocusPoint: Qt.point(0.5, 0.5)
// }
function dumpstats() {
console.log(camera.viewfinder.resolution)
console.log(camera.viewfinder.minimumFrameRate)
console.log(camera.viewfinder.maximumFrameRate)
var resolutions = camera.supportedViewfinderResolutions()
resolutions.forEach(function(item, i) {
console.log('' + item.width + 'x' + item.height)
})
// TODO
// pick a suitable resolution from the available resolutions
// problem: some cameras have no supportedViewfinderResolutions
// but still error out when an invalid resolution is set.
// 640x480 seems to be universally available, but this needs to
// be checked across a range of phone models.
}
}
}

View File

@@ -1,12 +1,13 @@
import QtQuick 2.6
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.0
import QtQuick.Controls.Material.impl 2.12
import QtQuick.Window 2.15
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Basic
import QtQuick.Controls.Material
import QtQuick.Controls.Material.impl
import QtQuick.Window
import QtQml 2.6
import QtMultimedia 5.6
import QtQml
import QtMultimedia
import org.electrum 1.0
@@ -27,14 +28,13 @@ ApplicationWindow
Material.accent: Material.LightBlue
font.pixelSize: constants.fontSizeMedium
property Item constants: appconstants
property QtObject constants: appconstants
Constants { id: appconstants }
property alias stack: mainStackView
property variant activeDialogs: []
property bool _wantClose: false
property var _exceptionDialog
property QtObject appMenu: Menu {
@@ -105,7 +105,8 @@ ApplicationWindow
ColumnLayout {
spacing: 0
width: parent.width
anchors.left: parent.left
anchors.right: parent.right
height: toolbar.height
RowLayout {
@@ -171,7 +172,6 @@ ApplicationWindow
RowLayout {
id: statusIconsLayout
anchors.verticalCenter: parent.verticalCenter
Item {
Layout.preferredWidth: constants.paddingLarge
Layout.preferredHeight: 1
@@ -207,9 +207,12 @@ ApplicationWindow
}
}
WalletSummary {
id: walletSummary
Layout.preferredWidth: app.width
// hack to force relayout of toolbar
// since qt6 watchOnlyIndicator.visible doesn't trigger relayout(?)
Item {
Layout.preferredHeight: 1
Layout.topMargin: -1
Layout.preferredWidth: watchOnlyIndicator.visible ? app.width : 1
}
}
}
@@ -218,7 +221,9 @@ ApplicationWindow
id: mainStackView
width: parent.width
height: keyboardFreeZone.height - header.height
initialItem: Qt.resolvedUrl('WalletMainView.qml')
initialItem: Component {
WalletMainView {}
}
function getRoot() {
return mainStackView.get(0)
@@ -454,7 +459,13 @@ ApplicationWindow
}
}
onClosing: {
onClosing: (close) => {
if (AppController.wantClose) {
// destroy most GUI components so that we don't dump so many null reference warnings on exit
app.header.visible = false
mainStackView.clear()
return
}
if (activeDialogs.length > 0) {
var activeDialog = activeDialogs[activeDialogs.length - 1]
if (activeDialog.allowClose) {
@@ -469,22 +480,16 @@ ApplicationWindow
close.accepted = false
stack.pop()
} else {
// destroy most GUI components so that we don't dump so many null reference warnings on exit
if (app._wantClose) {
app.header.visible = false
mainStackView.clear()
} else {
var dialog = app.messageDialog.createObject(app, {
title: qsTr('Close Electrum?'),
yesno: true
})
dialog.accepted.connect(function() {
app._wantClose = true
app.close()
})
dialog.open()
close.accepted = false
}
var dialog = app.messageDialog.createObject(app, {
title: qsTr('Close Electrum?'),
yesno: true
})
dialog.accepted.connect(function() {
AppController.wantClose = true
app.close()
})
dialog.open()
close.accepted = false
}
}