GODT-1468: Fix main windows status and add background context without retry.

This commit is contained in:
Jakub
2021-12-13 12:29:49 +01:00
parent 3bb9146d9f
commit d40fbda2ab
12 changed files with 101 additions and 112 deletions

View File

@ -36,12 +36,27 @@ Item {
if (root.usedFraction < .75) return root.colorScheme.signal_warning
return root.colorScheme.signal_danger
}
property real usedFraction: root.user && root.user.totalBytes ? Math.abs(root.user.usedBytes / root.user.totalBytes) : 0
property string totalSpace: root.spaceWithUnits(root.user ? root.user.totalBytes : 0)
property string usedSpace: root.spaceWithUnits(root.user ? root.user.usedBytes : 0)
property real usedFraction: root.user ? reasonableFracion(root.user.usedBytes, root.user.totalBytes) : 0
property string totalSpace: root.spaceWithUnits(root.user ? root.reasonableBytes(root.user.totalBytes) : 0)
property string usedSpace: root.spaceWithUnits(root.user ? root.reasonableBytes(root.user.usedBytes) : 0)
function reasonableFracion(used, total){
var usedSafe = root.reasonableBytes(used)
var totalSafe = root.reasonableBytes(total)
if (totalSafe == 0 || usedSafe == 0) return 0
if (totalSafe <= usedSafe) return 1
return usedSafe / totalSafe
}
function reasonableBytes(bytes){
var safeBytes = bytes+0
if (safeBytes != bytes) return 0
if (safeBytes < 0) return 0
return Math.ceil(safeBytes)
}
function spaceWithUnits(bytes){
if (bytes*1 !== bytes ) return "0 kB"
if (bytes*1 !== bytes || bytes == 0 ) return "0 kB"
var units = ['B',"kB", "MB", "GB", "TB"];
var i = parseInt(Math.floor(Math.log(bytes)/Math.log(1024)));

View File

@ -242,7 +242,7 @@ Window {
// add one user on start
var haveUserOnStart = false
var haveUserOnStart = true
if (haveUserOnStart) {
var newUserObject = root.userComponent.createObject(root)
newUserObject.username = "LerooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooyJenkins@protonmail.com"
@ -808,7 +808,7 @@ Window {
signal userDisconnected(string username)
signal apiCertIssue()
property bool showSplashScreen: true
property bool showSplashScreen: false
function login(username, password) {

View File

@ -20,6 +20,7 @@ import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import Proton 4.0
import Notifications 1.0
Item {
id: root
@ -59,12 +60,16 @@ Item {
spacing: 0
Status {
colorScheme: leftBar.colorScheme
Layout.leftMargin: 16
Layout.topMargin: 24
Layout.bottomMargin: 17
Layout.alignment: Qt.AlignHCenter
colorScheme: leftBar.colorScheme
backend: root.backend
notifications: root.notifications
notificationWhitelist: Notifications.Group.Connection | Notifications.Group.ForceUpdate
}
// just a placeholder

View File

@ -37,10 +37,11 @@ QtObject {
signal askDeleteAccount(var user)
enum Group {
Connection = 1,
Update = 2,
Connection = 1,
Update = 2,
Configuration = 4,
API = 32,
ForceUpdate = 8,
API = 32,
// Special group for notifications that require dialog popup instead of banner
Dialogs = 64
@ -201,7 +202,7 @@ QtObject {
brief: qsTr("Bridge is outdated")
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Danger
group: Notifications.Group.Update | Notifications.Group.Dialogs
group: Notifications.Group.Update | Notifications.Group.ForceUpdate | Notifications.Group.Dialogs
Connections {
target: root.backend

View File

@ -59,19 +59,19 @@ Item {
label.text = topmost.brief
switch (topmost.type) {
case Notification.NotificationType.Danger:
case Notification.NotificationType.Danger:
image.color = root.colorScheme.signal_danger
label.color = root.colorScheme.signal_danger
break;
case Notification.NotificationType.Warning:
case Notification.NotificationType.Warning:
image.color = root.colorScheme.signal_warning
label.color = root.colorScheme.signal_warning
break;
case Notification.NotificationType.Success:
case Notification.NotificationType.Success:
image.color = root.colorScheme.signal_success
label.color = root.colorScheme.signal_success
break;
case Notification.NotificationType.Info:
case Notification.NotificationType.Info:
image.color = root.colorScheme.signal_info
label.color = root.colorScheme.signal_info
break;
@ -85,8 +85,12 @@ Item {
ColorImage {
id: image
Layout.fillHeight: true
width: 16
height: 16
sourceSize.width: width
sourceSize.height: height
source: "./icons/ic-connected.svg"
color: root.colorScheme.signal_success
}
Label {
@ -100,88 +104,9 @@ Item {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
text: qsTr("Connected")
color: root.colorScheme.signal_success
}
}
state: "Connected"
states: [
State {
name: "Connected"
PropertyChanges {
target: image
source: "./icons/ic-connected.svg"
color: ProtonStyle.currentStyle.signal_success
}
PropertyChanges {
target: label
text: qsTr("Connected")
color: ProtonStyle.currentStyle.signal_success
}
},
State {
name: "No connection"
PropertyChanges {
target: image
source: "./icons/ic-no-connection.svg"
color: ProtonStyle.currentStyle.signal_danger
}
PropertyChanges {
target: label
text: qsTr("No connection")
color: ProtonStyle.currentStyle.signal_danger
}
},
State {
name: "Outdated"
PropertyChanges {
target: image
source: "./icons/ic-exclamation-circle-filled.svg"
color: ProtonStyle.currentStyle.signal_danger
}
PropertyChanges {
target: label
text: qsTr("Bridge is outdated")
color: ProtonStyle.currentStyle.signal_danger
}
},
State {
name: "Account changed"
PropertyChanges {
target: image
source: "./icons/ic-exclamation-circle-filled.svg"
color: ProtonStyle.currentStyle.signal_danger
}
PropertyChanges {
target: label
text: qsTr("The address list for your account has changed")
color: ProtonStyle.currentStyle.signal_danger
}
},
State {
name: "Auto update failed"
PropertyChanges {
target: image
source: "./icons/ic-info-circle-filled.svg"
color: ProtonStyle.currentStyle.signal_info
}
PropertyChanges {
target: label
text: qsTr("Bridge couldnt update automatically")
color: ProtonStyle.currentStyle.signal_info
}
},
State {
name: "Update ready"
PropertyChanges {
target: image
source: "./icons/ic-info-circle-filled.svg"
color: ProtonStyle.currentStyle.signal_info
}
PropertyChanges {
target: label
text: qsTr("Bridge update is ready")
color: ProtonStyle.currentStyle.signal_info
}
}
]
}