mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-07 19:59:14 -04:00
refactor(control-center): consolidate detail section height rules
This commit is contained in:
@@ -15,25 +15,6 @@ Item {
|
|||||||
property var pluginDetailInstance: null
|
property var pluginDetailInstance: null
|
||||||
property var widgetModel: null
|
property var widgetModel: null
|
||||||
property var collapseCallback: null
|
property var collapseCallback: null
|
||||||
property real maxAvailableHeight: 9999
|
|
||||||
|
|
||||||
function getDetailHeight(section) {
|
|
||||||
switch (true) {
|
|
||||||
case section === "wifi":
|
|
||||||
case section === "bluetooth":
|
|
||||||
case section === "builtin_vpn":
|
|
||||||
case section === "builtin_tailscale":
|
|
||||||
return Math.min(350, maxAvailableHeight);
|
|
||||||
case section.startsWith("brightnessSlider_"):
|
|
||||||
return Math.min(400, maxAvailableHeight);
|
|
||||||
case section.startsWith("plugin_"):
|
|
||||||
if (pluginDetailInstance?.ccDetailHeight)
|
|
||||||
return Math.min(pluginDetailInstance.ccDetailHeight, maxAvailableHeight);
|
|
||||||
return Math.min(250, maxAvailableHeight);
|
|
||||||
default:
|
|
||||||
return Math.min(250, maxAvailableHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: pluginDetailLoader
|
id: pluginDetailLoader
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import qs.Common
|
|||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Modules.ControlCenter.Widgets
|
import qs.Modules.ControlCenter.Widgets
|
||||||
import qs.Modules.ControlCenter.Components
|
import qs.Modules.ControlCenter.Components
|
||||||
|
import "../utils/detailHeight.js" as DetailHeightUtils
|
||||||
import "../utils/layout.js" as LayoutUtils
|
import "../utils/layout.js" as LayoutUtils
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@@ -38,8 +39,6 @@ Column {
|
|||||||
property real currentRowWidth: 0
|
property real currentRowWidth: 0
|
||||||
property int expandedRowIndex: -1
|
property int expandedRowIndex: -1
|
||||||
property var colorPickerModal: null
|
property var colorPickerModal: null
|
||||||
// Detail instance of the currently expanded plugin section, so the grid can
|
|
||||||
// honor its dynamic ccDetailHeight instead of a fixed slot size.
|
|
||||||
property var activePluginDetailInstance: null
|
property var activePluginDetailInstance: null
|
||||||
|
|
||||||
readonly property real _maxDetailHeight: {
|
readonly property real _maxDetailHeight: {
|
||||||
@@ -76,17 +75,7 @@ Column {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function detailHeightForSection(section) {
|
function detailHeightForSection(section) {
|
||||||
if (!section)
|
return DetailHeightUtils.detailHeightForSection(section, _maxDetailHeight, activePluginDetailInstance);
|
||||||
return 0;
|
|
||||||
if (section === "wifi" || section === "bluetooth" || section === "builtin_vpn")
|
|
||||||
return Math.min(350, _maxDetailHeight);
|
|
||||||
if (section.startsWith("brightnessSlider_"))
|
|
||||||
return Math.min(400, _maxDetailHeight);
|
|
||||||
if (section.startsWith("plugin_")) {
|
|
||||||
const h = activePluginDetailInstance ? activePluginDetailInstance.ccDetailHeight : 0;
|
|
||||||
return Math.min(h > 0 ? h : 250, _maxDetailHeight);
|
|
||||||
}
|
|
||||||
return Math.min(250, _maxDetailHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateRowsAndWidgets() {
|
function calculateRowsAndWidgets() {
|
||||||
@@ -226,7 +215,6 @@ Column {
|
|||||||
DetailHost {
|
DetailHost {
|
||||||
id: detailHost
|
id: detailHost
|
||||||
width: parent.width
|
width: parent.width
|
||||||
maxAvailableHeight: root._maxDetailHeight
|
|
||||||
height: active ? (root.detailHeightForSection(root.expandedSection) + Theme.spacingS) : 0
|
height: active ? (root.detailHeightForSection(root.expandedSection) + Theme.spacingS) : 0
|
||||||
clip: true
|
clip: true
|
||||||
property string retainedSection: ""
|
property string retainedSection: ""
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
function detailHeightForSection(section, maxHeight, pluginInstance) {
|
||||||
|
if (!section)
|
||||||
|
return 0;
|
||||||
|
if (section === "wifi" || section === "bluetooth"
|
||||||
|
|| section === "builtin_vpn" || section === "builtin_tailscale")
|
||||||
|
return Math.min(350, maxHeight);
|
||||||
|
if (section.startsWith("brightnessSlider_"))
|
||||||
|
return Math.min(400, maxHeight);
|
||||||
|
if (section.startsWith("plugin_")) {
|
||||||
|
const h = pluginInstance ? pluginInstance.ccDetailHeight : 0;
|
||||||
|
return Math.min(h > 0 ? h : 250, maxHeight);
|
||||||
|
}
|
||||||
|
return Math.min(250, maxHeight);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user