From 9683b7a79e3f0abfad55a793602f997497da1de6 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 23 Jun 2020 16:49:04 -0400 Subject: [PATCH] feat: enable saving app settings like the SplitView state --- ui/app/AppLayouts/Chat/ChatLayout.qml | 7 ++++++- ui/app/AppLayouts/Profile/ProfileLayout.qml | 7 +++++-- ui/app/AppLayouts/Wallet/WalletLayout.qml | 5 +++++ ui/app/AppMain.qml | 5 +++++ ui/main.qml | 23 +++++++++++++++++++-- 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/ui/app/AppLayouts/Chat/ChatLayout.qml b/ui/app/AppLayouts/Chat/ChatLayout.qml index ceb90ca9c0..6667fb0133 100644 --- a/ui/app/AppLayouts/Chat/ChatLayout.qml +++ b/ui/app/AppLayouts/Chat/ChatLayout.qml @@ -1,14 +1,19 @@ import QtQuick 2.13 import QtQuick.Controls 2.13 +import Qt.labs.settings 1.0 import "../../../imports" import "../../../shared" import "." SplitView { - id: chatView + property var appSettings + id: chatView handle: SplitViewHandle {} + Component.onCompleted: this.restoreState(appSettings.chatSplitView) + Component.onDestruction: appSettings.chatSplitView = this.saveState() + ContactsColumn { id: contactsColumn SplitView.preferredWidth: Theme.leftTabPrefferedSize diff --git a/ui/app/AppLayouts/Profile/ProfileLayout.qml b/ui/app/AppLayouts/Profile/ProfileLayout.qml index 084f506b70..180595fd3d 100644 --- a/ui/app/AppLayouts/Profile/ProfileLayout.qml +++ b/ui/app/AppLayouts/Profile/ProfileLayout.qml @@ -6,14 +6,17 @@ import "../../../shared" import "./Sections" SplitView { + property var appSettings + id: profileView - x: 0 - y: 0 Layout.fillHeight: true Layout.fillWidth: true handle: SplitViewHandle {} + Component.onCompleted: this.restoreState(appSettings.profileSplitView) + Component.onDestruction: appSettings.profileSplitView = this.saveState() + LeftTab { id: leftTab SplitView.preferredWidth: Theme.leftTabPrefferedSize diff --git a/ui/app/AppLayouts/Wallet/WalletLayout.qml b/ui/app/AppLayouts/Wallet/WalletLayout.qml index 2af0a8d01e..d421fa43f9 100644 --- a/ui/app/AppLayouts/Wallet/WalletLayout.qml +++ b/ui/app/AppLayouts/Wallet/WalletLayout.qml @@ -6,12 +6,17 @@ import "../../../shared" import "." SplitView { + property var appSettings + id: walletView Layout.fillHeight: true Layout.fillWidth: true handle: SplitViewHandle {} + Component.onCompleted: this.restoreState(appSettings.walletSplitView) + Component.onDestruction: appSettings.walletSplitView = this.saveState() + LeftTab { id: leftTab SplitView.preferredWidth: Theme.leftTabPrefferedSize diff --git a/ui/app/AppMain.qml b/ui/app/AppMain.qml index 0eeb31d192..d6ee4bdae6 100644 --- a/ui/app/AppMain.qml +++ b/ui/app/AppMain.qml @@ -6,6 +6,8 @@ import "../shared" import "./AppLayouts" RowLayout { + property var appSettings + id: rowLayout Layout.fillHeight: true Layout.fillWidth: true @@ -169,6 +171,7 @@ RowLayout { Layout.fillWidth: true Layout.alignment: Qt.AlignLeft | Qt.AlignTop Layout.fillHeight: true + appSettings: rowLayout.appSettings } WalletLayout { @@ -176,6 +179,7 @@ RowLayout { Layout.fillWidth: true Layout.alignment: Qt.AlignLeft | Qt.AlignTop Layout.fillHeight: true + appSettings: rowLayout.appSettings } BrowserLayout { @@ -190,6 +194,7 @@ RowLayout { Layout.fillWidth: true Layout.alignment: Qt.AlignLeft | Qt.AlignTop Layout.fillHeight: true + appSettings: rowLayout.appSettings } NodeLayout { diff --git a/ui/main.qml b/ui/main.qml index 1138929d18..3988d9f457 100644 --- a/ui/main.qml +++ b/ui/main.qml @@ -3,19 +3,36 @@ import QtQuick.Controls 2.13 import QtQuick.Layouts 1.13 import Qt.labs.platform 1.1 import QtQml.StateMachine 1.14 as DSM +import Qt.labs.settings 1.0 +import QtQml 2.13 import "./onboarding" import "./app" import "./imports" ApplicationWindow { + property alias appSettings: settings + id: applicationWindow width: 1232 height: 770 - title: "Nim Status Client" + title: { + // Set application settings + Qt.application.name = qsTr("Nim Status Client") + Qt.application.organization = "Status" + Qt.application.domain = "status.im" + return Qt.application.name + } visible: true signal navigateTo(string path) + Settings { + id: settings + property var chatSplitView + property var walletSplitView + property var profileSplitView + } + SystemTrayIcon { visible: true icon.source: "shared/img/status-logo.png" @@ -138,7 +155,9 @@ ApplicationWindow { Component { id: app - AppMain {} + AppMain { + appSettings: applicationWindow.appSettings + } } Component {