[Kst] kdeextragear-2/kst/kst

Rick Chern rchern at interchange.ubc.ca
Wed Aug 25 01:34:30 CEST 2004


CVS commit by rchern: 

Make Save As behaviour more like other applications
- add .kst if not included in filename
- if file already exists, keep on opening Save As dialog until save is successful or it is cancelled


  M +24 -17    kst.cpp   1.217


--- kdeextragear-2/kst/kst/kst.cpp  #1.216:1.217
@@ -868,4 +868,5 @@ bool KstApp::slotFileSaveAs() {
   slotUpdateStatusMsg(i18n("Saving file with a new filename..."));
 
+  while (true) {
   QString newName=
     KFileDialog::getSaveFileName(QDir::currentDirPath(),
@@ -873,12 +874,19 @@ bool KstApp::slotFileSaveAs() {
                                  this, i18n("Save As"));
   if(!newName.isEmpty()) {
-    if (doc->saveDocument(newName)) {
-      addRecentFile(newName);
-
-      QFileInfo saveAsInfo(newName);
+      QRegExp extension("*.kst", false, true);
+      QString longName = newName;
+      if (!extension.exactMatch(newName)) {
+        longName = newName + QString(".kst");
+      }
+      if (doc->saveDocument(longName)) {
+        addRecentFile(longName);
+        QFileInfo saveAsInfo(longName);
       doc->setTitle(saveAsInfo.fileName());
       doc->setAbsFilePath(saveAsInfo.absFilePath());
 
       setCaption(kapp->caption() + ": " + doc->title());
+
+        slotUpdateStatusMsg(i18n("Ready"));
+        return true;
     }
   } else {
@@ -886,6 +894,5 @@ bool KstApp::slotFileSaveAs() {
     return false;
   }
-  slotUpdateStatusMsg(i18n("Ready"));
-  return true;
+  }
 }
 





More information about the Kst mailing list