Fix toolbox not initializing due to enabledChanged signal

The Connections in qml is a QObject and it has an enabledChanged signal by default.
Therefore, we cannot really use the Connections to connect to the enabledChanged signal of e.g.
a python class, because qml complains that there is already a function named enabledChanged() in
the Connections.

To circumvent that, we can simply rename the enabledChanged() signal of the Toolbox to
toolboxEnabledChanged().
This commit is contained in:
Kostas Karmas 2021-03-30 08:51:58 +02:00
parent 7827b36ab7
commit 189d00c3ed
2 changed files with 5 additions and 5 deletions

View file

@ -117,7 +117,7 @@ Item
Connections Connections
{ {
target: toolbox target: toolbox
function onEnabledChanged() { isEnabled = toolbox.isEnabled(model.id) } function onToolboxEnabledChanged() { isEnabled = toolbox.isEnabled(model.id) }
} }
} }
} }

View file

@ -122,7 +122,7 @@ class Toolbox(QObject, Extension):
onIsDownloadingChanged = pyqtSignal() onIsDownloadingChanged = pyqtSignal()
restartRequiredChanged = pyqtSignal() restartRequiredChanged = pyqtSignal()
installChanged = pyqtSignal() installChanged = pyqtSignal()
enabledChanged = pyqtSignal() toolboxEnabledChanged = pyqtSignal()
# UI changes # UI changes
viewChanged = pyqtSignal() viewChanged = pyqtSignal()
@ -208,7 +208,7 @@ class Toolbox(QObject, Extension):
self._dialog.show() self._dialog.show()
# Apply enabled/disabled state to installed plugins # Apply enabled/disabled state to installed plugins
self.enabledChanged.emit() self.toolboxEnabledChanged.emit()
def _createDialog(self, qml_name: str) -> Optional[QObject]: def _createDialog(self, qml_name: str) -> Optional[QObject]:
Logger.log("d", "Marketplace: Creating dialog [%s].", qml_name) Logger.log("d", "Marketplace: Creating dialog [%s].", qml_name)
@ -442,7 +442,7 @@ class Toolbox(QObject, Extension):
@pyqtSlot(str) @pyqtSlot(str)
def enable(self, plugin_id: str) -> None: def enable(self, plugin_id: str) -> None:
self._plugin_registry.enablePlugin(plugin_id) self._plugin_registry.enablePlugin(plugin_id)
self.enabledChanged.emit() self.toolboxEnabledChanged.emit()
Logger.log("i", "%s was set as 'active'.", plugin_id) Logger.log("i", "%s was set as 'active'.", plugin_id)
self._restart_required = True self._restart_required = True
self.restartRequiredChanged.emit() self.restartRequiredChanged.emit()
@ -450,7 +450,7 @@ class Toolbox(QObject, Extension):
@pyqtSlot(str) @pyqtSlot(str)
def disable(self, plugin_id: str) -> None: def disable(self, plugin_id: str) -> None:
self._plugin_registry.disablePlugin(plugin_id) self._plugin_registry.disablePlugin(plugin_id)
self.enabledChanged.emit() self.toolboxEnabledChanged.emit()
Logger.log("i", "%s was set as 'deactive'.", plugin_id) Logger.log("i", "%s was set as 'deactive'.", plugin_id)
self._restart_required = True self._restart_required = True
self.restartRequiredChanged.emit() self.restartRequiredChanged.emit()