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-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
|
|
|
|
|
2022-03-03 22:50:53 +00:00
|
|
|
import mainui 1.0
|
2022-03-08 18:49:33 +00:00
|
|
|
import AppLayouts.Onboarding 1.0
|
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
|
2022-01-27 15:29:17 +00:00
|
|
|
property bool appIsReady: false
|
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
|
2020-07-13 18:45:54 +00:00
|
|
|
color: Style.current.background
|
2020-06-23 20:49:04 +00:00
|
|
|
title: {
|
|
|
|
// Set application settings
|
2022-04-04 11:26:30 +00:00
|
|
|
Qt.application.name = qsTr("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
|
|
|
|
2022-05-16 06:57:51 +00:00
|
|
|
function restoreAppState() {
|
|
|
|
let geometry = localAppSettings.geometry;
|
|
|
|
let visibility = localAppSettings.visibility;
|
|
|
|
|
|
|
|
if (visibility !== Window.Windowed &&
|
|
|
|
visibility !== Window.Maximized &&
|
|
|
|
visibility !== Window.FullScreen) {
|
|
|
|
visibility = Window.Windowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (geometry === undefined) {
|
|
|
|
let screen = Qt.application.screens[0];
|
|
|
|
|
|
|
|
geometry = Qt.rect(0,
|
|
|
|
0,
|
|
|
|
Math.min(Screen.desktopAvailableWidth - 125, 1400),
|
|
|
|
Math.min(Screen.desktopAvailableHeight - 125, 840));
|
|
|
|
geometry.x = (screen.width - geometry.width) / 2;
|
|
|
|
geometry.y = (screen.height - geometry.height) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
applicationWindow.visibility = visibility;
|
|
|
|
if (visibility == Window.Windowed) {
|
|
|
|
applicationWindow.x = geometry.x;
|
|
|
|
applicationWindow.y = geometry.y;
|
|
|
|
applicationWindow.width = geometry.width;
|
|
|
|
applicationWindow.height = geometry.height;
|
|
|
|
}
|
2021-11-26 12:58:15 +00:00
|
|
|
}
|
|
|
|
|
2022-05-16 06:57:51 +00:00
|
|
|
function storeAppState() {
|
|
|
|
if (!applicationWindow.appIsReady)
|
|
|
|
return;
|
|
|
|
|
|
|
|
localAppSettings.visibility = applicationWindow.visibility;
|
|
|
|
if (applicationWindow.visibility == Window.Windowed) {
|
|
|
|
localAppSettings.geometry = Qt.rect(applicationWindow.x, applicationWindow.y,
|
|
|
|
applicationWindow.width, applicationWindow.height);
|
|
|
|
}
|
2021-11-26 12:58:15 +00:00
|
|
|
}
|
|
|
|
|
2022-05-16 06:57:51 +00:00
|
|
|
onXChanged: Qt.callLater(storeAppState)
|
|
|
|
onYChanged: Qt.callLater(storeAppState)
|
|
|
|
onWidthChanged: Qt.callLater(storeAppState)
|
|
|
|
onHeightChanged: Qt.callLater(storeAppState)
|
2021-11-26 12:58:15 +00:00
|
|
|
|
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
|
2022-01-27 15:29:17 +00:00
|
|
|
|
|
|
|
onStartUpUIRaised: {
|
2022-05-16 06:57:51 +00:00
|
|
|
applicationWindow.appIsReady = true;
|
|
|
|
applicationWindow.storeAppState();
|
2022-01-27 15:29:17 +00:00
|
|
|
}
|
|
|
|
|
2021-10-20 09:58:39 +00:00
|
|
|
onAppStateChanged: {
|
2022-01-11 23:16:17 +00:00
|
|
|
if(state === Constants.appState.main) {
|
|
|
|
// We set main module to the Global singleton once user is logged in and we move to the main app.
|
|
|
|
Global.mainModuleInst = mainModule
|
|
|
|
|
|
|
|
if(localAccountSensitiveSettings.recentEmojis === "") {
|
|
|
|
localAccountSensitiveSettings.recentEmojis = [];
|
|
|
|
}
|
|
|
|
if (localAccountSensitiveSettings.whitelistedUnfurlingSites === "") {
|
|
|
|
localAccountSensitiveSettings.whitelistedUnfurlingSites = {};
|
|
|
|
}
|
|
|
|
if (localAccountSensitiveSettings.hiddenCommunityWelcomeBanners === "") {
|
|
|
|
localAccountSensitiveSettings.hiddenCommunityWelcomeBanners = [];
|
|
|
|
}
|
|
|
|
if (localAccountSensitiveSettings.hiddenCommunityBackUpBanners === "") {
|
|
|
|
localAccountSensitiveSettings.hiddenCommunityBackUpBanners = [];
|
|
|
|
}
|
2021-11-24 13:30:00 +00:00
|
|
|
}
|
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 {
|
2022-03-25 09:54:27 +00:00
|
|
|
if (loader.sourceComponent != app) {
|
2021-11-17 20:27:19 +00:00
|
|
|
Qt.quit();
|
|
|
|
}
|
|
|
|
else if (loader.sourceComponent == app) {
|
|
|
|
if (localAccountSensitiveSettings.quitOnClose) {
|
|
|
|
Qt.quit();
|
|
|
|
} else {
|
|
|
|
applicationWindow.visible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-05-19 14:03:14 +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")) {
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// chatsModel.handleProtocolUri(event.uri)
|
2021-09-10 08:56:20 +00:00
|
|
|
} else {
|
|
|
|
console.warn("Unknown event received: " + eventStr)
|
|
|
|
}
|
|
|
|
}
|
2021-09-06 13:37:00 +00:00
|
|
|
}
|
2021-01-29 03:00:33 +00:00
|
|
|
|
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-12-08 21:20:43 +00:00
|
|
|
Global.applicationWindow = this;
|
2022-05-16 06:57:51 +00:00
|
|
|
Style.changeTheme(localAppSettings.theme, systemPalette.isCurrentSystemThemeDark());
|
2022-02-03 20:42:22 +00:00
|
|
|
|
2022-05-16 06:57:51 +00:00
|
|
|
restoreAppState();
|
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-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 {
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("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 {
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-04 07:38:24 +00:00
|
|
|
Loader {
|
|
|
|
id: loader
|
2020-05-18 15:07:30 +00:00
|
|
|
anchors.fill: parent
|
2022-03-03 22:50:53 +00:00
|
|
|
opacity: active ? 1.0 : 0.0
|
|
|
|
visible: (opacity > 0.0001)
|
|
|
|
Behavior on opacity { NumberAnimation { duration: 120 }}
|
|
|
|
active: !splashScreen.visible
|
2020-05-19 13:22:38 +00:00
|
|
|
}
|
2020-05-18 15:07:30 +00:00
|
|
|
|
2020-06-04 07:38:24 +00:00
|
|
|
Component {
|
2020-05-19 13:22:38 +00:00
|
|
|
id: app
|
2021-12-09 13:28:02 +00:00
|
|
|
AppMain {
|
|
|
|
sysPalette: systemPalette
|
|
|
|
}
|
2020-06-04 07:38:24 +00:00
|
|
|
}
|
|
|
|
|
2022-03-03 22:50:53 +00:00
|
|
|
OnboardingLayout {
|
|
|
|
hasAccounts: applicationWindow.hasAccounts
|
|
|
|
onLoadApp: {
|
|
|
|
loader.sourceComponent = app;
|
2020-06-04 07:38:24 +00:00
|
|
|
}
|
|
|
|
|
2022-03-03 22:50:53 +00:00
|
|
|
onOnBoardingStepChanged: {
|
|
|
|
loader.sourceComponent = view;
|
2022-03-07 22:59:38 +00:00
|
|
|
if (!!state) {
|
|
|
|
loader.item.state = state;
|
|
|
|
}
|
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: {
|
2022-03-25 09:54:27 +00:00
|
|
|
if (loader.sourceComponent != app) {
|
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
|
|
|
}
|
2022-03-03 22:50:53 +00:00
|
|
|
|
|
|
|
SplashScreen {
|
|
|
|
id: splashScreen
|
|
|
|
}
|
2020-05-11 21:24:08 +00:00
|
|
|
}
|
2020-07-01 17:35:57 +00:00
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;formeditorZoom:0.5}
|
|
|
|
}
|
|
|
|
##^##*/
|