mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
PluginSystem: added ability to open panel near an item (button)
This commit is contained in:
@@ -900,23 +900,25 @@ Singleton {
|
||||
};
|
||||
|
||||
// ----------------------------------------
|
||||
api.togglePanel = function (screen) {
|
||||
api.togglePanel = function (screen, buttonItem) {
|
||||
// Toggle this plugin's panel on the specified screen
|
||||
// buttonItem: optional, if provided the panel will position near this button
|
||||
if (!screen) {
|
||||
Logger.w("PluginAPI", "No screen available for toggling panel");
|
||||
return false;
|
||||
}
|
||||
return togglePluginPanel(pluginId, screen);
|
||||
return togglePluginPanel(pluginId, screen, buttonItem);
|
||||
};
|
||||
|
||||
// ----------------------------------------
|
||||
api.openPanel = function (screen) {
|
||||
api.openPanel = function (screen, buttonItem) {
|
||||
// Open this plugin's panel on the specified screen
|
||||
// buttonItem: optional, if provided the panel will position near this button
|
||||
if (!screen) {
|
||||
Logger.w("PluginAPI", "No screen available for opening panel");
|
||||
return false;
|
||||
}
|
||||
return openPluginPanel(pluginId, screen);
|
||||
return openPluginPanel(pluginId, screen, buttonItem);
|
||||
};
|
||||
|
||||
// ----------------------------------------
|
||||
@@ -1395,7 +1397,7 @@ Singleton {
|
||||
}
|
||||
|
||||
// Open a plugin's panel (finds a free slot and loads the panel)
|
||||
function openPluginPanel(pluginId, screen) {
|
||||
function openPluginPanel(pluginId, screen, buttonItem) {
|
||||
if (!isPluginLoaded(pluginId)) {
|
||||
Logger.w("PluginService", "Cannot open panel: plugin not loaded:", pluginId);
|
||||
return false;
|
||||
@@ -1416,7 +1418,7 @@ Singleton {
|
||||
if (panel) {
|
||||
// If this slot is already showing this plugin's panel, toggle it
|
||||
if (panel.currentPluginId === pluginId) {
|
||||
panel.toggle();
|
||||
panel.toggle(buttonItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1425,7 +1427,7 @@ Singleton {
|
||||
// Set the pluginId first - when panel opens and panelContent loads,
|
||||
// Component.onCompleted will call loadPluginPanel automatically
|
||||
panel.currentPluginId = pluginId;
|
||||
panel.open();
|
||||
panel.open(buttonItem);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1438,7 +1440,7 @@ Singleton {
|
||||
// Set the pluginId first - when panel opens and panelContent loads,
|
||||
// Component.onCompleted will call loadPluginPanel automatically
|
||||
panel1.currentPluginId = pluginId;
|
||||
panel1.open();
|
||||
panel1.open(buttonItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1447,7 +1449,8 @@ Singleton {
|
||||
}
|
||||
|
||||
// Toggle a plugin's panel - close if open, open if closed
|
||||
function togglePluginPanel(pluginId, screen) {
|
||||
// buttonItem: optional, if provided the panel will position near this button
|
||||
function togglePluginPanel(pluginId, screen, buttonItem) {
|
||||
if (!isPluginLoaded(pluginId)) {
|
||||
Logger.w("PluginService", "Cannot toggle panel: plugin not loaded:", pluginId);
|
||||
return false;
|
||||
@@ -1466,13 +1469,13 @@ Singleton {
|
||||
|
||||
if (panel && panel.currentPluginId === pluginId) {
|
||||
// Panel is open for this plugin - toggle it (close)
|
||||
panel.toggle();
|
||||
panel.toggle(buttonItem);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Panel is not open - open it using the existing logic
|
||||
return openPluginPanel(pluginId, screen);
|
||||
return openPluginPanel(pluginId, screen, buttonItem);
|
||||
}
|
||||
|
||||
// ----- Error tracking functions -----
|
||||
|
||||
Reference in New Issue
Block a user