From 25eb5fb449c4a9a4be1b65576b7e6d3d582dd373 Mon Sep 17 00:00:00 2001 From: Pim Rijkers Date: Mon, 7 Jul 2025 14:13:35 +0200 Subject: [PATCH 1/3] add automatic restore --- .config/quickshell/modules/common/Config.qml | 3 +++ .../modules/sidebarRight/BottomWidgetGroup.qml | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.config/quickshell/modules/common/Config.qml b/.config/quickshell/modules/common/Config.qml index 81a8989d..3420549d 100644 --- a/.config/quickshell/modules/common/Config.qml +++ b/.config/quickshell/modules/common/Config.qml @@ -206,6 +206,9 @@ Singleton { property string username: "[unset]" } } + property JsonObject bottomWidgetRight: JsonObject { + property int lastTab: 0 + } } property JsonObject time: JsonObject { diff --git a/.config/quickshell/modules/sidebarRight/BottomWidgetGroup.qml b/.config/quickshell/modules/sidebarRight/BottomWidgetGroup.qml index efc34d9f..50730796 100644 --- a/.config/quickshell/modules/sidebarRight/BottomWidgetGroup.qml +++ b/.config/quickshell/modules/sidebarRight/BottomWidgetGroup.qml @@ -14,7 +14,7 @@ Rectangle { color: Appearance.colors.colLayer1 clip: true implicitHeight: collapsed ? collapsedBottomWidgetGroupRow.implicitHeight : bottomWidgetGroupRow.implicitHeight - property int selectedTab: 0 + property int selectedTab: Config.options.sidebar.bottomWidgetRight.lastTab property bool collapsed: Persistent.states.sidebar.bottomGroup.collapsed property var tabs: [ {"type": "calendar", "name": "Calendar", "icon": "calendar_month", "widget": calendarWidget}, @@ -146,6 +146,7 @@ Rectangle { buttonIcon: modelData.icon onClicked: { root.selectedTab = index + Config.options.sidebar.bottomWidgetRight.lastTab = index } } } @@ -171,9 +172,10 @@ Rectangle { StackLayout { id: tabStack Layout.fillWidth: true - height: tabStack.children[0]?.tabLoader?.implicitHeight // TODO: make this less stupid + // Take the highest one, because the TODO list has no implicit height. This way the heigth of the calendar is used when it's initially loaded with the TODO list + height: Math.max(...tabStack.children.map(child => child.tabLoader?.implicitHeight || 0)) // TODO: make this less stupid Layout.alignment: Qt.AlignVCenter - property int realIndex: 0 + property int realIndex: root.selectedTab property int animationDuration: Appearance.animation.elementMoveFast.duration * 1.5 // Switch the tab on halfway of the anim duration @@ -215,6 +217,10 @@ Rectangle { } } } + + Component.onCompleted: { + tabStack.currentIndex = root.selectedTab + } } } From 44443c4a37e8a64286a1ce02c666e98675f87131 Mon Sep 17 00:00:00 2001 From: Pim Rijkers Date: Tue, 8 Jul 2025 14:16:40 +0200 Subject: [PATCH 2/3] moved storage from config to persistent state --- .config/quickshell/modules/common/Config.qml | 3 --- .config/quickshell/modules/common/Persistent.qml | 1 + .config/quickshell/modules/common/PersistentStates.qml | 1 + .config/quickshell/modules/sidebarRight/BottomWidgetGroup.qml | 4 ++-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.config/quickshell/modules/common/Config.qml b/.config/quickshell/modules/common/Config.qml index 3420549d..81a8989d 100644 --- a/.config/quickshell/modules/common/Config.qml +++ b/.config/quickshell/modules/common/Config.qml @@ -206,9 +206,6 @@ Singleton { property string username: "[unset]" } } - property JsonObject bottomWidgetRight: JsonObject { - property int lastTab: 0 - } } property JsonObject time: JsonObject { diff --git a/.config/quickshell/modules/common/Persistent.qml b/.config/quickshell/modules/common/Persistent.qml index 62a39e3c..abd062d7 100644 --- a/.config/quickshell/modules/common/Persistent.qml +++ b/.config/quickshell/modules/common/Persistent.qml @@ -36,6 +36,7 @@ Singleton { property JsonObject sidebar: JsonObject { property JsonObject bottomGroup: JsonObject { property bool collapsed: false + property int tab: 0 } } diff --git a/.config/quickshell/modules/common/PersistentStates.qml b/.config/quickshell/modules/common/PersistentStates.qml index 6887b479..d6588725 100644 --- a/.config/quickshell/modules/common/PersistentStates.qml +++ b/.config/quickshell/modules/common/PersistentStates.qml @@ -12,6 +12,7 @@ Singleton { property QtObject sidebar: QtObject { property QtObject bottomGroup: QtObject { property bool collapsed: false + property int tab: 0 } } diff --git a/.config/quickshell/modules/sidebarRight/BottomWidgetGroup.qml b/.config/quickshell/modules/sidebarRight/BottomWidgetGroup.qml index 50730796..764258e6 100644 --- a/.config/quickshell/modules/sidebarRight/BottomWidgetGroup.qml +++ b/.config/quickshell/modules/sidebarRight/BottomWidgetGroup.qml @@ -14,7 +14,7 @@ Rectangle { color: Appearance.colors.colLayer1 clip: true implicitHeight: collapsed ? collapsedBottomWidgetGroupRow.implicitHeight : bottomWidgetGroupRow.implicitHeight - property int selectedTab: Config.options.sidebar.bottomWidgetRight.lastTab + property int selectedTab: Persistent.states.sidebar.bottomGroup.tab property bool collapsed: Persistent.states.sidebar.bottomGroup.collapsed property var tabs: [ {"type": "calendar", "name": "Calendar", "icon": "calendar_month", "widget": calendarWidget}, @@ -146,7 +146,7 @@ Rectangle { buttonIcon: modelData.icon onClicked: { root.selectedTab = index - Config.options.sidebar.bottomWidgetRight.lastTab = index + Persistent.states.sidebar.bottomGroup.tab = index } } } From f6e89ed60c3f8c48c6284cf768ca877861696b16 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sun, 20 Jul 2025 21:52:32 +0700 Subject: [PATCH 3/3] right sidebar: bottomwidgetgroup tabs: set currentIndex directly --- .../quickshell/ii/modules/sidebarRight/BottomWidgetGroup.qml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.config/quickshell/ii/modules/sidebarRight/BottomWidgetGroup.qml b/.config/quickshell/ii/modules/sidebarRight/BottomWidgetGroup.qml index 764258e6..bbbedace 100644 --- a/.config/quickshell/ii/modules/sidebarRight/BottomWidgetGroup.qml +++ b/.config/quickshell/ii/modules/sidebarRight/BottomWidgetGroup.qml @@ -177,6 +177,7 @@ Rectangle { Layout.alignment: Qt.AlignVCenter property int realIndex: root.selectedTab property int animationDuration: Appearance.animation.elementMoveFast.duration * 1.5 + currentIndex: root.selectedTab // Switch the tab on halfway of the anim duration Connections { @@ -217,10 +218,6 @@ Rectangle { } } } - - Component.onCompleted: { - tabStack.currentIndex = root.selectedTab - } } }