2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-05-11 21:24:08 +00:00
|
|
|
import Qt.labs.platform 1.1
|
2020-06-04 07:38:24 +00:00
|
|
|
import QtQml.StateMachine 1.14 as DSM
|
2020-06-23 20:49:04 +00:00
|
|
|
import Qt.labs.settings 1.0
|
2020-07-10 21:47:31 +00:00
|
|
|
import QtQuick.Window 2.12
|
2020-06-23 20:49:04 +00:00
|
|
|
import QtQml 2.13
|
2020-07-12 16:47:46 +00:00
|
|
|
import QtQuick.Window 2.0
|
feat: Support system dark mode theme
Supports system dark mode. Changes the user appearance setting to a 3-way setting of System, Light, Dark.
New accounts will have their appearance setting set to "System", which uses the system setting to determine if dark mode should be applied.
Breaking change: Users who had their settings on Light Theme, will now get the system theme (light or dark). Users who had their theme set to Dark, will now get the Light theme.
At startup, the onboarding screens will have the system-level setting of dark mode applied or not. Once, logged in, the user settings will be applied.
## Note
An appearance setting of "System" is not dynamic to the system-level setting. This means that if a user has "System" set for their appearance (and ie, the user has light mode set), and then user then changes their system setting from light to dark, the app will not respond until it is restarted. This is due to a limitation of Qt not having a reliable way to propagate these changes to QML.
2020-09-29 06:18:00 +00:00
|
|
|
import QtQuick.Controls.Universal 2.12
|
2020-07-12 16:47:46 +00:00
|
|
|
|
2021-05-19 14:03:14 +00:00
|
|
|
import DotherSide 0.1
|
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import utils 1.0
|
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
|
2021-10-12 18:26:02 +00:00
|
|
|
import "./app/AppLayouts/Onboarding/views"
|
2020-05-13 02:51:26 +00:00
|
|
|
import "./app"
|
2020-05-11 21:24:08 +00:00
|
|
|
|
2021-05-19 14:03:14 +00:00
|
|
|
StatusWindow {
|
2021-10-22 10:59:18 +00:00
|
|
|
property bool hasAccounts: startupModule.appState !== Constants.appState.onboarding
|
2021-02-18 19:14:31 +00:00
|
|
|
property bool removeMnemonicAfterLogin: false
|
2021-03-10 04:59:01 +00:00
|
|
|
property alias dragAndDrop: dragTarget
|
2021-04-07 13:59:42 +00:00
|
|
|
property bool popupOpened: false
|
2021-07-07 17:44:59 +00:00
|
|
|
property bool displayBeforeGetStartedModal: !hasAccounts
|
2020-06-23 20:49:04 +00:00
|
|
|
|
feat: Support system dark mode theme
Supports system dark mode. Changes the user appearance setting to a 3-way setting of System, Light, Dark.
New accounts will have their appearance setting set to "System", which uses the system setting to determine if dark mode should be applied.
Breaking change: Users who had their settings on Light Theme, will now get the system theme (light or dark). Users who had their theme set to Dark, will now get the Light theme.
At startup, the onboarding screens will have the system-level setting of dark mode applied or not. Once, logged in, the user settings will be applied.
## Note
An appearance setting of "System" is not dynamic to the system-level setting. This means that if a user has "System" set for their appearance (and ie, the user has light mode set), and then user then changes their system setting from light to dark, the app will not respond until it is restarted. This is due to a limitation of Qt not having a reliable way to propagate these changes to QML.
2020-09-29 06:18:00 +00:00
|
|
|
Universal.theme: Universal.System
|
|
|
|
|
2020-05-11 21:24:08 +00:00
|
|
|
id: applicationWindow
|
2021-08-12 11:52:04 +00:00
|
|
|
objectName: "mainWindow"
|
2021-04-08 15:44:58 +00:00
|
|
|
minimumWidth: 900
|
2020-11-18 14:01:09 +00:00
|
|
|
minimumHeight: 600
|
2021-11-26 12:58:15 +00:00
|
|
|
width: localAppSettings.appWidth
|
|
|
|
height: localAppSettings.appHeight
|
2020-07-13 18:45:54 +00:00
|
|
|
color: Style.current.background
|
2020-06-23 20:49:04 +00:00
|
|
|
title: {
|
|
|
|
// Set application settings
|
2020-09-04 16:07:11 +00:00
|
|
|
//% "Status Desktop"
|
|
|
|
Qt.application.name = qsTrId("status-desktop")
|
2020-06-23 20:49:04 +00:00
|
|
|
Qt.application.organization = "Status"
|
|
|
|
Qt.application.domain = "status.im"
|
|
|
|
return Qt.application.name
|
|
|
|
}
|
2020-05-11 21:24:08 +00:00
|
|
|
visible: true
|
2020-05-18 15:07:30 +00:00
|
|
|
|
2021-11-26 12:58:15 +00:00
|
|
|
function storeWidth() {
|
|
|
|
localAppSettings.appWidth = width
|
|
|
|
}
|
|
|
|
|
|
|
|
function storeHeight() {
|
|
|
|
localAppSettings.appHeight = height
|
|
|
|
}
|
|
|
|
|
|
|
|
onWidthChanged: Qt.callLater(storeWidth)
|
|
|
|
onHeightChanged: Qt.callLater(storeHeight)
|
|
|
|
|
2020-11-17 03:07:01 +00:00
|
|
|
Action {
|
|
|
|
shortcut: StandardKey.FullScreen
|
|
|
|
onTriggered: {
|
|
|
|
if (visibility === Window.FullScreen) {
|
|
|
|
showNormal()
|
|
|
|
} else {
|
|
|
|
showFullScreen()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Action {
|
|
|
|
shortcut: "Ctrl+M"
|
|
|
|
onTriggered: {
|
|
|
|
if (visibility === Window.Minimized) {
|
|
|
|
showNormal()
|
|
|
|
} else {
|
|
|
|
showMinimized()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-21 15:29:33 +00:00
|
|
|
|
2021-01-29 03:00:33 +00:00
|
|
|
Action {
|
|
|
|
shortcut: "Ctrl+W"
|
2021-11-10 12:48:22 +00:00
|
|
|
enabled: loader.item && !!loader.item.appLayout? loader.item.appLayout.appView.currentIndex === Constants.appViewStackIndex.browser
|
2021-04-20 20:15:16 +00:00
|
|
|
: true
|
2021-02-22 17:26:24 +00:00
|
|
|
onTriggered: {
|
|
|
|
applicationWindow.visible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Action {
|
|
|
|
shortcut: "Ctrl+Q"
|
2021-01-29 03:00:33 +00:00
|
|
|
onTriggered: {
|
|
|
|
Qt.quit()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-16 19:03:01 +00:00
|
|
|
Connections {
|
2021-10-20 09:58:39 +00:00
|
|
|
target: startupModule
|
|
|
|
onAppStateChanged: {
|
|
|
|
mainModule.openStoreToKeychainPopup.connect(function(){
|
|
|
|
storeToKeychainConfirmationPopup.open()
|
|
|
|
})
|
2021-11-24 13:30:00 +00:00
|
|
|
if(localAccountSensitiveSettings.recentEmojis === "") {
|
|
|
|
localAccountSensitiveSettings.recentEmojis = [];
|
|
|
|
}
|
|
|
|
if (localAccountSensitiveSettings.whitelistedUnfurlingSites === "") {
|
|
|
|
localAccountSensitiveSettings.whitelistedUnfurlingSites = {};
|
|
|
|
}
|
|
|
|
if (localAccountSensitiveSettings.hiddenCommunityWelcomeBanners === "") {
|
|
|
|
localAccountSensitiveSettings.hiddenCommunityWelcomeBanners = [];
|
|
|
|
}
|
|
|
|
if (localAccountSensitiveSettings.hiddenCommunityBackUpBanners === "") {
|
|
|
|
localAccountSensitiveSettings.hiddenCommunityBackUpBanners = [];
|
|
|
|
}
|
2021-10-16 19:03:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 14:03:14 +00:00
|
|
|
//! Workaround for custom QQuickWindow
|
|
|
|
Connections {
|
2021-06-03 08:29:14 +00:00
|
|
|
target: applicationWindow
|
2021-05-19 14:03:14 +00:00
|
|
|
onClosing: {
|
2021-11-17 20:27:19 +00:00
|
|
|
if (Qt.platform.os === "osx") {
|
|
|
|
loader.sourceComponent = undefined
|
|
|
|
close.accepted = true
|
|
|
|
} else {
|
|
|
|
if (loader.sourceComponent == login) {
|
|
|
|
Qt.quit();
|
|
|
|
}
|
|
|
|
else if (loader.sourceComponent == app) {
|
|
|
|
if (localAccountSensitiveSettings.quitOnClose) {
|
|
|
|
Qt.quit();
|
|
|
|
} else {
|
|
|
|
applicationWindow.visible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-05-19 14:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onActiveChanged: {
|
2021-05-19 18:31:18 +00:00
|
|
|
if (applicationWindow.active && currentlyHasANotification) {
|
2021-05-19 14:03:14 +00:00
|
|
|
currentlyHasANotification = false
|
|
|
|
// QML doesn't have a function to hide notifications, but this does the trick
|
|
|
|
systemTray.hide()
|
|
|
|
systemTray.show()
|
|
|
|
}
|
2021-02-22 22:10:47 +00:00
|
|
|
}
|
2021-01-29 03:00:33 +00:00
|
|
|
}
|
2021-09-21 15:29:33 +00:00
|
|
|
|
2021-09-06 13:37:00 +00:00
|
|
|
Connections {
|
|
|
|
target: singleInstance
|
|
|
|
|
|
|
|
onSecondInstanceDetected: {
|
|
|
|
console.log("User attempted to run the second instance of the application")
|
|
|
|
// activating this instance to give user visual feedback
|
|
|
|
applicationWindow.show()
|
|
|
|
applicationWindow.raise()
|
|
|
|
applicationWindow.requestActivate()
|
|
|
|
}
|
2021-09-10 08:56:20 +00:00
|
|
|
|
|
|
|
onEventReceived: {
|
|
|
|
let event = JSON.parse(eventStr)
|
|
|
|
if (event.hasOwnProperty("uri")) {
|
|
|
|
chatsModel.handleProtocolUri(event.uri)
|
|
|
|
} else {
|
|
|
|
console.warn("Unknown event received: " + eventStr)
|
|
|
|
}
|
|
|
|
}
|
2021-09-06 13:37:00 +00:00
|
|
|
}
|
2021-01-29 03:00:33 +00:00
|
|
|
|
2021-11-04 14:55:48 +00:00
|
|
|
Connections {
|
|
|
|
target: profileModel
|
|
|
|
ignoreUnknownSignals: true
|
|
|
|
enabled: removeMnemonicAfterLogin
|
|
|
|
onInitialized: {
|
|
|
|
mnemonicModule.remove()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-12 11:52:04 +00:00
|
|
|
// The easiest way to get current system theme (is it light or dark) without using
|
|
|
|
// OS native methods is to check lightness (0 - 1.0) of the window color.
|
|
|
|
// If it's too high (0.85+) means light theme is an active.
|
|
|
|
SystemPalette {
|
|
|
|
id: systemPalette
|
|
|
|
function isCurrentSystemThemeDark() {
|
|
|
|
return window.hslLightness < 0.85
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeThemeFromOutside() {
|
2021-10-20 10:55:10 +00:00
|
|
|
Style.changeTheme(localAppSettings.theme, systemPalette.isCurrentSystemThemeDark())
|
2021-08-12 11:52:04 +00:00
|
|
|
}
|
|
|
|
|
2020-07-12 16:47:46 +00:00
|
|
|
Component.onCompleted: {
|
2021-10-20 10:55:10 +00:00
|
|
|
Style.changeTheme(localAppSettings.theme, systemPalette.isCurrentSystemThemeDark())
|
2021-12-07 09:20:41 +00:00
|
|
|
setX(Qt.application.screens[0].width / 2 - width / 2);
|
|
|
|
setY(Qt.application.screens[0].height / 2 - height / 2);
|
|
|
|
|
2021-11-10 12:48:22 +00:00
|
|
|
if (!localAppSettings.appSizeInitialized) {
|
|
|
|
width = Screen.desktopAvailableWidth - 125
|
|
|
|
height = Screen.desktopAvailableHeight - 125
|
|
|
|
localAppSettings.appSizeInitialized = true
|
|
|
|
}
|
2021-07-19 13:03:35 +00:00
|
|
|
applicationWindow.updatePosition();
|
2020-07-12 16:47:46 +00:00
|
|
|
}
|
|
|
|
|
2020-06-04 07:38:24 +00:00
|
|
|
signal navigateTo(string path)
|
2021-09-21 15:29:33 +00:00
|
|
|
|
2021-02-15 16:29:16 +00:00
|
|
|
property bool currentlyHasANotification: false
|
|
|
|
|
2021-08-18 14:43:59 +00:00
|
|
|
function makeStatusAppActive() {
|
|
|
|
applicationWindow.show()
|
|
|
|
applicationWindow.raise()
|
|
|
|
applicationWindow.requestActivate()
|
|
|
|
}
|
|
|
|
|
2020-05-18 15:07:30 +00:00
|
|
|
SystemTrayIcon {
|
2020-12-07 17:37:39 +00:00
|
|
|
id: systemTray
|
2020-05-18 15:07:30 +00:00
|
|
|
visible: true
|
2021-07-19 16:00:05 +00:00
|
|
|
icon.source: {
|
2021-07-20 04:12:11 +00:00
|
|
|
if (production) {
|
|
|
|
if (Qt.platform.os == "osx")
|
2021-11-29 17:16:14 +00:00
|
|
|
return "imports/assets/images/status-logo-round-rect.svg"
|
2021-07-19 16:00:05 +00:00
|
|
|
else
|
2021-11-29 17:16:14 +00:00
|
|
|
return "imports/assets/images/status-logo-circle.svg"
|
2021-07-20 04:12:11 +00:00
|
|
|
} else {
|
|
|
|
if (Qt.platform.os == "osx")
|
2021-11-29 17:16:14 +00:00
|
|
|
return "imports/assets/images/status-logo-dev-round-rect.svg"
|
2021-07-19 16:00:05 +00:00
|
|
|
else
|
2021-11-29 17:16:14 +00:00
|
|
|
return "imports/assets/images/status-logo-dev-circle.svg"
|
2021-07-19 16:00:05 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-19 12:14:10 +00:00
|
|
|
|
2020-05-18 15:07:30 +00:00
|
|
|
menu: Menu {
|
2021-01-29 03:00:33 +00:00
|
|
|
MenuItem {
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Open Status"
|
|
|
|
text: qsTrId("open-status")
|
2021-01-29 03:00:33 +00:00
|
|
|
onTriggered: {
|
2021-08-18 14:43:59 +00:00
|
|
|
applicationWindow.makeStatusAppActive()
|
2021-01-29 03:00:33 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-21 15:29:33 +00:00
|
|
|
|
2021-05-19 14:03:14 +00:00
|
|
|
MenuSeparator {
|
2021-01-29 03:00:33 +00:00
|
|
|
}
|
|
|
|
|
2020-05-18 15:07:30 +00:00
|
|
|
MenuItem {
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Quit"
|
|
|
|
text: qsTrId("quit")
|
2020-05-18 15:07:30 +00:00
|
|
|
onTriggered: Qt.quit()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onActivated: {
|
2021-07-19 12:14:10 +00:00
|
|
|
if (reason !== SystemTrayIcon.Context) {
|
2021-08-18 14:43:59 +00:00
|
|
|
applicationWindow.makeStatusAppActive()
|
2021-04-07 18:33:23 +00:00
|
|
|
}
|
2020-05-18 15:07:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 10:44:21 +00:00
|
|
|
function prepareForStoring(password, runStoreToKeychainPopup) {
|
2021-09-13 11:51:47 +00:00
|
|
|
if(Qt.platform.os == "osx")
|
|
|
|
{
|
2021-10-16 19:03:01 +00:00
|
|
|
storeToKeychainConfirmationPopup.password = password
|
2021-10-17 10:44:21 +00:00
|
|
|
|
|
|
|
if(runStoreToKeychainPopup)
|
|
|
|
storeToKeychainConfirmationPopup.open()
|
2021-09-13 11:51:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfirmationDialog {
|
|
|
|
id: storeToKeychainConfirmationPopup
|
|
|
|
property string password: ""
|
|
|
|
height: 200
|
|
|
|
confirmationText: qsTr("Would you like to store password to the Keychain?")
|
|
|
|
showRejectButton: true
|
|
|
|
showCancelButton: true
|
|
|
|
confirmButtonLabel: qsTr("Store")
|
|
|
|
rejectButtonLabel: qsTr("Not now")
|
|
|
|
cancelButtonLabel: qsTr("Never")
|
|
|
|
|
|
|
|
function finish()
|
|
|
|
{
|
|
|
|
password = ""
|
|
|
|
storeToKeychainConfirmationPopup.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
onConfirmButtonClicked: {
|
2021-10-17 10:44:21 +00:00
|
|
|
localAccountSettings.storeToKeychainValue = Constants.storeToKeychainValueStore
|
2021-10-16 19:03:01 +00:00
|
|
|
mainModule.storePassword(password)
|
2021-09-13 11:51:47 +00:00
|
|
|
finish()
|
|
|
|
}
|
|
|
|
|
|
|
|
onRejectButtonClicked: {
|
2021-10-17 10:44:21 +00:00
|
|
|
localAccountSettings.storeToKeychainValue = Constants.storeToKeychainValueNotNow
|
2021-09-13 11:51:47 +00:00
|
|
|
finish()
|
|
|
|
}
|
|
|
|
|
|
|
|
onCancelButtonClicked: {
|
2021-10-17 10:44:21 +00:00
|
|
|
localAccountSettings.storeToKeychainValue = Constants.storeToKeychainValueNever
|
2021-09-13 11:51:47 +00:00
|
|
|
finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-04 07:38:24 +00:00
|
|
|
DSM.StateMachine {
|
|
|
|
id: stateMachine
|
|
|
|
initialState: onboardingState
|
|
|
|
running: true
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: onboardingState
|
2021-06-28 11:11:54 +00:00
|
|
|
initialState: hasAccounts ? stateLogin : keysMainState
|
2020-06-04 07:38:24 +00:00
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: keysMainState
|
|
|
|
onEntered: loader.sourceComponent = keysMain
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: genKeyState
|
|
|
|
signal: applicationWindow.navigateTo
|
|
|
|
guard: path === "GenKey"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: existingKeyState
|
|
|
|
onEntered: loader.sourceComponent = existingKey
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: appState
|
2021-10-14 08:04:15 +00:00
|
|
|
signal: startupModule.appStateChanged
|
2021-10-22 10:59:18 +00:00
|
|
|
guard: state == Constants.appState.main
|
2020-06-04 07:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: genKeyState
|
|
|
|
onEntered: loader.sourceComponent = genKey
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: appState
|
2021-10-14 08:04:15 +00:00
|
|
|
signal: startupModule.appStateChanged
|
2021-10-22 10:59:18 +00:00
|
|
|
guard: state == Constants.appState.main
|
2020-06-04 07:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-24 12:03:57 +00:00
|
|
|
DSM.State {
|
|
|
|
id: keycardState
|
2021-10-05 06:16:30 +00:00
|
|
|
onEntered: loader.sourceComponent = keycardFlowSelection
|
2021-09-24 12:03:57 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: appState
|
2021-10-14 08:04:15 +00:00
|
|
|
signal: startupModule.appStateChanged
|
2021-10-22 10:59:18 +00:00
|
|
|
guard: state == Constants.appState.main
|
2021-09-24 12:03:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-04 07:38:24 +00:00
|
|
|
DSM.State {
|
|
|
|
id: stateLogin
|
|
|
|
onEntered: loader.sourceComponent = login
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: appState
|
2021-10-14 08:04:15 +00:00
|
|
|
signal: startupModule.appStateChanged
|
2021-10-22 10:59:18 +00:00
|
|
|
guard: state == Constants.appState.main
|
2020-06-04 07:38:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: genKeyState
|
|
|
|
signal: applicationWindow.navigateTo
|
|
|
|
guard: path === "GenKey"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-12 20:47:44 +00:00
|
|
|
DSM.SignalTransition {
|
2021-06-28 11:11:54 +00:00
|
|
|
targetState: hasAccounts ? stateLogin : keysMainState
|
2020-06-12 20:47:44 +00:00
|
|
|
signal: applicationWindow.navigateTo
|
|
|
|
guard: path === "InitialState"
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: existingKeyState
|
|
|
|
signal: applicationWindow.navigateTo
|
|
|
|
guard: path === "ExistingKey"
|
|
|
|
}
|
|
|
|
|
2020-07-01 15:37:36 +00:00
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: keysMainState
|
|
|
|
signal: applicationWindow.navigateTo
|
|
|
|
guard: path === "KeysMain"
|
|
|
|
}
|
|
|
|
|
2021-09-24 12:03:57 +00:00
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: keycardState
|
|
|
|
signal: applicationWindow.navigateTo
|
2021-10-05 06:16:30 +00:00
|
|
|
guard: path === "KeycardFlowSelection"
|
2021-09-24 12:03:57 +00:00
|
|
|
}
|
|
|
|
|
2020-06-04 07:38:24 +00:00
|
|
|
DSM.FinalState {
|
|
|
|
id: onboardingDoneState
|
|
|
|
}
|
|
|
|
}
|
2020-09-22 15:12:48 +00:00
|
|
|
|
2020-06-04 07:38:24 +00:00
|
|
|
DSM.State {
|
|
|
|
id: appState
|
2021-08-06 11:49:36 +00:00
|
|
|
onEntered: loader.sourceComponent = app
|
2020-06-04 07:38:24 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: stateLogin
|
2021-10-17 10:59:26 +00:00
|
|
|
signal: startupModule.logOut
|
2020-06-04 07:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: loader
|
2020-05-18 15:07:30 +00:00
|
|
|
anchors.fill: parent
|
2020-05-19 13:22:38 +00:00
|
|
|
}
|
2020-05-18 15:07:30 +00:00
|
|
|
|
2021-03-10 04:59:01 +00:00
|
|
|
DropArea {
|
|
|
|
id: dragTarget
|
|
|
|
|
|
|
|
signal droppedOnValidScreen(var drop)
|
|
|
|
property alias droppedUrls: rptDraggedPreviews.model
|
2021-09-15 11:40:07 +00:00
|
|
|
property bool enabled: !drag.source && !!loader.item && !!loader.item.appLayout &&
|
2021-05-19 14:03:14 +00:00
|
|
|
(
|
|
|
|
// in chat view
|
2021-11-10 12:48:22 +00:00
|
|
|
(loader.item.appLayout.appView.currentIndex === Constants.appViewStackIndex.chat &&
|
2021-05-19 14:03:14 +00:00
|
|
|
(
|
|
|
|
// in a one-to-one chat
|
2021-06-17 22:09:00 +00:00
|
|
|
chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne ||
|
2021-05-19 14:03:14 +00:00
|
|
|
// in a private group chat
|
2021-06-17 22:09:00 +00:00
|
|
|
chatsModel.channelView.activeChannel.chatType === Constants.chatTypePrivateGroupChat
|
2021-05-19 14:03:14 +00:00
|
|
|
)
|
|
|
|
) ||
|
2021-11-10 12:48:22 +00:00
|
|
|
// in timeline view
|
|
|
|
loader.item.appLayout.appView.currentIndex === Constants.appViewStackIndex.timeline ||
|
2021-05-19 14:03:14 +00:00
|
|
|
// In community section
|
2021-11-10 12:48:22 +00:00
|
|
|
chatsModel.communities.activeCommunity.active
|
2021-05-19 14:03:14 +00:00
|
|
|
)
|
2021-03-10 04:59:01 +00:00
|
|
|
|
|
|
|
width: applicationWindow.width
|
|
|
|
height: applicationWindow.height
|
|
|
|
|
|
|
|
function cleanup() {
|
|
|
|
rptDraggedPreviews.model = []
|
|
|
|
}
|
|
|
|
|
|
|
|
onDropped: (drop) => {
|
2021-05-19 14:03:14 +00:00
|
|
|
if (enabled) {
|
|
|
|
droppedOnValidScreen(drop)
|
2021-07-28 12:40:51 +00:00
|
|
|
} else {
|
|
|
|
drop.accepted = false
|
2021-05-19 14:03:14 +00:00
|
|
|
}
|
|
|
|
cleanup()
|
|
|
|
}
|
2021-03-10 04:59:01 +00:00
|
|
|
onEntered: {
|
2021-09-15 11:40:07 +00:00
|
|
|
if (!enabled || !!drag.source) {
|
2021-07-28 12:40:51 +00:00
|
|
|
drag.accepted = false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-03-10 04:59:01 +00:00
|
|
|
// needed because drag.urls is not a normal js array
|
|
|
|
rptDraggedPreviews.model = drag.urls.filter(img => Utils.hasDragNDropImageExtension(img))
|
|
|
|
}
|
|
|
|
onPositionChanged: {
|
|
|
|
rptDraggedPreviews.x = drag.x
|
|
|
|
rptDraggedPreviews.y = drag.y
|
|
|
|
}
|
|
|
|
onExited: cleanup()
|
|
|
|
Rectangle {
|
|
|
|
id: dropRectangle
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
color: Style.current.transparent
|
|
|
|
opacity: 0.8
|
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
2021-09-15 11:40:07 +00:00
|
|
|
when: dragTarget.enabled && dragTarget.containsDrag
|
2021-03-10 04:59:01 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: dropRectangle
|
|
|
|
color: Style.current.background
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
Repeater {
|
|
|
|
id: rptDraggedPreviews
|
|
|
|
|
|
|
|
Image {
|
|
|
|
source: modelData
|
|
|
|
width: 80
|
|
|
|
height: 80
|
|
|
|
sourceSize.width: 160
|
|
|
|
sourceSize.height: 160
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
x: index * 10 + rptDraggedPreviews.x
|
|
|
|
y: index * 10 + rptDraggedPreviews.y
|
|
|
|
z: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-04 07:38:24 +00:00
|
|
|
Component {
|
2020-05-19 13:22:38 +00:00
|
|
|
id: app
|
2020-09-15 19:47:13 +00:00
|
|
|
AppMain {}
|
2020-06-04 07:38:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: keysMain
|
2021-10-12 18:26:02 +00:00
|
|
|
KeysMainView {
|
2020-06-04 07:38:24 +00:00
|
|
|
btnGenKey.onClicked: applicationWindow.navigateTo("GenKey")
|
|
|
|
btnExistingKey.onClicked: applicationWindow.navigateTo("ExistingKey")
|
2021-10-05 06:16:30 +00:00
|
|
|
btnKeycard.onClicked: applicationWindow.navigateTo("KeycardFlowSelection")
|
2020-06-04 07:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: existingKey
|
2021-10-12 18:26:02 +00:00
|
|
|
ExistingKeyView {
|
2020-06-12 20:47:44 +00:00
|
|
|
onClosed: function () {
|
2021-02-18 19:14:31 +00:00
|
|
|
removeMnemonicAfterLogin = false
|
2020-07-01 15:37:36 +00:00
|
|
|
if (hasAccounts) {
|
|
|
|
applicationWindow.navigateTo("InitialState")
|
|
|
|
} else {
|
|
|
|
applicationWindow.navigateTo("KeysMain")
|
|
|
|
}
|
2020-06-12 20:47:44 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-04 07:38:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: genKey
|
2021-10-12 18:26:02 +00:00
|
|
|
GenKeyView {
|
2020-06-13 15:17:54 +00:00
|
|
|
onClosed: function () {
|
2020-07-01 15:37:36 +00:00
|
|
|
if (hasAccounts) {
|
|
|
|
applicationWindow.navigateTo("InitialState")
|
|
|
|
} else {
|
|
|
|
applicationWindow.navigateTo("KeysMain")
|
|
|
|
}
|
2020-06-13 15:17:54 +00:00
|
|
|
}
|
2020-06-04 07:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-24 12:03:57 +00:00
|
|
|
Component {
|
2021-10-05 06:16:30 +00:00
|
|
|
id: keycardFlowSelection
|
2021-10-12 18:26:02 +00:00
|
|
|
KeycardFlowSelectionView {
|
2021-09-24 12:03:57 +00:00
|
|
|
onClosed: function () {
|
|
|
|
if (hasAccounts) {
|
|
|
|
applicationWindow.navigateTo("InitialState")
|
|
|
|
} else {
|
|
|
|
applicationWindow.navigateTo("KeysMain")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-04 07:38:24 +00:00
|
|
|
Component {
|
|
|
|
id: login
|
2021-10-12 18:26:02 +00:00
|
|
|
LoginView {
|
2020-06-12 20:47:44 +00:00
|
|
|
onGenKeyClicked: function () {
|
|
|
|
applicationWindow.navigateTo("GenKey")
|
|
|
|
}
|
|
|
|
onExistingKeyClicked: function () {
|
|
|
|
applicationWindow.navigateTo("ExistingKey")
|
|
|
|
}
|
2020-06-04 07:38:24 +00:00
|
|
|
}
|
2020-05-11 21:24:08 +00:00
|
|
|
}
|
2020-07-10 21:47:31 +00:00
|
|
|
|
|
|
|
NotificationWindow {
|
|
|
|
id: notificationWindow
|
|
|
|
}
|
2021-05-19 18:31:18 +00:00
|
|
|
|
|
|
|
MacTrafficLights {
|
2021-06-03 08:29:14 +00:00
|
|
|
// parent: Overlay.overlay
|
2021-05-19 18:31:18 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.margins: 13
|
|
|
|
|
|
|
|
visible: Qt.platform.os === "osx" && !applicationWindow.isFullScreen
|
2021-06-03 08:29:14 +00:00
|
|
|
|
|
|
|
onClose: {
|
2021-06-28 11:11:54 +00:00
|
|
|
if (loader.sourceComponent == login) {
|
2021-08-11 11:47:32 +00:00
|
|
|
Qt.quit();
|
2021-06-03 08:29:14 +00:00
|
|
|
}
|
|
|
|
else if (loader.sourceComponent == app) {
|
2021-10-20 09:50:50 +00:00
|
|
|
if (localAccountSensitiveSettings.quitOnClose) {
|
2021-06-03 08:29:14 +00:00
|
|
|
Qt.quit();
|
|
|
|
} else {
|
|
|
|
applicationWindow.visible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onMinimised: {
|
|
|
|
applicationWindow.showMinimized()
|
|
|
|
}
|
|
|
|
|
|
|
|
onMaximized: {
|
|
|
|
applicationWindow.toggleFullScreen()
|
|
|
|
}
|
2021-05-19 18:31:18 +00:00
|
|
|
}
|
2020-05-11 21:24:08 +00:00
|
|
|
}
|
2020-07-01 17:35:57 +00:00
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;formeditorZoom:0.5}
|
|
|
|
}
|
|
|
|
##^##*/
|