mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-13 09:12:08 -04:00
ipc: update DankBar selection (#1894)
* ipc: update DankBar selection * ipc: use getPreferredBar in dash open * ipc: don't toggle dash on dash open
This commit is contained in:
@@ -21,11 +21,37 @@ Item {
|
|||||||
required property var workspaceRenameModalLoader
|
required property var workspaceRenameModalLoader
|
||||||
required property var windowRuleModalLoader
|
required property var windowRuleModalLoader
|
||||||
|
|
||||||
function getFirstBar() {
|
function getPreferredBar(refPropertyName) {
|
||||||
if (!root.dankBarRepeater || root.dankBarRepeater.count === 0)
|
if (!root.dankBarRepeater || root.dankBarRepeater.count === 0)
|
||||||
return null;
|
return null;
|
||||||
const firstLoader = root.dankBarRepeater.itemAt(0);
|
|
||||||
return firstLoader ? firstLoader.item : null;
|
const focusedScreenName = BarWidgetService.getFocusedScreenName();
|
||||||
|
|
||||||
|
const loaders = Array.from({
|
||||||
|
length: root.dankBarRepeater.count
|
||||||
|
}, (_, i) => root.dankBarRepeater.itemAt(i));
|
||||||
|
|
||||||
|
let currentBar = null;
|
||||||
|
|
||||||
|
for (const loader of loaders) {
|
||||||
|
const instances = loader?.item?.barVariants?.instances || [];
|
||||||
|
for (const bar of instances) {
|
||||||
|
if (!bar)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const onFocusedScreen = focusedScreenName && bar.modelData?.name === focusedScreenName;
|
||||||
|
const hasRef = !refPropertyName || !!bar[refPropertyName];
|
||||||
|
|
||||||
|
if (hasRef) {
|
||||||
|
currentBar = bar;
|
||||||
|
|
||||||
|
if (onFocusedScreen)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
@@ -97,9 +123,9 @@ Item {
|
|||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
function open(): string {
|
function open(): string {
|
||||||
const bar = root.getFirstBar();
|
const bar = root.getPreferredBar("controlCenterButtonRef");
|
||||||
if (bar) {
|
if (bar) {
|
||||||
bar.triggerControlCenterOnFocusedScreen();
|
bar.triggerControlCenter();
|
||||||
return "CONTROL_CENTER_OPEN_SUCCESS";
|
return "CONTROL_CENTER_OPEN_SUCCESS";
|
||||||
}
|
}
|
||||||
return "CONTROL_CENTER_OPEN_FAILED";
|
return "CONTROL_CENTER_OPEN_FAILED";
|
||||||
@@ -114,9 +140,14 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggle(): string {
|
function toggle(): string {
|
||||||
const bar = root.getFirstBar();
|
if (root.controlCenterLoader.item?.shouldBeVisible) {
|
||||||
|
root.controlCenterLoader.item.close();
|
||||||
|
return "CONTROL_CENTER_TOGGLE_SUCCESS";
|
||||||
|
}
|
||||||
|
|
||||||
|
const bar = root.getPreferredBar("controlCenterButtonRef");
|
||||||
if (bar) {
|
if (bar) {
|
||||||
bar.triggerControlCenterOnFocusedScreen();
|
bar.triggerControlCenter();
|
||||||
return "CONTROL_CENTER_TOGGLE_SUCCESS";
|
return "CONTROL_CENTER_TOGGLE_SUCCESS";
|
||||||
}
|
}
|
||||||
return "CONTROL_CENTER_TOGGLE_FAILED";
|
return "CONTROL_CENTER_TOGGLE_FAILED";
|
||||||
@@ -131,27 +162,37 @@ Item {
|
|||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
function open(tab: string): string {
|
function open(tab: string): string {
|
||||||
root.dankDashPopoutLoader.active = true;
|
const bar = root.getPreferredBar("clockButtonRef");
|
||||||
if (root.dankDashPopoutLoader.item) {
|
if (!bar)
|
||||||
switch (tab.toLowerCase()) {
|
return "DASH_OPEN_FAILED";
|
||||||
case "media":
|
|
||||||
root.dankDashPopoutLoader.item.currentTabIndex = 1;
|
const dash = root.dankDashPopoutLoader.item;
|
||||||
break;
|
const onSameScreen = dash && dash.shouldBeVisible && dash.triggerScreen?.name === bar.screen?.name;
|
||||||
case "wallpaper":
|
|
||||||
root.dankDashPopoutLoader.item.currentTabIndex = 2;
|
if (!onSameScreen) {
|
||||||
break;
|
bar.triggerWallpaperBrowser();
|
||||||
case "weather":
|
|
||||||
root.dankDashPopoutLoader.item.currentTabIndex = SettingsData.weatherEnabled ? 3 : 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
root.dankDashPopoutLoader.item.currentTabIndex = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
root.dankDashPopoutLoader.item.setTriggerPosition(Screen.width / 2, Theme.barHeight + Theme.spacingS, 100, "center", Screen);
|
|
||||||
root.dankDashPopoutLoader.item.dashVisible = true;
|
|
||||||
return "DASH_OPEN_SUCCESS";
|
|
||||||
}
|
}
|
||||||
return "DASH_OPEN_FAILED";
|
|
||||||
|
if (!root.dankDashPopoutLoader.item)
|
||||||
|
return "DASH_OPEN_FAILED";
|
||||||
|
|
||||||
|
switch (tab.toLowerCase()) {
|
||||||
|
case "media":
|
||||||
|
root.dankDashPopoutLoader.item.currentTabIndex = 1;
|
||||||
|
break;
|
||||||
|
case "wallpaper":
|
||||||
|
root.dankDashPopoutLoader.item.currentTabIndex = 2;
|
||||||
|
break;
|
||||||
|
case "weather":
|
||||||
|
root.dankDashPopoutLoader.item.currentTabIndex = SettingsData.weatherEnabled ? 3 : 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
root.dankDashPopoutLoader.item.currentTabIndex = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
root.dankDashPopoutLoader.item.dashVisible = true;
|
||||||
|
return "DASH_OPEN_SUCCESS";
|
||||||
}
|
}
|
||||||
|
|
||||||
function close(): string {
|
function close(): string {
|
||||||
@@ -163,8 +204,14 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggle(tab: string): string {
|
function toggle(tab: string): string {
|
||||||
const bar = root.getFirstBar();
|
if (root.dankDashPopoutLoader.item?.dashVisible) {
|
||||||
if (bar && bar.triggerWallpaperBrowserOnFocusedScreen()) {
|
root.dankDashPopoutLoader.item.dashVisible = false;
|
||||||
|
return "DASH_TOGGLE_SUCCESS";
|
||||||
|
}
|
||||||
|
|
||||||
|
const bar = root.getPreferredBar("clockButtonRef");
|
||||||
|
if (bar) {
|
||||||
|
bar.triggerWallpaperBrowser();
|
||||||
if (root.dankDashPopoutLoader.item) {
|
if (root.dankDashPopoutLoader.item) {
|
||||||
switch (tab.toLowerCase()) {
|
switch (tab.toLowerCase()) {
|
||||||
case "media":
|
case "media":
|
||||||
@@ -521,8 +568,9 @@ Item {
|
|||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
function wallpaper(): string {
|
function wallpaper(): string {
|
||||||
const bar = root.getFirstBar();
|
const bar = root.getPreferredBar("clockButtonRef");
|
||||||
if (bar && bar.triggerWallpaperBrowserOnFocusedScreen()) {
|
if (bar) {
|
||||||
|
bar.triggerWallpaperBrowser();
|
||||||
return "SUCCESS: Toggled wallpaper browser";
|
return "SUCCESS: Toggled wallpaper browser";
|
||||||
}
|
}
|
||||||
return "ERROR: Failed to toggle wallpaper browser";
|
return "ERROR: Failed to toggle wallpaper browser";
|
||||||
|
|||||||
Reference in New Issue
Block a user