NSectionEditor: fix unresponsive widget settings dialog when pressing apply

This commit is contained in:
Lysec
2026-01-26 12:59:32 +01:00
parent 92aeeb2d79
commit 884d4e49a7
+70 -59
View File
@@ -128,6 +128,75 @@ NBox {
return false;
}
// Open settings for a widget
function openWidgetSettings(index, widgetData) {
// Check if this is a plugin widget
var isPlugin = root.widgetRegistry && root.widgetRegistry.isPluginWidget(widgetData.id);
if (isPlugin) {
// Handle plugin settings - emit signal for parent to handle
var pluginId = widgetData.id.replace("plugin:", "");
var manifest = PluginRegistry.getPluginManifest(pluginId);
if (!manifest || !manifest.entryPoints?.settings) {
Logger.e("NSectionEditor", "Plugin settings not found for:", pluginId);
return;
}
// Emit signal to request opening plugin settings
root.openPluginSettingsRequested(manifest);
} else {
// Handle core widget settings
var component = Qt.createComponent(Qt.resolvedUrl(root.settingsDialogComponent));
function instantiateAndOpen() {
if (root._activeDialog) {
try {
root._activeDialog.close();
root._activeDialog.destroy();
} catch (e) {}
root._activeDialog = null;
}
var dialog = component.createObject(Overlay.overlay, {
"widgetIndex": index,
"widgetData": widgetData,
"widgetId": widgetData.id,
"sectionId": root.sectionId,
"screen": root.screen
});
if (dialog) {
root._activeDialog = dialog;
dialog.updateWidgetSettings.connect(root.updateWidgetSettings);
dialog.closed.connect(() => {
if (root._activeDialog === dialog) {
root._activeDialog = null;
dialog.destroy();
}
});
dialog.open();
} else {
Logger.e("NSectionEditor", "Failed to create settings dialog instance");
}
}
if (component.status === Component.Ready) {
instantiateAndOpen();
} else if (component.status === Component.Error) {
Logger.e("NSectionEditor", component.errorString());
} else {
component.statusChanged.connect(function() {
if (component.status === Component.Ready) {
instantiateAndOpen();
} else if (component.status === Component.Error) {
Logger.e("NSectionEditor", component.errorString());
}
});
}
}
}
ColumnLayout {
anchors.fill: parent
anchors.margins: Style.marginL
@@ -433,65 +502,7 @@ NBox {
colorBgHover: Qt.alpha(Color.mOnPrimary, Style.opacityLight)
colorFgHover: Color.mOnPrimary
onClicked: {
// Check if this is a plugin widget
var isPlugin = root.widgetRegistry && root.widgetRegistry.isPluginWidget(modelData.id);
if (isPlugin) {
// Handle plugin settings - emit signal for parent to handle
var pluginId = modelData.id.replace("plugin:", "");
var manifest = PluginRegistry.getPluginManifest(pluginId);
if (!manifest || !manifest.entryPoints?.settings) {
Logger.e("NSectionEditor", "Plugin settings not found for:", pluginId);
return;
}
// Emit signal to request opening plugin settings
root.openPluginSettingsRequested(manifest);
} else {
// Handle core widget settings
var component = Qt.createComponent(Qt.resolvedUrl(root.settingsDialogComponent));
function instantiateAndOpen() {
if (root._activeDialog) {
root._activeDialog.close();
root._activeDialog.destroy();
root._activeDialog = null;
}
var dialog = component.createObject(Overlay.overlay, {
"widgetIndex": index,
"widgetData": modelData,
"widgetId": modelData.id,
"sectionId": root.sectionId,
"screen": root.screen
});
if (dialog) {
root._activeDialog = dialog;
dialog.updateWidgetSettings.connect(root.updateWidgetSettings);
dialog.closed.connect(() => {
if (root._activeDialog === dialog) {
root._activeDialog = null;
dialog.destroy();
}
});
dialog.open();
} else {
Logger.e("NSectionEditor", "Failed to create settings dialog instance");
}
}
if (component.status === Component.Ready) {
instantiateAndOpen();
} else if (component.status === Component.Error) {
Logger.e("NSectionEditor", component.errorString());
} else {
component.statusChanged.connect(function () {
if (component.status === Component.Ready) {
instantiateAndOpen();
} else if (component.status === Component.Error) {
Logger.e("NSectionEditor", component.errorString());
}
});
}
}
root.openWidgetSettings(index, modelData);
}
}
}