MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / onSaveScriptClicked

Method onSaveScriptClicked

Gui/ScriptEditor.cpp:399–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399void
400ScriptEditor::onSaveScriptClicked()
401{
402 std::vector<std::string> filters;
403
404 filters.push_back("py");
405 SequenceFileDialog dialog(this, filters, false, SequenceFileDialog::eFileDialogModeSave, getGui()->getLastSaveProjectDirectory().toStdString(),
406 getGui(), false);
407
408 if ( dialog.exec() ) {
409 QDir currentDir = dialog.currentDirectory();
410 getGui()->updateLastSavedProjectPath( currentDir.absolutePath() );
411
412 QString fileName( QString::fromUtf8( dialog.selectedFiles().c_str() ) );
413 QFile file(fileName);
414 if ( file.open(QIODevice::ReadWrite) ) {
415 QTextStream ts(&file);
416 ts << _imp->inputEdit->toPlainText();
417 } else {
418 Dialogs::errorDialog( tr("Operation failed").toStdString(), tr("Failure to save the file").toStdString() );
419 }
420 }
421}
422
423class InputScriptCommand
424 : public QUndoCommand

Callers

nothing calls this directly

Calls 9

getGuiFunction · 0.85
toStdStringMethod · 0.80
currentDirectoryMethod · 0.80
absolutePathMethod · 0.80
selectedFilesMethod · 0.80
push_backMethod · 0.45
execMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected