| 367 | } |
| 368 | |
| 369 | void |
| 370 | ScriptEditor::onLoadScriptClicked() |
| 371 | { |
| 372 | std::vector<std::string> filters; |
| 373 | |
| 374 | filters.push_back("py"); |
| 375 | SequenceFileDialog dialog(this, filters, false, SequenceFileDialog::eFileDialogModeOpen, getGui()->getLastLoadProjectDirectory().toStdString(), |
| 376 | getGui(), false); |
| 377 | |
| 378 | if ( dialog.exec() ) { |
| 379 | QDir currentDir = dialog.currentDirectory(); |
| 380 | getGui()->updateLastOpenedProjectPath( currentDir.absolutePath() ); |
| 381 | QString fileName( QString::fromUtf8( dialog.selectedFiles().c_str() ) ); |
| 382 | QFile file(fileName); |
| 383 | if ( file.open(QIODevice::ReadOnly) ) { |
| 384 | QTextStream ts(&file); |
| 385 | QString content = ts.readAll(); |
| 386 | _imp->inputEdit->setPlainText(content); |
| 387 | } else { |
| 388 | Dialogs::errorDialog( tr("Operation failed").toStdString(), tr("Failure to open the file").toStdString() ); |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | void |
| 394 | ScriptEditor::onSaveScriptClicked() |
nothing calls this directly
no test coverage detected