88#include < QStringList>
99#include < QTimer>
1010#include < QTextCursor>
11+ #include < QDir>
1112
1213namespace interactive_script_plugin
1314{
@@ -103,6 +104,9 @@ void InteractiveScriptGui::initPlugin(qt_gui_cpp::PluginContext& context)
103104 timer2->start ();
104105 connect (timer2, &QTimer::timeout,
105106 this , &InteractiveScriptGui::updateTf);
107+
108+ // save the configuation at application start, to prevent loading the last subjects's solution
109+ on_save ();
106110}
107111
108112void InteractiveScriptGui::shutdownPlugin ()
@@ -247,7 +251,7 @@ void InteractiveScriptGui::updateTf() {
247251
248252void InteractiveScriptGui::on_save () {
249253 using namespace load_save ;
250- if (auto file = save_dialog (ui_.tabWidget ->currentWidget () == ui_.blockly_tab )) {
254+ /* if(auto file = save_dialog(ui_.tabWidget->currentWidget() == ui_.blockly_tab)) {
251255 switch (file->format) {
252256 case Filename::XML:
253257 save_file(*file, ui_.blockly_widget->xml().toStdString());
@@ -258,12 +262,15 @@ void InteractiveScriptGui::on_save() {
258262 ui_.tabWidget->setCurrentWidget(ui_.code_tab);
259263 break;
260264 }
261- }
265+ }*/
266+
267+ Filename f {" /data/save_" + std::to_string (time (nullptr )) + " .xml" , Filename::XML};
268+ save_file (f, ui_.blockly_widget ->xml ().toStdString ());
262269}
263270
264271void InteractiveScriptGui::on_load () {
265272 using namespace load_save ;
266- if (auto file = load_dialog ()) {
273+ /* if (auto file = load_dialog()) {
267274 switch (file->format) {
268275 case Filename::XML:
269276 ui_.blockly_widget->loadXml(QString::fromStdString(load_file(*file)));
@@ -274,7 +281,11 @@ void InteractiveScriptGui::on_load() {
274281 ui_.tabWidget->setCurrentWidget(ui_.code_tab);
275282 break;
276283 }
277- }
284+ }*/
285+
286+ Filename f {QDir (" /data" , " save_*.xml" ).entryList ().back ().toStdString (), Filename::XML};
287+ ui_.blockly_widget ->loadXml (QString::fromStdString (load_file (f)));
288+ ui_.tabWidget ->setCurrentWidget (ui_.blockly_tab );
278289}
279290
280291bool InteractiveScriptGui::hasConfiguration () const {
0 commit comments