From 228a9b6ebde8ed40ac06c9660a0784b37f865a09 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Mon, 23 Nov 2020 12:50:06 -0800 Subject: [PATCH] gcd.firstTime + SettingsList scrolls --- QML_DEBUG_NOTES.md | 10 +++++++++ go/ui/gcd.go | 24 +++++++++++---------- go/ui/settings.go | 7 +++--- main.go | 3 +++ qml/main.qml | 15 +++++++------ qml/opaque | 2 +- qml/panes/GroupSettingsPane.qml | 2 +- qml/panes/PeerSettingsPane.qml | 11 +++++++--- qml/panes/ServerAddEditPane.qml | 2 +- qml/panes/ServerInfoPane.qml | 2 +- qml/panes/SettingsPane.qml | 38 ++++++++++++++++++--------------- qml/widgets/Message.qml | 2 +- 12 files changed, 73 insertions(+), 45 deletions(-) create mode 100644 QML_DEBUG_NOTES.md diff --git a/QML_DEBUG_NOTES.md b/QML_DEBUG_NOTES.md new file mode 100644 index 00000000..7d42e238 --- /dev/null +++ b/QML_DEBUG_NOTES.md @@ -0,0 +1,10 @@ +# Settings List / Flickable + +Content not scrolling: Flickable does some reparenting behind the scenes and so +in the top level child of the Flickable you will need: + + parent: root.contentItem + +And in the flickable you will need to set the contentHeight: + + contentHeight: .height + \ No newline at end of file diff --git a/go/ui/gcd.go b/go/ui/gcd.go index 4850680d..5c6cad66 100644 --- a/go/ui/gcd.go +++ b/go/ui/gcd.go @@ -36,18 +36,18 @@ type GrandCentralDispatcher struct { m_selectedProfile string m_selectedConversation string - _ string `property:"os"` - _ float32 `property:"themeScale,auto,changed"` - _ string `property:"theme,auto,changed"` - _ string `property:"locale,auto,changed"` - _ string `property:"version"` - _ string `property:"buildDate"` - _ string `property:"assetPath"` - _ string `property:"selectedProfile,auto"` - _ string `property:"selectedConversation,auto"` _ int `property:"torStatus"` - + _ string `property:"os"` + _ bool `property:"firstTime"` + _ float32 `property:"themeScale,auto,changed"` + _ string `property:"theme,auto,changed"` + _ string `property:"locale,auto,changed"` + _ string `property:"version"` + _ string `property:"buildDate"` + _ string `property:"assetPath"` + _ string `property:"selectedProfile,auto"` + _ string `property:"selectedConversation,auto"` _ bool `property:experimentsEnabled,auto,changed` _ map[string]bool `property:experiments,auto,changed` @@ -141,7 +141,9 @@ type GrandCentralDispatcher struct { func (this *GrandCentralDispatcher) init() { this.uIManagers = make(map[string]Manager) - this.GlobalSettings = ReadGlobalSettings() + firstTime := false + this.GlobalSettings,firstTime = ReadGlobalSettings() + this.SetFirstTime(firstTime) this.SetThemeScale(this.GlobalSettings.Zoom) this.SetTheme(this.GlobalSettings.Theme) this.SetExperimentsEnabled(this.GlobalSettings.ExperimentsEnabled) diff --git a/go/ui/settings.go b/go/ui/settings.go index 137c68e4..6728647b 100644 --- a/go/ui/settings.go +++ b/go/ui/settings.go @@ -55,7 +55,7 @@ func InitGlobalSettingsFile(directory string, password string) error { return nil } -func ReadGlobalSettings() *GlobalSettings { +func ReadGlobalSettings() (*GlobalSettings, bool) { settings := DefaultGlobalSettings if runtime.GOOS == "android" { settings.Zoom = 2.9 @@ -65,17 +65,18 @@ func ReadGlobalSettings() *GlobalSettings { settingsBytes, err := the.GlobalSettingsFile.Read() if err != nil { log.Errorf("Could not read global ui settings: %v\n", err) - return &settings + return &settings, true //firstTime = true } err = json.Unmarshal(settingsBytes, &settings) if err != nil { log.Errorf("Could not parse global ui settings: %v\n", err) + return &settings, true //firstTime = true } log.Debugf("Settings: %v", settings) - return &settings + return &settings, false } func WriteGlobalSettings(globalSettings *GlobalSettings) { diff --git a/main.go b/main.go index cd79e4b1..ff02d7db 100644 --- a/main.go +++ b/main.go @@ -115,6 +115,7 @@ func main() { the.CwtchApp = nil the.CwtchService = nil os.MkdirAll(the.CwtchDir, 0700) + os.MkdirAll(path.Join(the.CwtchDir, "tor"), 0700) if *flagService { mainService() @@ -185,6 +186,8 @@ func mainUi(flagLocal bool, flagClientUI bool) { gcd.SetBuildDate("now") } + + // this is to load local qml files quickly when developing var qmlSource *core.QUrl if flagLocal { diff --git a/qml/main.qml b/qml/main.qml index 55a3aa20..d50a40c4 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -141,18 +141,21 @@ ApplicationWindow { StackLayout { id: parentStack - currentIndex: managementPane - - anchors.right: parent.right - anchors.left: parent.left - anchors.bottom: statusbar.top - anchors.top: toolbar.bottom readonly property int managementPane: 0 readonly property int settingsPane: 1 readonly property int addEditProfilePane: 2 readonly property int profilePane: 3 readonly property int addEditServerPane: 4 + + currentIndex: gcd.firstTime ? parentStack.settingsPane : parentStack.managementPane + + anchors.right: parent.right + anchors.left: parent.left + anchors.bottom: statusbar.top + anchors.top: toolbar.bottom + + property alias pane: parentStack.currentIndex Rectangle { // Profile login/management pane diff --git a/qml/opaque b/qml/opaque index 3b9675e2..d6b56d02 160000 --- a/qml/opaque +++ b/qml/opaque @@ -1 +1 @@ -Subproject commit 3b9675e25917f667ba4b1cf1db09d44ed328f010 +Subproject commit d6b56d02780c675a0acc36bd0f9ae65a42789077 diff --git a/qml/panes/GroupSettingsPane.qml b/qml/panes/GroupSettingsPane.qml index 0c52f7e5..2c6842e9 100644 --- a/qml/panes/GroupSettingsPane.qml +++ b/qml/panes/GroupSettingsPane.qml @@ -20,7 +20,7 @@ Opaque.SettingsList { // groupSettingsPane property bool connected: false property bool synced: false - settings: Column { + Column { anchors.fill: parent Opaque.Setting { diff --git a/qml/panes/PeerSettingsPane.qml b/qml/panes/PeerSettingsPane.qml index 8822822a..95a9349f 100644 --- a/qml/panes/PeerSettingsPane.qml +++ b/qml/panes/PeerSettingsPane.qml @@ -16,12 +16,17 @@ Opaque.SettingsList { // settingsPane id: root anchors.fill: parent anchors.topMargin: 20 - + width: parent.width + height: parent.height + contentHeight: peerSettings.height + 20 property string authorization property string saveHistory - settings: Column { - anchors.fill: parent + Column { + id: peerSettings + anchors.horizontalCenter: parent.horizontalCenter + width:parent.width -20 + parent: root.contentItem Opaque.Setting { inline: false diff --git a/qml/panes/ServerAddEditPane.qml b/qml/panes/ServerAddEditPane.qml index a35522b4..1eff6f0d 100644 --- a/qml/panes/ServerAddEditPane.qml +++ b/qml/panes/ServerAddEditPane.qml @@ -34,8 +34,8 @@ Opaque.SettingsList { // Add Profile Pane serverAddEditPane.server_messages = server_messages; } - settings: Column { + Column { anchors.horizontalCenter: parent.horizontalCenter width: 700 diff --git a/qml/panes/ServerInfoPane.qml b/qml/panes/ServerInfoPane.qml index b7dd4d84..372ed12d 100644 --- a/qml/panes/ServerInfoPane.qml +++ b/qml/panes/ServerInfoPane.qml @@ -20,7 +20,7 @@ Opaque.SettingsList { // groupSettingsPane property bool connected: false property bool synced: false - settings: Column { + Column { anchors.fill: parent Opaque.Setting { diff --git a/qml/panes/SettingsPane.qml b/qml/panes/SettingsPane.qml index cc7fe4d1..0271cb7b 100644 --- a/qml/panes/SettingsPane.qml +++ b/qml/panes/SettingsPane.qml @@ -16,13 +16,19 @@ import "../utils.js" as Utils Opaque.SettingsList { // settingsPane id: root anchors.fill: parent + width: parent.width + height: parent.height anchors.topMargin: 20 + contentHeight: settings.height - settings: Column { + Column { + id: settings anchors.horizontalCenter: parent.horizontalCenter - width: parent.width - 20 + width:parent.width -20 + parent:root.contentItem Opaque.Setting { + //: Language label: qsTr("setting-language") @@ -149,6 +155,19 @@ Opaque.SettingsList { // settingsPane name: "groups_enabled" experiment_id: "tapir-groups-experiment" } + Opaque.ScalingLabel { + id: versionLabel + anchors.horizontalCenter: parent.horizontalCenter + //: Version %1 + text: qsTr("version %1").arg(gcd.version) + } + + Opaque.ScalingLabel { + id: builddateLabel + anchors.horizontalCenter: parent.horizontalCenter + //: Built on: %2 + text: qsTr("builddate %2").arg(gcd.buildDate) + } } @@ -177,22 +196,7 @@ Opaque.SettingsList { // settingsPane - Opaque.ScalingLabel { - id: versionLabel - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: builddateLabel.top - //: Version %1 - text: qsTr("version %1").arg(gcd.version) - } - Opaque.ScalingLabel { - id: builddateLabel - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - anchors.bottomMargin: 10 - //: Built on: %2 - text: qsTr("builddate %2").arg(gcd.buildDate) - } //end of flickable diff --git a/qml/widgets/Message.qml b/qml/widgets/Message.qml index 23cec57e..65ded440 100644 --- a/qml/widgets/Message.qml +++ b/qml/widgets/Message.qml @@ -174,7 +174,7 @@ Rectangle { Image { // ACKNOWLEDGEMENT ICON id: ack - source: root.error != "" ? gcd.assetPath + "core/fontawesome/regular/window-close.webp" : (root.ackd ? gcd.assetPath + "core/fontawesome/regular/check-circle.svg" : gcd.assetPath + "core/fontawesome/regular/hourglass.svg") + source: root.error != "" ? gcd.assetPath + "core/fontawesome/regular/window-close.webp" : (root.ackd ? gcd.assetPath + "core/fontawesome/regular/check-circle.webp" : gcd.assetPath + "core/fontawesome/regular/hourglass.svg") height: Theme.chatMetaTextSize * gcd.themeScale width: Theme.chatMetaTextSize * gcd.themeScale anchors.bottom: parent.bottom