mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
bar-plugins: fixed bar not refreshing after install/uninstall
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import qs.Commons
|
||||
import qs.Services.Noctalia
|
||||
@@ -234,14 +233,6 @@ ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
// Downloaded indicator
|
||||
NIcon {
|
||||
icon: "circle-check"
|
||||
pointSize: Style.baseWidgetSize * 0.5
|
||||
color: Color.mPrimary
|
||||
visible: modelData.downloaded === true
|
||||
}
|
||||
|
||||
// Open plugin page button
|
||||
NIconButton {
|
||||
icon: "external-link"
|
||||
@@ -250,22 +241,21 @@ ColumnLayout {
|
||||
onClicked: Qt.openUrlExternally("https://noctalia.dev/plugins/" + modelData.id + "/")
|
||||
}
|
||||
|
||||
// Install/Uninstall button
|
||||
// Downloaded indicator
|
||||
NIcon {
|
||||
icon: "circle-check"
|
||||
pointSize: Style.baseWidgetSize * 0.5
|
||||
color: Color.mPrimary
|
||||
visible: modelData.downloaded === true
|
||||
}
|
||||
|
||||
// Install button (only shown when not downloaded)
|
||||
NIconButton {
|
||||
icon: modelData.downloaded ? "trash" : "download"
|
||||
visible: modelData.downloaded === false
|
||||
icon: "download"
|
||||
baseSize: Style.baseWidgetSize * 0.7
|
||||
tooltipText: modelData.downloaded ? I18n.tr("common.uninstall") : I18n.tr("common.install")
|
||||
onClicked: {
|
||||
if (modelData.downloaded) {
|
||||
// Construct composite key for available plugins
|
||||
var pluginData = Object.assign({}, modelData);
|
||||
pluginData.compositeKey = PluginRegistry.generateCompositeKey(modelData.id, modelData.source?.url || "");
|
||||
uninstallDialog.pluginToUninstall = pluginData;
|
||||
uninstallDialog.open();
|
||||
} else {
|
||||
installPlugin(modelData);
|
||||
}
|
||||
}
|
||||
tooltipText: I18n.tr("common.install")
|
||||
onClicked: installPlugin(modelData)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,64 +336,6 @@ ColumnLayout {
|
||||
}
|
||||
}
|
||||
|
||||
// Uninstall confirmation dialog
|
||||
Popup {
|
||||
id: uninstallDialog
|
||||
parent: Overlay.overlay
|
||||
modal: true
|
||||
dim: false
|
||||
anchors.centerIn: parent
|
||||
width: 400 * Style.uiScaleRatio
|
||||
padding: Style.marginL
|
||||
|
||||
property var pluginToUninstall: null
|
||||
|
||||
background: Rectangle {
|
||||
color: Color.mSurface
|
||||
radius: Style.radiusS
|
||||
border.color: Color.mPrimary
|
||||
border.width: Style.borderM
|
||||
}
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
width: parent.width
|
||||
spacing: Style.marginL
|
||||
|
||||
NHeader {
|
||||
label: I18n.tr("panels.plugins.uninstall-dialog-title")
|
||||
description: I18n.tr("panels.plugins.uninstall-dialog-description", {
|
||||
"plugin": uninstallDialog.pluginToUninstall?.name || ""
|
||||
})
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: Style.marginM
|
||||
Layout.fillWidth: true
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
NButton {
|
||||
text: I18n.tr("common.cancel")
|
||||
onClicked: uninstallDialog.close()
|
||||
}
|
||||
|
||||
NButton {
|
||||
text: I18n.tr("common.uninstall")
|
||||
backgroundColor: Color.mPrimary
|
||||
textColor: Color.mOnPrimary
|
||||
onClicked: {
|
||||
if (uninstallDialog.pluginToUninstall) {
|
||||
uninstallPlugin(uninstallDialog.pluginToUninstall.compositeKey);
|
||||
uninstallDialog.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Timer to check for updates after refresh starts
|
||||
Timer {
|
||||
id: checkUpdatesTimer
|
||||
@@ -433,27 +365,6 @@ ColumnLayout {
|
||||
});
|
||||
}
|
||||
|
||||
function uninstallPlugin(pluginId) {
|
||||
var manifest = PluginRegistry.getPluginManifest(pluginId);
|
||||
var pluginName = manifest?.name || pluginId;
|
||||
|
||||
ToastService.showNotice(I18n.tr("panels.plugins.title"), I18n.tr("panels.plugins.uninstalling", {
|
||||
"plugin": pluginName
|
||||
}));
|
||||
|
||||
PluginService.uninstallPlugin(pluginId, function (success, error) {
|
||||
if (success) {
|
||||
ToastService.showNotice(I18n.tr("panels.plugins.title"), I18n.tr("panels.plugins.uninstall-success", {
|
||||
"plugin": pluginName
|
||||
}));
|
||||
} else {
|
||||
ToastService.showError(I18n.tr("panels.plugins.title"), I18n.tr("panels.plugins.uninstall-error", {
|
||||
"error": error || "Unknown error"
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Listen to plugin service signals
|
||||
Connections {
|
||||
target: PluginService
|
||||
|
||||
@@ -457,6 +457,8 @@ ColumnLayout {
|
||||
var manifest = PluginRegistry.getPluginManifest(pluginId);
|
||||
var pluginName = manifest?.name || pluginId;
|
||||
|
||||
BarService.widgetsRevision++;
|
||||
|
||||
ToastService.showNotice(I18n.tr("panels.plugins.title"), I18n.tr("panels.plugins.uninstalling", {
|
||||
"plugin": pluginName
|
||||
}));
|
||||
|
||||
@@ -517,7 +517,7 @@ Singleton {
|
||||
var manifest = PluginRegistry.getPluginManifest(compositeKey);
|
||||
if (manifest && manifest.entryPoints && manifest.entryPoints.barWidget) {
|
||||
var widgetId = "plugin:" + compositeKey;
|
||||
addWidgetToBar(widgetId, "right"); // Default to right section
|
||||
addWidgetToBar(widgetId, "right");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -527,6 +527,7 @@ Singleton {
|
||||
enabled: true
|
||||
});
|
||||
root.pluginEnabled(compositeKey);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -604,6 +605,11 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
// Signal the bar to refresh if widgets were removed
|
||||
if (changed) {
|
||||
BarService.widgetsRevision++;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -730,6 +736,9 @@ Singleton {
|
||||
// Register with BarWidgetRegistry
|
||||
BarWidgetRegistry.registerPluginWidget(pluginId, widgetComponent, manifest.metadata);
|
||||
Logger.i("PluginService", "Loaded bar widget for plugin:", pluginId);
|
||||
|
||||
// Now that the widget is registered, bump widgetsRevision so the bar can render it
|
||||
BarService.widgetsRevision++;
|
||||
} else if (widgetComponent.status === Component.Error) {
|
||||
root.recordPluginError(pluginId, "barWidget", widgetComponent.errorString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user