Skip to content

Commit

Permalink
fix(ui): update style on edit data, check save status
Browse files Browse the repository at this point in the history
  • Loading branch information
azagoruyko committed Aug 15, 2024
1 parent 933ee04 commit 01d7419
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,9 @@ def editData(self, attrWidgetIndex):
def save(data):
@AttributesWidget._wrapper
def _save(_, attrWidgetIndex):
attr.setData(data)
attr.setData(data)
self.updateWidget(attrWidgetIndex)
self.updateWidgetStyle(attrWidgetIndex)
_save(self, attrWidgetIndex)

attr, _, _ = self._attributeAndWidgets[attrWidgetIndex]
Expand Down Expand Up @@ -892,19 +893,27 @@ def saveModule(self):
if not os.path.exists(dirname):
os.makedirs(dirname)

item.module.saveToFile(outputPath)
item.emitDataChanged() # path changed
self.mainWindow.attributesTabWidget.updateWidgetStyles()
try:
item.module.saveToFile(outputPath)
except Exception as e:
QMessageBox.critical(self, "Rig Builder", "Can't save module '{}': {}".format(item.module.name(), str(e)))
else:
item.emitDataChanged() # path changed
self.mainWindow.attributesTabWidget.updateWidgetStyles()

def saveAsModule(self):
for item in self.selectedItems():
outputDir = os.path.dirname(item.module.filePath()) or RigBuilderLocalPath+"/modules"
outputPath, _ = QFileDialog.getSaveFileName(mainWindow, "Save as "+item.module.name(), outputDir + "/" +item.module.name(), "*.xml")

if outputPath:
item.module.saveToFile(outputPath, newUid=True)
item.emitDataChanged() # path and uid changed
self.mainWindow.attributesTabWidget.updateWidgetStyles()
try:
item.module.saveToFile(outputPath, newUid=True)
except Exception as e:
QMessageBox.critical(self, "Rig Builder", "Can't save module '{}': {}".format(item.module.name(), str(e)))
else:
item.emitDataChanged() # path and uid changed
self.mainWindow.attributesTabWidget.updateWidgetStyles()

def embedModule(self):
selectedItems = self.selectedItems()
Expand Down

0 comments on commit 01d7419

Please sign in to comment.