aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-07-03 12:17:31 +0200
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-07-03 12:17:31 +0200
commit50ba585ba00b2037ddd1c3818b49e8412689e094 (patch)
tree76568156384a241e239fda2e1f1c7b69104add8e
parentf33f424ccf7ca57aae95566663c8f31956fbdf8f (diff)
downloadqtmips-50ba585ba00b2037ddd1c3818b49e8412689e094.tar.gz
qtmips-50ba585ba00b2037ddd1c3818b49e8412689e094.tar.bz2
qtmips-50ba585ba00b2037ddd1c3818b49e8412689e094.zip
Implement file save as workaround for emscripten build.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
-rw-r--r--qtmips_gui/mainwindow.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index b93d2ef..306099a 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -570,24 +570,28 @@ void MainWindow::save_source_as() {
if (fileDialog.exec() != QDialog::Accepted)
return;
const QString fn = fileDialog.selectedFiles().first();
- if (current_srceditor->saveFile(fn)) {
- int idx = central_window->indexOf(current_srceditor);
- if (idx >= 0)
- central_window->setTabText(idx, current_srceditor->title());
- } else {
+ if (!current_srceditor->saveFile(fn)) {
QMessageBox::critical(this, "QtMips Error", tr("Cannot save file '%1'.").arg(fn));
+ return;
}
#else
- bool ok;
- QString text = QInputDialog::getText(this, tr("Select file name"),
- tr("File name:"), QLineEdit::Normal,
- "unknow.s", &ok);
- if (ok && !text.isEmpty()) {
- current_srceditor->setFileName(text);
- if (!current_srceditor->filename().isEmpty())
+ 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())
+ return;
+ current_srceditor->setFileName(text);
+ 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());
update_open_file_list();
}