Skip to content

Commit

Permalink
Merge pull request #311 from simelo/Fix_scrolling_issues_v2
Browse files Browse the repository at this point in the history
Fixes #162 fixes #169 scrolling issues v2 AND Errors handling in the QML Engine
  • Loading branch information
olemis committed Jan 12, 2020
2 parents 4773ccb + b86b213 commit 9710a39
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 102 deletions.
18 changes: 5 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,13 @@ func main() {
// url := core.NewQUrl3("qrc:/ui/src/ui/main.qml", 0)
url := core.NewQUrl3("src/ui/main.qml", 0) // disable this to make a release

// TODO: Find a way to use a `core.Qt__QueuedConnection`, so we can remove the flag `allOk`
allOk := true
engine.ConnectObjectCreated(func(object *core.QObject, objUrl *core.QUrl) {
if object.Pointer() == nil && url.ToString(0) == objUrl.ToString(0) {
allOk = false
app.Exit(-1) // Ignored because we need a `core.Qt__QueuedConnection`
engine.ConnectSignal(engine.ConnectObjectCreated, func(object *core.QObject, objUrl *core.QUrl) {
if object.Pointer() == nil && url.ToString(0) == objUrl.ToString(0)[len(objUrl.ToString(0)) - len(url.ToString(0)):] {
app.Exit(-1)
}
})
}, core.Qt__QueuedConnection)
engine.Load(url)
splash.QWidget.Close()

// A `core.Qt__QueuedConnection` will allows us to remove the condition bellow, leaving only `app.Exec()`
if allOk == true {
app.Exec()
} else {
app.Exit(-1)
}
app.Exec()
}
3 changes: 2 additions & 1 deletion src/ui/Delegates/HistoryFilterListDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import "../" // For quick UI development, switch back to resources when making a
Item {
id: root

readonly property real addressListHeight: listViewFilterAddress.height
property alias tristate: checkDelegate.tristate
property alias walletText: checkDelegate.text

clip: true
implicitWidth: width
implicitHeight: height
width: 300
height: checkDelegate.height + columnLayout.spacing + listViewFilterAddress.height

Expand Down
4 changes: 2 additions & 2 deletions src/ui/Delegates/HistoryListDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ ItemDelegate {

ListView {
Layout.alignment: Qt.AlignLeft
height: contentItem.height
height: contentHeight
id: listViewAddresses
model: modelAddresses
delegate: TransactionAddressDelegate {}
delegate: TransactionAddressDelegate {}
}
} // ColumnLayout (main content)

Expand Down
10 changes: 9 additions & 1 deletion src/ui/Delegates/WalletListDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,18 @@ Item {

Label {
id: labelSky
text: sky // a role of the model
text: sky === qsTr("N/A") ? "" : sky // a role of the model
color: Material.accent
horizontalAlignment: Text.AlignRight
Layout.preferredWidth: internalLabelsWidth

BusyIndicator {
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right

implicitWidth: implicitHeight
implicitHeight: parent.height + 10
}
}

Label {
Expand Down
32 changes: 2 additions & 30 deletions src/ui/Dialogs/DialogTransactionDetails.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,9 @@ Dialog {
title: qsTr("Transaction details")
standardButtons: Dialog.Ok

Flickable {
id: flickable
TransactionDetails {
id: transactionDetails
anchors.fill: parent
clip: true
contentHeight: columnLayoutRoot.height

ColumnLayout {
id: columnLayoutRoot
width: parent.width
spacing: 20

TransactionDetails {
id: transactionDetails
implicitWidth: 500
Layout.fillWidth: true
}

Rectangle {
visible: transactionDetails.expanded
height: 1
color: Material.color(Material.Grey)
Layout.fillWidth: true
}
} // ColumnLayout

ScrollIndicator.vertical: ScrollIndicator {
parent: dialogTransactionsDetails.contentItem
anchors.top: flickable.top
anchors.bottom: flickable.bottom
anchors.right: parent.right
anchors.rightMargin: -dialogTransactionsDetails.rightPadding + 1
}
}
}
42 changes: 18 additions & 24 deletions src/ui/HistoryFilterList.qml
Original file line number Diff line number Diff line change
@@ -1,45 +1,39 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.12
import QtQuick.Layouts 1.12
import WalletsManager 1.0

// Resource imports
// import "qrc:/ui/src/ui/Delegates"
import "Delegates/" // For quick UI development, switch back to resources when making a release

Item {
id: root

readonly property alias count: listViewFilters.count
property alias interactive: listViewFilters.interactive
property alias contentHeight: listViewFilters.contentHeight

clip: true
ScrollView {
id: historyFilterDelegate

ListView {
id: listViewFilters

anchors.fill: parent
width: parent.width
spacing: 10

model: modelFilters
delegate: HistoryFilterListDelegate {}
}

ModelManager {
id: modelManager

Component.onCompleted: {
setWalletManager(walletManager)
delegate: HistoryFilterListDelegate {
width: parent.width
}
}

WalletModel {
id: modelFilters
ModelManager {
id: modelManager

Component.onCompleted: {
setWalletManager(walletManager)
}
}
WalletModel {
id: modelFilters

Component.onCompleted: {
loadModel(walletManager.getWallets())
Component.onCompleted: {
loadModel(walletManager.getWallets())
}
}
}
}
}
24 changes: 11 additions & 13 deletions src/ui/PageHistory.qml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ Page {
id: toolTipFilters

anchors.centerIn: Overlay.overlay

readonly property real minimumHeight: Math.min(applicationWindow.height - 100, filter.contentHeight + 150)
width: 300
height: minimumHeight
width: applicationWindow.width > 440 ? 440 - 40 : applicationWindow.width - 40
height: Math.min(applicationWindow.height - 40, filter.contentHeight + header.height + footer.height + topPadding + bottomPadding)

modal: true
standardButtons: Dialog.Close
Expand Down Expand Up @@ -103,15 +101,15 @@ Page {
modal: true
focus: true

date: listTransactions.currentItem !== null ? listTransactions.currentItem.modelDate : ""
status: listTransactions.currentItem !== null ? listTransactions.currentItem.modelStatus : 0
type: listTransactions.currentItem !== null ? listTransactions.currentItem.modelType : 0
amount: listTransactions.currentItem !== null ? listTransactions.currentItem.modelAmount : ""
hoursReceived: listTransactions.currentItem !== null ? listTransactions.currentItem.modelHoursReceived : 1
hoursBurned: listTransactions.currentItem !== null ? listTransactions.currentItem.modelHoursBurned : 1
transactionID: listTransactions.currentItem !== null ? listTransactions.currentItem.modelTransactionID : ""
modelInputs: listTransactions.currentItem !== null ? listTransactions.currentItem.modelInputs : null
modelOutputs: listTransactions.currentItem !== null ? listTransactions.currentItem.modelOutputs : null
date: listTransactions.currentItem ? listTransactions.currentItem.modelDate : ""
status: listTransactions.currentItem ? listTransactions.currentItem.modelStatus : 0
type: listTransactions.currentItem ? listTransactions.currentItem.modelType : 0
amount: listTransactions.currentItem ? listTransactions.currentItem.modelAmount : ""
hoursReceived: listTransactions.currentItem ? listTransactions.currentItem.modelHoursReceived : 1
hoursBurned: listTransactions.currentItem ? listTransactions.currentItem.modelHoursBurned : 1
transactionID: listTransactions.currentItem ? listTransactions.currentItem.modelTransactionID : ""
modelInputs: listTransactions.currentItem ? listTransactions.currentItem.modelInputs : null
modelOutputs: listTransactions.currentItem ? listTransactions.currentItem.modelOutputs : null
}

QTransactionList {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/PageSend.qml
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ Page {
anchors.centerIn: Overlay.overlay
property var walletsAddresses
readonly property real maxHeight: (expanded ? 490 : 340) + (showPasswordField ? 140 : 0)
width: applicationWindow.width > 640 ? 640 - 40 : applicationWindow.width - 40
height: applicationWindow.height > maxHeight ? maxHeight - 40 : applicationWindow.height - 40
width: applicationWindow.width > 640 - 40 ? 640 - 40 : applicationWindow.width - 40
height: applicationWindow.height > maxHeight - 40 ? maxHeight - 40 : applicationWindow.height - 40
Behavior on height { NumberAnimation { duration: 1000; easing.type: Easing.OutQuint } }

modal: true
Expand Down
26 changes: 10 additions & 16 deletions src/ui/TransactionDetails.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ Item {
Internal
}

implicitHeight: 80 + rowLayoutBasicDetails.height + (expanded ? rowLayoutMoreDetails.height : 0)
readonly property real basicHeight: 80 + rowLayoutBasicDetails.height
implicitHeight: Math.min(basicHeight + (expanded ? Math.max(listViewInputs.height, listViewOutputs.height) : 0), maxHeight)
Behavior on implicitHeight { NumberAnimation { duration: 1000; easing.type: Easing.OutQuint } }

implicitWidth: 600
clip: true

ColumnLayout {
Expand Down Expand Up @@ -129,7 +129,7 @@ Item {
Layout.fillWidth: true
}
Label {
text: (type === TransactionDetails.Type.Receive ? "Receive" : "Send") + ' ' + amount + ' ' + qsTr("SKY")
text: (type === TransactionDetails.Type.Receive ? qsTr("Receive") : qsTr("Send")) + ' ' + amount + ' ' + qsTr("SKY")
font.bold: true
font.pointSize: Qt.application.font.pointSize * 1.15
horizontalAlignment: Label.AlignHCenter
Expand All @@ -149,7 +149,7 @@ Item {
implicitWidth: 200
flat: true
checkable: true
text: (checked ? qsTr("Less") : qsTr("More")) + ' ' + qsTr("details")
text: checked ? qsTr("Less details") : qsTr("More details")
}

Rectangle {
Expand All @@ -165,14 +165,15 @@ Item {

Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
Layout.fillHeight: true

opacity: expanded ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 1000; easing.type: Easing.OutQuint } }

ColumnLayout {
id: columnLayoutInputs
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
Layout.fillHeight: true

Label {
text: qsTr("Inputs")
Expand All @@ -184,18 +185,14 @@ Item {
ScrollView {
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true

contentHeight: listViewInputs.height
Layout.fillHeight: true

ListView {
id: listViewInputs

Material.foreground: Material.Grey
height: contentHeight
model: modelInputs
clip: true
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
delegate: InputOutputDelegate {
width: parent.width
}
Expand All @@ -205,8 +202,8 @@ Item {

ColumnLayout {
id: columnLayoutOutputs
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
Layout.fillHeight: true

Label {
text: qsTr("Outputs")
Expand All @@ -218,18 +215,15 @@ Item {
ScrollView {
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true

contentHeight: listViewInputs.height
Layout.fillHeight: true
Component.onCompleted: console.log("LALALALA", width, height, contentWidth, contentHeight)

ListView {
id: listViewOutputs

Material.foreground: Material.Grey
height: contentHeight
model: modelOutputs
clip: true
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
delegate: InputOutputDelegate {
width: parent.width
}
Expand Down

0 comments on commit 9710a39

Please sign in to comment.