SettingsPanel: finally made the panel ordering easier and also saved ram
This commit is contained in:
parent
860a65b9ca
commit
e86d7e5beb
2 changed files with 102 additions and 73 deletions
|
|
@ -39,7 +39,6 @@ NLoader {
|
||||||
// Start hide animation
|
// Start hide animation
|
||||||
bgRect.scaleValue = 0.8
|
bgRect.scaleValue = 0.8
|
||||||
bgRect.opacityValue = 0.0
|
bgRect.opacityValue = 0.0
|
||||||
|
|
||||||
// Hide after animation completes
|
// Hide after animation completes
|
||||||
hideTimer.start()
|
hideTimer.start()
|
||||||
}
|
}
|
||||||
|
|
@ -48,12 +47,7 @@ NLoader {
|
||||||
Connections {
|
Connections {
|
||||||
target: panel
|
target: panel
|
||||||
function onDismissed() {
|
function onDismissed() {
|
||||||
// Start hide animation
|
hide()
|
||||||
bgRect.scaleValue = 0.8
|
|
||||||
bgRect.opacityValue = 0.0
|
|
||||||
|
|
||||||
// Hide after animation completes
|
|
||||||
hideTimer.start()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,79 +64,126 @@ NLoader {
|
||||||
|
|
||||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
|
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
|
||||||
|
|
||||||
// Order is NOT relevant, and should match the Tabs.xxxx {} in the StackLayout
|
Component {
|
||||||
|
id: generalTab
|
||||||
|
Tabs.GeneralTab {}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: barTab
|
||||||
|
Tabs.BarTab {}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: audioTab
|
||||||
|
Tabs.AudioTab {}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: displayTab
|
||||||
|
Tabs.DisplayTab {}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: networkTab
|
||||||
|
Tabs.NetworkTab {}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: timeWeatherTab
|
||||||
|
Tabs.TimeWeatherTab {}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: colorSchemeTab
|
||||||
|
Tabs.ColorSchemeTab {}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: wallpaperTab
|
||||||
|
Tabs.WallpaperTab {}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: wallpaperSelectorTab
|
||||||
|
Tabs.WallpaperSelectorTab {}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: screenRecorderTab
|
||||||
|
Tabs.ScreenRecorderTab {}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: aboutTab
|
||||||
|
Tabs.AboutTab {}
|
||||||
|
}
|
||||||
|
|
||||||
property var tabsModel: [{
|
property var tabsModel: [{
|
||||||
"id": SettingsPanel.Tab.General,
|
"id": SettingsPanel.Tab.General,
|
||||||
"label": "General",
|
"label": "General",
|
||||||
"icon": "tune"
|
"icon": "tune",
|
||||||
|
"source": generalTab
|
||||||
}, {
|
}, {
|
||||||
"id": SettingsPanel.Tab.Bar,
|
"id": SettingsPanel.Tab.Bar,
|
||||||
"label": "Bar",
|
"label": "Bar",
|
||||||
"icon": "web_asset"
|
"icon": "web_asset",
|
||||||
|
"source": barTab
|
||||||
}, {
|
}, {
|
||||||
"id": SettingsPanel.Tab.Audio,
|
"id": SettingsPanel.Tab.Audio,
|
||||||
"label": "Audio",
|
"label": "Audio",
|
||||||
"icon": "volume_up"
|
"icon": "volume_up",
|
||||||
|
"source": audioTab
|
||||||
}, {
|
}, {
|
||||||
"id": SettingsPanel.Tab.Display,
|
"id": SettingsPanel.Tab.Display,
|
||||||
"label": "Display",
|
"label": "Display",
|
||||||
"icon": "monitor"
|
"icon": "monitor",
|
||||||
|
"source": displayTab
|
||||||
}, {
|
}, {
|
||||||
"id": SettingsPanel.Tab.Network,
|
"id": SettingsPanel.Tab.Network,
|
||||||
"label": "Network",
|
"label": "Network",
|
||||||
"icon": "lan"
|
"icon": "lan",
|
||||||
|
"source": networkTab
|
||||||
}, {
|
}, {
|
||||||
"id": SettingsPanel.Tab.TimeWeather,
|
"id": SettingsPanel.Tab.TimeWeather,
|
||||||
"label": "Time & Weather",
|
"label": "Time & Weather",
|
||||||
"icon": "schedule"
|
"icon": "schedule",
|
||||||
|
"source": timeWeatherTab
|
||||||
}, {
|
}, {
|
||||||
"id": SettingsPanel.Tab.ColorScheme,
|
"id": SettingsPanel.Tab.ColorScheme,
|
||||||
"label": "Color Scheme",
|
"label": "Color Scheme",
|
||||||
"icon": "palette"
|
"icon": "palette",
|
||||||
|
"source": colorSchemeTab
|
||||||
}, {
|
}, {
|
||||||
"id": SettingsPanel.Tab.Wallpaper,
|
"id": SettingsPanel.Tab.Wallpaper,
|
||||||
"label": "Wallpaper",
|
"label": "Wallpaper",
|
||||||
"icon": "image"
|
"icon": "image",
|
||||||
|
"source": wallpaperTab
|
||||||
}, {
|
}, {
|
||||||
"id": SettingsPanel.Tab.WallpaperSelector,
|
"id": SettingsPanel.Tab.WallpaperSelector,
|
||||||
"label": "Wallpaper Selector",
|
"label": "Wallpaper Selector",
|
||||||
"icon": "wallpaper_slideshow"
|
"icon": "wallpaper_slideshow",
|
||||||
|
"source": wallpaperSelectorTab
|
||||||
}, {
|
}, {
|
||||||
"id": SettingsPanel.Tab.ScreenRecorder,
|
"id": SettingsPanel.Tab.ScreenRecorder,
|
||||||
"label": "Screen Recorder",
|
"label": "Screen Recorder",
|
||||||
"icon": "videocam"
|
"icon": "videocam",
|
||||||
|
"source": screenRecorderTab
|
||||||
}, {
|
}, {
|
||||||
"id": SettingsPanel.Tab.About,
|
"id": SettingsPanel.Tab.About,
|
||||||
"label": "About",
|
"label": "About",
|
||||||
"icon": "info"
|
"icon": "info",
|
||||||
|
"source": aboutTab
|
||||||
}]
|
}]
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
show()
|
var initialIndex = 0
|
||||||
}
|
if (root.requestedTab !== null) {
|
||||||
|
for (var i = 0; i < panel.tabsModel.length; i++) {
|
||||||
// Combined visibility change handler
|
if (panel.tabsModel[i].id === root.requestedTab) {
|
||||||
onVisibleChanged: {
|
initialIndex = i
|
||||||
if (visible) {
|
|
||||||
// Default to first tab
|
|
||||||
currentTabIndex = 0
|
|
||||||
|
|
||||||
// Find the request tab if necessary
|
|
||||||
if (requestedTab != null) {
|
|
||||||
for (var i = 0; i < tabsModel.length; i++) {
|
|
||||||
if (tabsModel[i].id == requestedTab) {
|
|
||||||
currentTabIndex = i
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (bgRect.opacityValue > 0) {
|
// Now that the UI is settled, set the current tab index.
|
||||||
// Start hide animation
|
panel.currentTabIndex = initialIndex
|
||||||
bgRect.scaleValue = 0.8
|
show()
|
||||||
bgRect.opacityValue = 0.0
|
}
|
||||||
|
|
||||||
// Hide after animation completes
|
onVisibleChanged: {
|
||||||
hideTimer.start()
|
if (!visible && (bgRect.opacityValue > 0)) {
|
||||||
|
hide()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,14 +215,12 @@ NLoader {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
}
|
}
|
||||||
|
|
||||||
// Animation behaviors
|
|
||||||
Behavior on scale {
|
Behavior on scale {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: Style.animationSlow
|
duration: Style.animationSlow
|
||||||
easing.type: Easing.OutExpo
|
easing.type: Easing.OutExpo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: Style.animationNormal
|
duration: Style.animationNormal
|
||||||
|
|
@ -194,7 +233,6 @@ NLoader {
|
||||||
anchors.margins: Style.marginLarge * scaling
|
anchors.margins: Style.marginLarge * scaling
|
||||||
spacing: Style.marginLarge * scaling
|
spacing: Style.marginLarge * scaling
|
||||||
|
|
||||||
// Sidebar with tighter spacing
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: sidebar
|
id: sidebar
|
||||||
Layout.preferredWidth: 260 * scaling
|
Layout.preferredWidth: 260 * scaling
|
||||||
|
|
@ -207,29 +245,20 @@ NLoader {
|
||||||
Column {
|
Column {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Style.marginSmall * scaling
|
anchors.margins: Style.marginSmall * scaling
|
||||||
spacing: Style.marginTiny * 1.5 * scaling // Minimal spacing between tabs
|
spacing: Style.marginTiny * 1.5 * scaling
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: sections
|
id: sections
|
||||||
model: panel.tabsModel
|
model: panel.tabsModel
|
||||||
|
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
id: tabItem
|
id: tabItem
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 32 * scaling // Back to original height
|
height: 32 * scaling
|
||||||
radius: Style.radiusSmall * scaling
|
radius: Style.radiusSmall * scaling
|
||||||
color: selected ? Colors.mPrimary : (tabItem.hovering ? Colors.mTertiary : "transparent")
|
color: selected ? Colors.mPrimary : (tabItem.hovering ? Colors.mTertiary : "transparent")
|
||||||
border.color: "transparent"
|
|
||||||
border.width: 0
|
|
||||||
|
|
||||||
readonly property bool selected: index === currentTabIndex
|
readonly property bool selected: index === currentTabIndex
|
||||||
|
|
||||||
// Subtle hover effect: only icon/text color tint on hover
|
|
||||||
property bool hovering: false
|
property bool hovering: false
|
||||||
|
|
||||||
property color tabTextColor: selected ? Colors.mOnPrimary : (tabItem.hovering ? Colors.mOnTertiary : Colors.mOnSurface)
|
property color tabTextColor: selected ? Colors.mOnPrimary : (tabItem.hovering ? Colors.mOnTertiary : Colors.mOnSurface)
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.leftMargin: Style.marginSmall * scaling
|
anchors.leftMargin: Style.marginSmall * scaling
|
||||||
|
|
@ -290,7 +319,7 @@ NLoader {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
spacing: Style.marginSmall * scaling
|
spacing: Style.marginSmall * scaling
|
||||||
|
|
||||||
// Tab label on the main right
|
// Tab label on the main right side
|
||||||
NText {
|
NText {
|
||||||
text: panel.tabsModel[currentTabIndex].label
|
text: panel.tabsModel[currentTabIndex].label
|
||||||
font.pointSize: Style.fontSizeLarge * scaling
|
font.pointSize: Style.fontSizeLarge * scaling
|
||||||
|
|
@ -302,9 +331,7 @@ NLoader {
|
||||||
icon: "close"
|
icon: "close"
|
||||||
tooltipText: "Close"
|
tooltipText: "Close"
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
onClicked: {
|
onClicked: panel.hide()
|
||||||
panel.hide()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -312,23 +339,26 @@ NLoader {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
StackLayout {
|
Item {
|
||||||
id: stack
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
currentIndex: currentTabIndex
|
clip: true
|
||||||
|
|
||||||
Tabs.GeneralTab {}
|
Repeater {
|
||||||
Tabs.BarTab {}
|
model: panel.tabsModel
|
||||||
Tabs.AudioTab {}
|
|
||||||
Tabs.DisplayTab {}
|
onItemAdded: function (index, item) {
|
||||||
Tabs.NetworkTab {}
|
item.sourceComponent = panel.tabsModel[index].source
|
||||||
Tabs.TimeWeatherTab {}
|
}
|
||||||
Tabs.ColorSchemeTab {}
|
|
||||||
Tabs.WallpaperTab {}
|
delegate: Loader {
|
||||||
Tabs.WallpaperSelectorTab {}
|
// All loaders will occupy the same space, stacked on top of each other.
|
||||||
Tabs.ScreenRecorderTab {}
|
anchors.fill: parent
|
||||||
Tabs.AboutTab {}
|
visible: index === panel.currentTabIndex
|
||||||
|
// The loader is only active (and uses memory) when its page is visible.
|
||||||
|
active: visible
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,6 @@ ColumnLayout {
|
||||||
name: "AAC"
|
name: "AAC"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentKey: Settings.data.screenRecorder.audioCodec
|
currentKey: Settings.data.screenRecorder.audioCodec
|
||||||
onSelected: function (key) {
|
onSelected: function (key) {
|
||||||
Settings.data.screenRecorder.audioCodec = key
|
Settings.data.screenRecorder.audioCodec = key
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue