big refactoring of API system

This commit is contained in:
Blue 2024-01-20 18:17:21 -03:00
parent 27124380e4
commit 7a116bfdf2
Signed by: blue
GPG key ID: 9B203B252A63EE38
37 changed files with 1060 additions and 534 deletions

View file

@ -5,7 +5,7 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import magpie.Models as Models
import magpie
import magpie.Components as Components
Item {
@ -28,9 +28,11 @@ Item {
id: listView
Layout.fillHeight: true
Layout.fillWidth: true
model: Models.Assets
model: Magpie.assets
spacing: 5
delegate: Components.AssetLine {
height: 20
width: listView.width
}
}
}

View file

@ -4,23 +4,50 @@
import QtQuick
import QtQuick.Controls
Rectangle {
Item {
id: line
required property string title
required property string icon
required property color color
required property string balance
Row {
readonly property int iconSize: height
readonly property int freespace: width - iconSize - spacing * children.length - 1
anchors.fill: parent
IconLabel {
anchors.verticalCenter: parent.verticalCenter
icon.name: line.icon
width: parent.height
height: parent.height
spacing: 5
Rectangle {
width: parent.iconSize
height: parent.iconSize
color: line.color
IconLabel {
anchors.fill: parent
icon {
name: line.icon
width: width
height: height
}
}
}
Text {
anchors.verticalCenter: parent.verticalCenter
width: parent.freespace / 2
height: parent.height
text: title
verticalAlignment: Text.AlignVCenter
color: palette.text
font.bold: true
}
Text {
width: parent.freespace / 2
height: parent.height
text: balance
verticalAlignment: Text.AlignVCenter
color: palette.text
}
}
}

View file

@ -4,7 +4,7 @@
import QtQuick
import QtQuick.Controls
import magpie.API
import magpie
import magpie.Components as Components
Item {

View file

@ -4,7 +4,7 @@
import QtQuick
import QtQuick.Controls
import magpie.API
import magpie
import magpie.Components as Components
Column {

View file

@ -4,7 +4,7 @@
import QtQuick
import QtQuick.Controls
import magpie.API
import magpie
import magpie.Components as Components
Column {

View file

@ -5,7 +5,7 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import magpie.API
import magpie
import magpie.Components as Components
Page {

View file

@ -5,7 +5,7 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import magpie.API
import magpie
import magpie.Forms as Forms
import magpie.Components as Components
@ -44,7 +44,7 @@ Page {
}
Label {
horizontalAlignment: Label.AlignLeft
text: API.state === API.NoServer ? qsTr("choose") : API.address
text: Magpie.state === Magpie.NoServer ? qsTr("choose") : Magpie.address
font {
italic: true
underline: true
@ -52,20 +52,20 @@ Page {
MouseArea {
anchors.fill: parent
onClicked: pickServer(API.address)
onClicked: pickServer(Magpie.address)
}
}
}
Components.Modal {
inProgress: API.state === API.Authenticating
visible: !priv.loggingIn && API.state === API.Authenticating
closable: API.state === API.NotAuthenticated
status: "Logging into " + API.address + "..."
inProgress: Magpie.state === Magpie.Authenticating
visible: !priv.loggingIn && Magpie.state === Magpie.Authenticating
closable: Magpie.state === Magpie.NotAuthenticated
status: "Logging into " + Magpie.address + "..."
}
Item {
visible: priv.loggingIn || API.state === API.NotAuthenticated || API.state === API.Authenticating
visible: priv.loggingIn || Magpie.state === Magpie.NotAuthenticated || Magpie.state === Magpie.Authenticating
width: page.width
height: stack.currentItem ? stack.currentItem.implicitHeight: 0

View file

@ -7,7 +7,7 @@ import QtQuick.Controls
import QtQuick.Layouts
import QtCore
import magpie.API
import magpie
import magpie.Application as Application
ApplicationWindow {
@ -35,7 +35,7 @@ ApplicationWindow {
Component {
id: serverPick
ServerPick {
address: API.address
address: Magpie.address
onBack: stack.pop()
StackView.onActivating: pickingServer = true;
StackView.onDeactivating: pickingServer = false;
@ -52,15 +52,15 @@ ApplicationWindow {
}
Connections {
target: API
target: Magpie
function onAddressChanged (url) {
if (pickingServer && url.toString().length > 0)
stack.pop()
}
function onStateChanged (state) {
if (state === API.Authenticated)
if (state === Magpie.Authenticated)
stack.push(app);
else if (runningApp && state === API.NotAuthenticated)
else if (runningApp && state === Magpie.NotAuthenticated)
stack.pop();
}
}