mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 15:46:44 +00:00
GODT-22: Facelift
- GODT-1199: Add menu to status window - GODT-22: use ColorImage instead of IconLabel - GODT-22: remove banners from MainWindow - GODT-1199: Fix separator width - GODT-1199: Fix StatusWindow button position - GODT-1198: Open main window on startup if no users - GODT-1199: Fix avatar text color - GODT-1198: refactor main window layout - GODT-22: add missing components to qmldir - GODT-22: refactor components having Layout as root item - GODT-22: add more user controls - GODT-1199: Add status window resize and maximum height - GODT-22: WIP: notification arch - GODT-22: Notifications WIP - GODT-22: Fix notification filter, topmost notification - GODT-1199: Add notifications to status window - GODT-22: Add strict typization to colorScheme variable - GODT-1198: WIP Notifications, dialogs and banners - GODT-22: Add backend notifications (Banners & Dialogs) D
This commit is contained in:
49
internal/frontend/qml/Notifications/Notification.qml
Normal file
49
internal/frontend/qml/Notifications/Notification.qml
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright (c) 2021 Proton Technologies AG
|
||||
//
|
||||
// This file is part of ProtonMail Bridge.
|
||||
//
|
||||
// ProtonMail Bridge is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ProtonMail Bridge is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import QtQml 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
|
||||
QtObject {
|
||||
id: root
|
||||
|
||||
default property var children
|
||||
|
||||
enum NotificationType {
|
||||
Info = 0,
|
||||
Success = 1,
|
||||
Warning = 2,
|
||||
Danger = 3
|
||||
}
|
||||
|
||||
property string text
|
||||
property string description
|
||||
property string icon
|
||||
property list<Action> action
|
||||
property int type
|
||||
property int group
|
||||
|
||||
property bool dismissed: false
|
||||
property bool active: false
|
||||
readonly property var occurred: active ? new Date() : undefined
|
||||
|
||||
property var data
|
||||
|
||||
onActiveChanged: {
|
||||
dismissed = false
|
||||
}
|
||||
}
|
||||
114
internal/frontend/qml/Notifications/NotificationFilter.qml
Normal file
114
internal/frontend/qml/Notifications/NotificationFilter.qml
Normal file
@ -0,0 +1,114 @@
|
||||
// Copyright (c) 2021 Proton Technologies AG
|
||||
//
|
||||
// This file is part of ProtonMail Bridge.
|
||||
//
|
||||
// ProtonMail Bridge is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ProtonMail Bridge is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import QtQml 2.12
|
||||
import QtQml.Models 2.12
|
||||
|
||||
// contains notifications that satisfy black- and whitelist and are sorted in time-occurred order
|
||||
ListModel {
|
||||
id: root
|
||||
|
||||
enum FilterConsts {
|
||||
None = 0,
|
||||
All = 255
|
||||
}
|
||||
|
||||
property int whitelist: NotificationFilter.FilterConsts.All
|
||||
property int blacklist: NotificationFilter.FilterConsts.None
|
||||
|
||||
property Notification topmost
|
||||
property var source
|
||||
|
||||
property bool componentCompleted: false
|
||||
Component.onCompleted: {
|
||||
root.componentCompleted = true
|
||||
root.rebuildList()
|
||||
}
|
||||
|
||||
// overriding get method to ignore any role and return directly object itself
|
||||
function get(row) {
|
||||
if (row < 0 || row >= count) {
|
||||
return undefined
|
||||
}
|
||||
return data(index(row, 0), Qt.DisplayRole)
|
||||
}
|
||||
|
||||
function rebuildList() {
|
||||
// avoid evaluation of the list before Component.onCompleted
|
||||
if (!root.componentCompleted) {
|
||||
return
|
||||
}
|
||||
|
||||
for (var i = 0; i < root.count; i++) {
|
||||
root.get(i).onActiveChanged.disconnect( root.updateList )
|
||||
}
|
||||
|
||||
root.clear()
|
||||
|
||||
if (!root.source) {
|
||||
return
|
||||
}
|
||||
|
||||
for (i = 0; i < root.source.length; i++) {
|
||||
var obj = root.source[i]
|
||||
if (obj.group & root.blacklist) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (!(obj.group & root.whitelist)) {
|
||||
continue
|
||||
}
|
||||
|
||||
root.append({obj})
|
||||
obj.onActiveChanged.connect( root.updateList )
|
||||
}
|
||||
}
|
||||
|
||||
function updateList() {
|
||||
var topmost = null
|
||||
|
||||
for (var i = 0; i < root.count; i++) {
|
||||
var obj = root.get(i)
|
||||
|
||||
if (!obj.active) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (topmost && (topmost.type > obj.type)) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (topmost && (topmost.type === obj.type) && (topmost.occurred > obj.occurred)) {
|
||||
continue
|
||||
}
|
||||
|
||||
topmost = obj
|
||||
}
|
||||
|
||||
root.topmost = topmost
|
||||
}
|
||||
|
||||
onWhitelistChanged: {
|
||||
root.rebuildList()
|
||||
}
|
||||
onBlacklistChanged: {
|
||||
root.rebuildList()
|
||||
}
|
||||
onSourceChanged: {
|
||||
root.rebuildList()
|
||||
}
|
||||
}
|
||||
428
internal/frontend/qml/Notifications/Notifications.qml
Normal file
428
internal/frontend/qml/Notifications/Notifications.qml
Normal file
@ -0,0 +1,428 @@
|
||||
// Copyright (c) 2021 Proton Technologies AG
|
||||
//
|
||||
// This file is part of ProtonMail Bridge.
|
||||
//
|
||||
// ProtonMail Bridge is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ProtonMail Bridge is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import QtQml 2.12
|
||||
import Qt.labs.platform 1.1
|
||||
import QtQuick.Controls 2.12
|
||||
import ".."
|
||||
|
||||
QtObject {
|
||||
id: root
|
||||
|
||||
property var backend
|
||||
|
||||
property MainWindow frontendMain
|
||||
property StatusWindow frontendStatus
|
||||
property SystemTrayIcon frontendTray
|
||||
|
||||
enum Group {
|
||||
Connection = 1,
|
||||
Update = 2,
|
||||
Configuration = 4,
|
||||
API = 32,
|
||||
|
||||
// Special group for notifications that require dialog popup instead of banner
|
||||
Dialogs = 64
|
||||
}
|
||||
|
||||
property var all: [
|
||||
root.noInternet,
|
||||
root.updateManualReady,
|
||||
root.updateManualRestartNeeded,
|
||||
root.updateManualError,
|
||||
root.updateForce,
|
||||
root.updateForceError,
|
||||
root.updateSilentRestartNeeded,
|
||||
root.updateSilentError,
|
||||
root.bugReportSendSuccess,
|
||||
root.bugReportSendError,
|
||||
root.cacheAnavailable,
|
||||
root.cacheCantMove,
|
||||
root.accountChanged,
|
||||
root.diskFull
|
||||
]
|
||||
|
||||
// Connection
|
||||
property Notification noInternet: Notification {
|
||||
text: qsTr("No connection")
|
||||
icon: "./icons/ic-no-connection.svg"
|
||||
type: Notification.NotificationType.Danger
|
||||
group: Notifications.Group.Connection
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
|
||||
onInternetOff: {
|
||||
root.noInternet.active = true
|
||||
}
|
||||
onInternetOn: {
|
||||
root.noInternet.active = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Updates
|
||||
property Notification updateManualReady: Notification {
|
||||
text: qsTr("Update to Bridge") + " " + (data ? data.version : "")
|
||||
description: qsTr("A new version of ProtonMail Bridge is available. See what's changed.")
|
||||
icon: "./icons/ic-info-circle-filled.svg"
|
||||
type: Notification.NotificationType.Info
|
||||
group: Notifications.Group.Update | Notifications.Group.Dialogs
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
onUpdateManualReady: {
|
||||
root.updateManualReady.data = { version: version }
|
||||
root.updateManualReady.active = true
|
||||
}
|
||||
}
|
||||
|
||||
action: [
|
||||
Action {
|
||||
text: qsTr("Update")
|
||||
|
||||
onTriggered: {
|
||||
// TODO: call update from backend
|
||||
root.updateManualReady.active = false
|
||||
}
|
||||
},
|
||||
Action {
|
||||
text: qsTr("Remind me later")
|
||||
|
||||
onTriggered: {
|
||||
// TODO: start timer here
|
||||
root.updateManualReady.active = false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
property Notification updateManualRestartNeeded: Notification {
|
||||
text: qsTr("Bridge update is ready")
|
||||
icon: "./icons/ic-info-circle-filled.svg"
|
||||
type: Notification.NotificationType.Info
|
||||
group: Notifications.Group.Update
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
onUpdateManualRestartNeeded: {
|
||||
root.updateManualRestartNeeded.active = true
|
||||
}
|
||||
}
|
||||
|
||||
action: Action {
|
||||
text: qsTr("Restart Bridge")
|
||||
|
||||
onTriggered: {
|
||||
// TODO
|
||||
root.updateManualRestartNeeded.active = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property Notification updateManualError: Notification {
|
||||
text: qsTr("Bridge couldn’t update")
|
||||
icon: "./icons/ic-exclamation-circle-filled.svg"
|
||||
type: Notification.NotificationType.Warning
|
||||
group: Notifications.Group.Update
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
onUpdateManualError: {
|
||||
root.updateManualError.active = true
|
||||
}
|
||||
}
|
||||
|
||||
action: Action {
|
||||
text: qsTr("Update manually")
|
||||
|
||||
onTriggered: {
|
||||
// TODO
|
||||
root.updateManualError.active = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property Notification updateForce: Notification {
|
||||
text: qsTr("Update to ProtonMail Bridge") + " " + (data ? data.version : "")
|
||||
description: qsTr("This version of Bridge is no longer supported, please update. Learn why. To update manually, go to: https:/protonmail.com/bridge/download")
|
||||
icon: "./icons/ic-exclamation-circle-filled.svg"
|
||||
type: Notification.NotificationType.Danger
|
||||
group: Notifications.Group.Update | Notifications.Group.Dialogs
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
|
||||
onUpdateForce: {
|
||||
root.updateForce.data = { version: version }
|
||||
root.updateForce.active = true
|
||||
}
|
||||
}
|
||||
|
||||
action: [
|
||||
Action {
|
||||
text: qsTr("Update")
|
||||
|
||||
onTriggered: {
|
||||
// TODO: trigger update here
|
||||
root.updateForce.active = false
|
||||
}
|
||||
},
|
||||
Action {
|
||||
text: qsTr("Quite Bridge")
|
||||
|
||||
onTriggered: {
|
||||
// TODO: quit Bridge here
|
||||
root.updateForce.active = false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
property Notification updateForceError: Notification {
|
||||
text: qsTr("Bridge coudn’t update")
|
||||
description: qsTr("You must update manually. Go to: https:/protonmail.com/bridge/download")
|
||||
icon: "./icons/ic-exclamation-circle-filled.svg"
|
||||
type: Notification.NotificationType.Danger
|
||||
group: Notifications.Group.Update | Notifications.Group.Dialogs
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
|
||||
onUpdateForceError: {
|
||||
root.updateForceError.active = true
|
||||
}
|
||||
}
|
||||
|
||||
action: [
|
||||
Action {
|
||||
text: qsTr("Update manually")
|
||||
|
||||
onTriggered: {
|
||||
// TODO: trigger update here
|
||||
root.updateForceError.active = false
|
||||
}
|
||||
},
|
||||
Action {
|
||||
text: qsTr("Quite Bridge")
|
||||
|
||||
onTriggered: {
|
||||
// TODO: quit Bridge here
|
||||
root.updateForce.active = false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
property Notification updateSilentRestartNeeded: Notification {
|
||||
text: qsTr("Bridge update is ready")
|
||||
icon: "./icons/ic-info-circle-filled.svg"
|
||||
type: Notification.NotificationType.Info
|
||||
group: Notifications.Group.Update
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
onUpdateSilentRestartNeeded: {
|
||||
root.updateSilentRestartNeeded.active = true
|
||||
}
|
||||
}
|
||||
|
||||
action: Action {
|
||||
text: qsTr("Restart Bridge")
|
||||
|
||||
onTriggered: {
|
||||
// TODO
|
||||
root.updateSilentRestartNeeded.active = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property Notification updateSilentError: Notification {
|
||||
text: qsTr("Bridge couldn’t update")
|
||||
icon: "./icons/ic-exclamation-circle-filled.svg"
|
||||
type: Notification.NotificationType.Warning
|
||||
group: Notifications.Group.Update
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
onUpdateSilentError: {
|
||||
root.updateSilentError.active = true
|
||||
}
|
||||
}
|
||||
|
||||
action: Action {
|
||||
text: qsTr("Update manually")
|
||||
|
||||
onTriggered: {
|
||||
// TODO
|
||||
root.updateSilentError.active = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bug reports
|
||||
property Notification bugReportSendSuccess: Notification {
|
||||
text: qsTr("Bug report sent")
|
||||
description: qsTr("We’ve received your report, thank you! Our team will get back to you as soon as we can.")
|
||||
type: Notification.NotificationType.Success
|
||||
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
onBugReportSendSuccess: {
|
||||
root.bugReportSendSuccess.active = true
|
||||
}
|
||||
}
|
||||
|
||||
action: [
|
||||
Action {
|
||||
text: qsTr("Ok")
|
||||
onTriggered: {
|
||||
root.bugReportSendSuccess.active = false
|
||||
}
|
||||
},
|
||||
Action {
|
||||
text: "test"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
property Notification bugReportSendError: Notification {
|
||||
text: qsTr("There was a problem")
|
||||
description: qsTr("There was a problem with sending your report. Please try again later or contact us directly at security@protonmail.com")
|
||||
type: Notification.NotificationType.Warning
|
||||
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
onBugReportSendError: {
|
||||
root.bugReportSendError.active = true
|
||||
}
|
||||
}
|
||||
|
||||
action: Action {
|
||||
text: qsTr("Ok")
|
||||
onTriggered: {
|
||||
root.bugReportSendError.active = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cache
|
||||
property Notification cacheAnavailable: Notification {
|
||||
text: qsTr("Cache location is unavailable")
|
||||
description: qsTr("Check the directory or change it in your settings.")
|
||||
type: Notification.NotificationType.Warning
|
||||
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
onCacheAnavailable: {
|
||||
root.cacheAnavailable.active = true
|
||||
}
|
||||
}
|
||||
|
||||
action: [
|
||||
Action {
|
||||
text: qsTr("Quit Bridge")
|
||||
onTriggered: {
|
||||
root.cacheAnavailable.active = false
|
||||
}
|
||||
},
|
||||
Action {
|
||||
text: qsTr("Change location")
|
||||
onTriggered: {
|
||||
root.cacheAnavailable.active = false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
property Notification cacheCantMove: Notification {
|
||||
text: qsTr("Can’t move cache")
|
||||
description: qsTr("The location you have selected is not available. Make sure you have enough free space or choose another location.")
|
||||
type: Notification.NotificationType.Warning
|
||||
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
onCacheCantMove: {
|
||||
root.cacheCantMove.active = true
|
||||
}
|
||||
}
|
||||
|
||||
action: [
|
||||
Action {
|
||||
text: qsTr("Cancel")
|
||||
onTriggered: {
|
||||
root.cacheCantMove.active = false
|
||||
}
|
||||
},
|
||||
Action {
|
||||
text: qsTr("Change location")
|
||||
onTriggered: {
|
||||
root.cacheCantMove.active = false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// Other
|
||||
property Notification accountChanged: Notification {
|
||||
text: qsTr("The address list for your account has changed")
|
||||
icon: "./icons/ic-exclamation-circle-filled.svg"
|
||||
type: Notification.NotificationType.Danger
|
||||
group: Notifications.Group.Configuration
|
||||
|
||||
action: Action {
|
||||
text: qsTr("Reconfigure")
|
||||
|
||||
onTriggered: {
|
||||
// TODO: open configuration window here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property Notification diskFull: Notification {
|
||||
text: qsTr("Your disk is almost full")
|
||||
description: qsTr("Quit Bridge and free disk space or disable the local cache (not recommended).")
|
||||
type: Notification.NotificationType.Warning
|
||||
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
onDiskFull: {
|
||||
root.diskFull.active = true
|
||||
}
|
||||
}
|
||||
|
||||
action: [
|
||||
Action {
|
||||
text: qsTr("Quit Bridge")
|
||||
onTriggered: {
|
||||
root.diskFull.active = false
|
||||
}
|
||||
},
|
||||
Action {
|
||||
text: qsTr("Settings")
|
||||
onTriggered: {
|
||||
root.diskFull.active = false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
6
internal/frontend/qml/Notifications/qmldir
Normal file
6
internal/frontend/qml/Notifications/qmldir
Normal file
@ -0,0 +1,6 @@
|
||||
module Notifications
|
||||
depends QtQml 2.12
|
||||
|
||||
Notifications 1.0 Notifications.qml
|
||||
NotificationFilter 1.0 NotificationFilter.qml
|
||||
Notification 1.0 Notification.qml
|
||||
Reference in New Issue
Block a user