1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-02 03:28:28 -04:00

dash: allow hiding all tabs

port 1.5
This commit is contained in:
bbedward
2026-07-13 16:11:15 -04:00
parent e3034e4e94
commit 7535b70fa6
9 changed files with 85 additions and 101 deletions
@@ -1105,13 +1105,12 @@ Item {
onClockClicked: {
const section = topBarContent.getWidgetSection(parent) || "center";
const tabIndex = SettingsData.dashTabIndexForId("overview");
topBarContent.openWidgetPopout({
loader: dankDashPopoutLoader,
widgetItem: clockWidget,
section,
tabIndex,
triggerSource: topBarContent._dashTriggerSource(section, tabIndex),
triggerSource: topBarContent._dashTriggerSource(section, "overview"),
prepare: popout => popout.requestTab("overview"),
mode: "click",
useCenterSection: true,
setTriggerScreen: true
@@ -1134,13 +1133,12 @@ Item {
parentScreen: barWindow.screen
onClicked: {
const section = topBarContent.getWidgetSection(parent) || "center";
const tabIndex = SettingsData.dashTabIndexForId("media");
topBarContent.openWidgetPopout({
loader: dankDashPopoutLoader,
widgetItem: mediaWidget,
section,
tabIndex,
triggerSource: topBarContent._dashTriggerSource(section, tabIndex),
triggerSource: topBarContent._dashTriggerSource(section, "media"),
prepare: popout => popout.requestTab("media"),
mode: "click",
useCenterSection: true,
setTriggerScreen: true
@@ -1162,13 +1160,12 @@ Item {
parentScreen: barWindow.screen
onClicked: {
const section = topBarContent.getWidgetSection(parent) || "center";
const tabIndex = SettingsData.dashTabIndexForId("weather");
topBarContent.openWidgetPopout({
loader: dankDashPopoutLoader,
widgetItem: weatherWidget,
section,
tabIndex,
triggerSource: topBarContent._dashTriggerSource(section, tabIndex),
triggerSource: topBarContent._dashTriggerSource(section, "weather"),
prepare: popout => popout.requestTab("weather"),
mode: "click",
useCenterSection: true,
setTriggerScreen: true
@@ -736,11 +736,11 @@ Item {
case "music":
case "weather":
{
const tabIndex = SettingsData.dashTabIndexForId(widgetId === "clock" ? "overview" : (widgetId === "music" ? "media" : "weather"));
const tabId = widgetId === "clock" ? "overview" : (widgetId === "music" ? "media" : "weather");
return barContent.openWidgetPopout(Object.assign({}, base, {
loader,
tabIndex,
triggerSource: dashTriggerSource(section, tabIndex),
triggerSource: dashTriggerSource(section, tabId),
prepare: popout => popout.requestTab(tabId),
useCenterSection: true,
setTriggerScreen: true
}));
+5 -3
View File
@@ -65,7 +65,7 @@ PanelWindow {
}
}
function triggerDashTab(tabIndex) {
function triggerDashTab(tabId) {
dankDashPopoutLoader.active = true;
if (!dankDashPopoutLoader.item) {
return false;
@@ -103,12 +103,14 @@ PanelWindow {
dankDashPopoutLoader.item.triggerScreen = barWindow.screen;
}
PopoutManager.requestPopout(dankDashPopoutLoader.item, tabIndex, (barConfig?.id ?? "default") + "-" + section + "-" + tabIndex);
if (dankDashPopoutLoader.item.requestTab)
dankDashPopoutLoader.item.requestTab(tabId);
PopoutManager.requestPopout(dankDashPopoutLoader.item, undefined, (barConfig?.id ?? "default") + "-" + section + "-" + tabId);
return true;
}
function triggerWallpaperBrowser() {
triggerDashTab(SettingsData.dashTabIndexForId("wallpaper"));
triggerDashTab("wallpaper");
}
readonly property bool usesOverlayLayer: CompositorService.framePeerSurfacesUseOverlayForScreen(barWindow.screen) || (barConfig?.useOverlayLayer ?? false)
+36 -54
View File
@@ -10,7 +10,7 @@ DankPopout {
property bool dashVisible: false
property var triggerScreen: null
property int currentTabIndex: 0
property string currentTabId: "overview"
readonly property var __tabPresentation: ({
"overview": {
@@ -36,36 +36,34 @@ DankPopout {
}
})
readonly property var orderedTabIds: SettingsData.visibleDashTabIds()
readonly property string currentTabId: orderedTabIds.length > 0 ? (orderedTabIds[Math.min(currentTabIndex, orderedTabIds.length - 1)] ?? "overview") : "overview"
// -1 when the current view's tab is hidden: the view still shows, no tab is highlighted.
readonly property int currentTabIndex: orderedTabIds.indexOf(currentTabId)
function __isActionTab(id) {
return root.__tabPresentation[id]?.isAction === true;
}
function __resolveContentIndex(idx) {
if (orderedTabIds.length === 0)
return 0;
var clamped = Math.max(0, Math.min(idx, orderedTabIds.length - 1));
if (!__isActionTab(orderedTabIds[clamped]))
return clamped;
for (var f = clamped + 1; f < orderedTabIds.length; f++)
if (!__isActionTab(orderedTabIds[f]))
return f;
for (var b = clamped - 1; b >= 0; b--)
if (!__isActionTab(orderedTabIds[b]))
return b;
return clamped;
// Show a view regardless of tab visibility; bar widgets and IPC land here.
function requestTab(id) {
const valid = __tabPresentation[id] !== undefined && !__isActionTab(id) && (id !== "weather" || SettingsData.weatherEnabled);
currentTabId = valid ? id : "overview";
}
onOrderedTabIdsChanged: {
var resolved = __resolveContentIndex(currentTabIndex);
if (resolved !== currentTabIndex)
currentTabIndex = resolved;
function __cycleTab(dir) {
const ids = orderedTabIds.filter(id => !__isActionTab(id));
if (ids.length === 0)
return;
const pos = ids.indexOf(currentTabId);
const next = pos < 0 ? (dir > 0 ? 0 : ids.length - 1) : (pos + dir + ids.length) % ids.length;
currentTabId = ids[next];
}
onCurrentTabIndexChanged: {
var resolved = __resolveContentIndex(currentTabIndex);
if (resolved !== currentTabIndex)
currentTabIndex = resolved;
Connections {
target: SettingsData
function onWeatherEnabledChanged() {
if (!SettingsData.weatherEnabled && root.currentTabId === "weather")
root.currentTabId = "overview";
}
}
popupWidth: SettingsData.showWeekNumber ? 736 : 700
@@ -266,32 +264,13 @@ DankPopout {
}
if (event.key === Qt.Key_Tab && !(event.modifiers & Qt.ShiftModifier)) {
let nextIndex = root.currentTabIndex + 1;
while (nextIndex < tabBar.model.length && tabBar.model[nextIndex] && tabBar.model[nextIndex].isAction) {
nextIndex++;
}
if (nextIndex >= tabBar.model.length) {
nextIndex = 0;
}
root.currentTabIndex = nextIndex;
root.__cycleTab(1);
event.accepted = true;
return;
}
if (event.key === Qt.Key_Backtab || (event.key === Qt.Key_Tab && (event.modifiers & Qt.ShiftModifier))) {
let prevIndex = root.currentTabIndex - 1;
while (prevIndex >= 0 && tabBar.model[prevIndex] && tabBar.model[prevIndex].isAction) {
prevIndex--;
}
if (prevIndex < 0) {
prevIndex = tabBar.model.length - 1;
while (prevIndex >= 0 && tabBar.model[prevIndex] && tabBar.model[prevIndex].isAction) {
prevIndex--;
}
}
if (prevIndex >= 0) {
root.currentTabIndex = prevIndex;
}
root.__cycleTab(-1);
event.accepted = true;
return;
}
@@ -331,11 +310,12 @@ DankPopout {
// Effective visibility is false while the popout window is unmapped, so gating
// height on `visible` collapses the bar between opens and resizes the surface
// mid-animation. Gate on the model instead.
readonly property bool hasTabs: (model?.length ?? 0) > 0
// mid-animation. Gate on data only. The bar also hides entirely when the
// current view's tab isn't in the visible set (e.g. IPC-opened hidden tab).
readonly property bool showTabs: (model?.length ?? 0) > 0 && root.currentTabIndex >= 0
width: parent.width
height: hasTabs ? 48 : 0
visible: hasTabs
height: showTabs ? 48 : 0
visible: showTabs
currentIndex: root.currentTabIndex
spacing: Theme.spacingS
equalWidthTabs: true
@@ -354,7 +334,9 @@ DankPopout {
model: root.orderedTabIds.map(id => root.__tabPresentation[id])
onTabClicked: function (index) {
root.currentTabIndex = index;
const id = root.orderedTabIds[index];
if (id !== undefined)
root.currentTabId = id;
}
onActionTriggered: function (index) {
@@ -367,8 +349,8 @@ DankPopout {
Item {
width: parent.width
height: tabBar.hasTabs ? Theme.spacingXS : 0
visible: tabBar.hasTabs
height: tabBar.showTabs ? Theme.spacingXS : 0
visible: tabBar.showTabs
}
Item {
@@ -411,11 +393,11 @@ DankPopout {
onNavFocusRequested: mainContainer.forceActiveFocus()
onSwitchToWeatherTab: {
if (SettingsData.weatherEnabled) {
root.currentTabIndex = SettingsData.dashTabIndexForId("weather");
root.requestTab("weather");
}
}
onSwitchToMediaTab: {
root.currentTabIndex = SettingsData.dashTabIndexForId("media");
root.requestTab("media");
}
}
}
@@ -434,7 +416,7 @@ DankPopout {
popoutY: root.alignedY
popoutWidth: root.alignedWidth
popoutHeight: root.alignedHeight
contentOffsetY: Theme.spacingM + 48 + Theme.spacingS + Theme.spacingXS
contentOffsetY: Theme.spacingM + (tabBar.showTabs ? 48 + Theme.spacingS + Theme.spacingXS : 0)
section: root.triggerSection
barPosition: root.effectiveBarPosition
Component.onCompleted: root.__mediaTabRef = this
+1 -9
View File
@@ -48,7 +48,6 @@ Item {
// its delegates alive across commits (preserving focus for keyboard reorder)
readonly property var tabIds: SettingsData._dashTabIds
readonly property var tabState: SettingsData.getDashTabs()
readonly property var visibleContentIds: SettingsData.visibleDashTabIds().filter(id => id !== "settings")
function presentationFor(id) {
return __presentation[id] ?? {
@@ -148,10 +147,6 @@ Item {
commit();
}
function canHide(id) {
return !isEnabled(id) || id === "settings" || visibleContentIds.indexOf(id) < 0 || visibleContentIds.length > 1;
}
// Keyboard nav is handled at the tab root (not per-row activeFocusOnTab)
Keys.onPressed: function (event) {
const order = enabledOrder.concat(disabledOrder);
@@ -172,8 +167,7 @@ Item {
}
event.accepted = true;
} else if ((event.key === Qt.Key_Space || event.key === Qt.Key_Return) && highlightedId !== "") {
if (canHide(highlightedId))
SettingsData.setDashTabEnabled(highlightedId, !isEnabled(highlightedId));
SettingsData.setDashTabEnabled(highlightedId, !isEnabled(highlightedId));
event.accepted = true;
}
}
@@ -379,7 +373,6 @@ Item {
readonly property bool isEnabled: root.isEnabled(modelData)
readonly property bool dragging: root.draggingId === modelData
readonly property bool highlighted: root.highlightedId === modelData
readonly property bool canHide: root.canHide(modelData)
width: reorderArea.width
height: root.rowHeight
@@ -528,7 +521,6 @@ Item {
iconName: rowItem.isEnabled ? "visibility" : "visibility_off"
iconSize: 18
iconColor: rowItem.isEnabled ? Theme.primary : Theme.outline
enabled: rowItem.canHide
onClicked: {
root.forceActiveFocus();
root.highlightedId = rowItem.modelData;