aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Semke <alexander.semke@web.de>2016-10-24 19:18:38 (GMT)
committerAlexander Semke <alexander.semke@web.de>2016-10-24 19:18:38 (GMT)
commit270f9bfc00ea0147185d0045eba1c659238fca4c (patch)
treea7253e787566ab0c4c504358cecab8317f16cf1d
parent4ed136409c34ee699f0117d54c267931c8d2b952 (diff)
Save session as a plain script file if the user asked to.
BUG: 348338
-rw-r--r--src/cantor_part.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/cantor_part.cpp b/src/cantor_part.cpp
index 6654360..bf822e3 100644
--- a/src/cantor_part.cpp
+++ b/src/cantor_part.cpp
@@ -453,8 +453,9 @@ bool CantorPart::saveFile()
void CantorPart::fileSaveAs()
{
- // this slot is called whenever the File->Save As menu is selected,
- QString filter=i18n("Cantor Worksheet (*.cws)");
+ // this slot is called whenever the File->Save As menu is selected
+ QString worksheetFilter = i18n("Cantor Worksheet (*.cws)");
+ QString filter = worksheetFilter;
//if the backend supports scripts, also append their scriptFile endings to the filter
Cantor::Backend * const backend=m_worksheet->session()->backend();
@@ -464,13 +465,16 @@ void CantorPart::fileSaveAs()
filter+=QLatin1Char('\n')+e->scriptFileFilter();
}
- QString file_name = QFileDialog::getSaveFileName(widget(), i18n("Save as"), QString(), filter);
- if (!file_name.isEmpty()) {
- if (!file_name.endsWith(QLatin1String(".cws")) &&
- !file_name.endsWith(QLatin1String(".mws")))
- file_name += QLatin1String(".cws");
+ QString selectedFilter;
+ QString file_name = QFileDialog::getSaveFileName(widget(), i18n("Save as"), QString(), filter, &selectedFilter);
+ if (file_name.isEmpty())
+ return;
+
+ //depending on user's selection, save as a worksheet or as a plain script file
+ if (selectedFilter == worksheetFilter)
saveAs(QUrl::fromLocalFile(file_name));
- }
+ else
+ m_worksheet->savePlain(file_name);
updateCaption();
}