1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-26 22:42:50 -05:00

dankbar: add generic bar widget IPC for popouts

fixes #750
This commit is contained in:
bbedward
2025-11-24 19:52:26 -05:00
parent d341a5a60b
commit fa98a27c90
5 changed files with 278 additions and 27 deletions

View File

@@ -155,35 +155,56 @@ Loader {
}
onLoaded: {
if (item) {
contentItemReady(item);
if (axis && "isVertical" in item) {
try {
item.isVertical = axis.isVertical;
} catch (e) {}
}
if (!item)
return;
if (item.pluginService !== undefined) {
var parts = widgetId.split(":");
var pluginId = parts[0];
var variantId = parts.length > 1 ? parts[1] : null;
contentItemReady(item);
if (item.pluginId !== undefined) {
item.pluginId = pluginId;
}
if (item.variantId !== undefined) {
item.variantId = variantId;
}
if (item.variantData !== undefined && variantId) {
item.variantData = PluginService.getPluginVariantData(pluginId, variantId);
}
item.pluginService = PluginService;
}
if (item.popoutService !== undefined) {
item.popoutService = PopoutService;
}
if (axis && "isVertical" in item) {
try {
item.isVertical = axis.isVertical;
} catch (e) {}
}
if (item.pluginService !== undefined) {
var parts = widgetId.split(":");
var pluginId = parts[0];
var variantId = parts.length > 1 ? parts[1] : null;
if (item.pluginId !== undefined)
item.pluginId = pluginId;
if (item.variantId !== undefined)
item.variantId = variantId;
if (item.variantData !== undefined && variantId)
item.variantData = PluginService.getPluginVariantData(pluginId, variantId);
item.pluginService = PluginService;
}
if (item.popoutService !== undefined)
item.popoutService = PopoutService;
registerWidgetIfEligible();
}
Component.onDestruction: {
unregisterWidget();
}
function registerWidgetIfEligible() {
if (!item || !widgetId || !parentScreen?.name)
return;
const hasPopout = item.popoutTarget !== undefined || typeof item.triggerPopout === "function" || typeof item.clicked === "function";
if (!hasPopout)
return;
BarWidgetService.registerWidget(widgetId, parentScreen.name, item);
}
function unregisterWidget() {
if (!widgetId || !parentScreen?.name)
return;
BarWidgetService.unregisterWidget(widgetId, parentScreen.name);
}
function getWidgetComponent(widgetId, components) {

View File

@@ -186,6 +186,32 @@ Item {
}
}
function triggerPopout() {
if (pillClickAction) {
if (pillClickAction.length === 0) {
pillClickAction();
return;
}
const pill = isVertical ? verticalPill : horizontalPill;
const globalPos = pill.mapToGlobal(0, 0);
const currentScreen = parentScreen || Screen;
const pos = SettingsData.getPopupTriggerPosition(globalPos, currentScreen, barThickness, pill.width);
pillClickAction(pos.x, pos.y, pos.width, section, currentScreen);
return;
}
if (!hasPopout)
return;
const pill = isVertical ? verticalPill : horizontalPill;
const globalPos = pill.visualContent.mapToGlobal(0, 0);
const currentScreen = parentScreen || Screen;
const barPosition = axis?.edge === "left" ? 2 : (axis?.edge === "right" ? 3 : (axis?.edge === "top" ? 0 : 1));
const pos = SettingsData.getPopupTriggerPosition(globalPos, currentScreen, barThickness, pill.visualWidth, barSpacing, barPosition, barConfig);
pluginPopout.setTriggerPosition(pos.x, pos.y, pos.width, section, currentScreen, barPosition, barThickness, barSpacing, barConfig);
pluginPopout.toggle();
}
PluginPopout {
id: pluginPopout
contentWidth: root.popoutWidth

View File

@@ -55,7 +55,7 @@ Column {
cursorShape: Qt.PointingHandCursor
onPressed: {
if (root.closePopout) {
root.closePopout()
root.closePopout();
}
}
}