Browse Source

Simplify replace-plugin dialog code

tags/1.9.7
falkTX 9 years ago
parent
commit
4876baaa93
2 changed files with 30 additions and 12 deletions
  1. +10
    -10
      source/carla_host.py
  2. +20
    -2
      source/carla_skin.py

+ 10
- 10
source/carla_host.py View File

@@ -721,8 +721,7 @@ class HostWindow(QMainWindow):
# --------------------------------------------------------------------------------------------------------
# Plugins (menu actions)

@pyqtSlot()
def slot_pluginAdd(self, pluginToReplace = -1):
def showAddPluginDialog(self):
dialog = PluginDatabaseW(self.fParentOrSelf, self.host)

if not dialog.exec_():
@@ -739,17 +738,18 @@ class HostWindow(QMainWindow):
uniqueId = dialog.fRetPlugin['uniqueId']
extraPtr = self.getExtraPtr(dialog.fRetPlugin)

if pluginToReplace >= 0:
if not self.host.replace_plugin(pluginToReplace):
CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to replace plugin"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
return
return (btype, ptype, filename, label, uniqueId, extraPtr)

@pyqtSlot()
def slot_pluginAdd(self):
data = self.showAddPluginDialog()

ok = self.host.add_plugin(btype, ptype, filename, None, label, uniqueId, extraPtr, 0x0)
if data is None:
return

if pluginToReplace >= 0:
self.host.replace_plugin(self.host.get_max_plugin_number())
btype, ptype, filename, label, uniqueId, extraPtr = data

if not ok:
if not self.host.add_plugin(btype, ptype, filename, None, label, uniqueId, extraPtr, 0x0):
CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to load plugin"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)

@pyqtSlot()


+ 20
- 2
source/carla_skin.py View File

@@ -763,6 +763,25 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta):

self.setName(newName)

def showReplaceDialog(self):
data = gCarla.gui.showAddPluginDialog()

if data is None:
return

btype, ptype, filename, label, uniqueId, extraPtr = data

if not self.host.replace_plugin(self.fPluginId):
CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to replace plugin"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
return

ok = self.host.add_plugin(btype, ptype, filename, None, label, uniqueId, extraPtr, 0x0)

self.host.replace_plugin(self.host.get_max_plugin_number())

if not ok:
CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to load plugin"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)

#------------------------------------------------------------------

def activeChanged(self, onOff):
@@ -1083,8 +1102,7 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta):
# Replace

elif actSel == actReplace:
# FIXME
gCarla.gui.slot_pluginAdd(self.fPluginId)
self.showReplaceDialog()

# -------------------------------------------------------------
# Remove


Loading…
Cancel
Save