aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-07-03 20:24:37 +0200
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-07-03 20:26:15 +0200
commite28573e96800e0f316a8404b8c02c60c4597159b (patch)
tree71e06e848e93c0868c5176018f8bd791be12375e /qtmips_gui
parent59adcfe30f70abe9f493d65f98ec54c59e17d9ce (diff)
downloadqtmips-e28573e96800e0f316a8404b8c02c60c4597159b.tar.gz
qtmips-e28573e96800e0f316a8404b8c02c60c4597159b.tar.bz2
qtmips-e28573e96800e0f316a8404b8c02c60c4597159b.zip
Emscripten version does not wait for dialog->exec(), proces selected value by signal.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/mainwindow.cpp20
-rw-r--r--qtmips_gui/mainwindow.h3
2 files changed, 17 insertions, 6 deletions
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index b40bbfc..7a76dc2 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -574,21 +574,29 @@ void MainWindow::save_source_as() {
QMessageBox::critical(this, "QtMips Error", tr("Cannot save file '%1'.").arg(fn));
return;
}
+ int idx = central_window->indexOf(current_srceditor);
+ if (idx >= 0)
+ central_window->setTabText(idx, current_srceditor->title());
+ update_open_file_list();
#else
QInputDialog *dialog = new QInputDialog(this);
dialog->setWindowTitle("Select file name");
dialog->setLabelText("File name:");
dialog->setTextValue("unknow.s");
dialog->setMinimumSize(QSize(200, 100));
- int ret = dialog->exec();
- QString text = dialog->textValue();
- delete dialog;
- if (!ret || text.isEmpty())
+ dialog->setAttribute(Qt::WA_DeleteOnClose);
+ connect(dialog, SIGNAL(textValueSelected(QString)),
+ this, SLOT(src_editor_save_to(QString)));
+ dialog->open();
+#endif
+}
+
+void MainWindow::src_editor_save_to(QString filename) {
+ if (filename.isEmpty() || (current_srceditor == nullptr))
return;
- current_srceditor->setFileName(text);
+ current_srceditor->setFileName(filename);
if (!current_srceditor->filename().isEmpty())
save_source();
-#endif
int idx = central_window->indexOf(current_srceditor);
if (idx >= 0)
central_window->setTabText(idx, current_srceditor->title());
diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h
index 94365fe..bd1aa80 100644
--- a/qtmips_gui/mainwindow.h
+++ b/qtmips_gui/mainwindow.h
@@ -106,6 +106,9 @@ protected:
void closeEvent(QCloseEvent *event);
void setCurrentSrcEditor(SrcEditor *srceditor);
+protected slots:
+ void src_editor_save_to(QString filename);
+
private:
Ui::MainWindow *ui;