[Kstars-devel] kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Tue Feb 22 05:35:03 CET 2005


CVS commit by harris: 

Warn user if they try to overwrite an existing file, in three situations:
+ Saving sky image
+ Saving internet image from popup menu
+ Saving Script in script builder tool

These changes add i18n() strings, but the strings are identical to ones that 
already exist in fitsviewer.cpp, so they do not break strings freeze.

CCMAIL: kstars-devel at kde.org


  M +8 -3      imageviewer.cpp   1.21
  M +12 -0     kstarsactions.cpp   1.126
  M +15 -3     tools/scriptbuilder.cpp   1.43


--- kdeedu/kstars/kstars/imageviewer.cpp  #1.20:1.21
@@ -207,8 +207,13 @@ void ImageViewer::saveFileToDisc()
         {
                 QFile f (newURL.directory() + "/" +  newURL.fileName());
-                kdDebug()<<"Saving to :"<<f.name()<<endl;
                 if (f.exists())
                 {
-                    kdDebug()<<"Warning! Remove existing file "<< f.name()<<endl;
+                        int r=KMessageBox::warningContinueCancel(static_cast<QWidget *>(parent()),
+                                                                        i18n( "A file named \"%1\" already exists. "
+                                                                                        "Overwrite it?" ).arg(newURL.fileName()),
+                                                                        i18n( "Overwrite File?" ),
+                                                                        i18n( "&Overwrite" ) );
+                        if(r==KMessageBox::Cancel) return;
+                        
                     f.remove();
                 }

--- kdeedu/kstars/kstars/kstarsactions.cpp  #1.125:1.126
@@ -409,4 +409,16 @@ void KStars::slotExportImage() {
         KURL fileURL = KFileDialog::getSaveURL( QDir::homeDirPath(), "image/png image/jpeg image/gif image/x-portable-pixmap image/x-bmp" );
 
+        //Warn user if file exists!
+        if (QFile::exists(fileURL.path()))
+        {
+                int r=KMessageBox::warningContinueCancel(static_cast<QWidget *>(parent()),
+                                                                i18n( "A file named \"%1\" already exists. "
+                                                                                "Overwrite it?" ).arg(fileURL.fileName()),
+                                                                i18n( "Overwrite File?" ),
+                                                                i18n( "&Overwrite" ) );
+                
+                if(r==KMessageBox::Cancel) return;
+        }
+        
         exportImage( fileURL.url(), map()->width(), map()->height() );
 }

--- kdeedu/kstars/kstars/tools/scriptbuilder.cpp  #1.42:1.43
@@ -760,8 +760,20 @@ void ScriptBuilder::slotSave() {
                 currentDir = currentFileURL.directory();
 
-                if ( currentFileURL.isLocalFile() )
+                if ( currentFileURL.isLocalFile() ) {
                         fname = currentFileURL.path();
-                else
+                        
+                        //Warn user if file exists
+                        if (QFile::exists(currentFileURL.path())) {
+                                int r=KMessageBox::warningContinueCancel(static_cast<QWidget *>(parent()),
+                                                i18n( "A file named \"%1\" already exists. "
+                                                                "Overwrite it?" ).arg(currentFileURL.fileName()),
+                                                i18n( "Overwrite File?" ),
+                                                i18n( "&Overwrite" ) );
+                
+                                if(r==KMessageBox::Cancel) return;
+                        }
+                } else {
                         fname = tmpfile.name();
+                }
 
                 if ( fname.right( 7 ).lower() != ".kstars" ) fname += ".kstars";




More information about the Kstars-devel mailing list