Bug 92103 - image viewer save warning should offer cancel and saveas
Summary: image viewer save warning should offer cancel and saveas
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: ImageEditor-Save (show other bugs)
Version: 0.7.0
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-26 00:15 UTC by Richard Taylor
Modified: 2022-02-02 16:34 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 7.5.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Taylor 2004-10-26 00:15:34 UTC
Version:           0.7-beta1 (using KDE 3.3.0, Gentoo)
Compiler:          gcc version 3.3.3 20040412 (Gentoo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)
OS:                Linux (i686) release 2.6.8-gentoo-r3

When a image is changed and the Next Image button is pressed a warning dialog appears. The dialog offers on Save Yes/No. It would be nice if it also offered Cancel and SaveAs.
Comment 1 Joern Ahrens 2004-11-27 23:33:32 UTC
CVS commit by jahrens: 


I've looked at some dialogs of this kind (kolourpaint, kate, kwrite...)
and so I've changed the warning dialog to the behavior I found there.
The dialog lets the user now choose, if he wants to 
- save (the changes)
- discard (the changes)
- cancel (the operation)
For saveAs you have to click cancel and choose saveAs from the file
menu.

BUG: 92103
CCMAIL: joern.ahrens@kdemail.net


  M +48 -22    imagewindow.cpp   1.61
  M +2 -1      imagewindow.h   1.29


--- kdeextragear-3/digikam/utilities/imageeditor/imagewindow.cpp  #1.60:1.61
@@ -420,5 +420,6 @@ void ImageWindow::slotLoadCurrent()
 void ImageWindow::slotLoadNext()
 {
-    promptUserSave();
+    if(!promptUserSave())
+        return;
 
     KURL::List::iterator it = m_urlList.find(m_urlCurrent);
@@ -436,5 +437,6 @@ void ImageWindow::slotLoadNext()
 void ImageWindow::slotLoadPrev()
 {
-    promptUserSave();
+    if(!promptUserSave())
+        return;
 
     KURL::List::iterator it = m_urlList.find(m_urlCurrent);
@@ -453,5 +455,7 @@ void ImageWindow::slotLoadPrev()
 void ImageWindow::slotLoadFirst()
 {
-    promptUserSave();
+    if(!promptUserSave())
+        return;
+    
     m_urlCurrent = m_urlList.first();
     slotLoadCurrent();
@@ -460,5 +464,7 @@ void ImageWindow::slotLoadFirst()
 void ImageWindow::slotLoadLast()
 {
-    promptUserSave();
+    if(!promptUserSave())
+        return;
+    
     m_urlCurrent = m_urlList.last();
     slotLoadCurrent();
@@ -725,4 +731,9 @@ void ImageWindow::slotFilePrint()
 void ImageWindow::slotSave()
 {
+    save();
+}
+
+bool ImageWindow::save()
+{
     QString tmpFile = locateLocal("tmp", m_urlCurrent.filename());
 
@@ -730,10 +741,10 @@ void ImageWindow::slotSave()
                                           m_PNGCompression, m_TIFFCompression);
 
-    if (result == false)
+    if (!result)
     {
         KMessageBox::error(this, i18n("Failed to save file\n\"%1\" to album\n\"%2\".")
                            .arg(m_urlCurrent.filename())
                            .arg(m_urlCurrent.path().section('/', -2, -2)));
-        return;
+        return false;
     }
 
@@ -758,14 +769,15 @@ void ImageWindow::slotSave()
         QString errMsg(SyncJob::lastErrorMsg());
         KMessageBox::error(this, errMsg, errMsg);
+        return false;
     }
-    else
-    {
+
         emit signalFileModified(m_urlCurrent);
         QTimer::singleShot(0, this, SLOT(slotLoadCurrent()));
-    }
+    
+    return true;
 }
 
 void ImageWindow::slotSaveAs()
- {
+{
     // Get the new filename.
 
@@ -1007,16 +1019,28 @@ void ImageWindow::slotEscapePressed()
 }
 
-void ImageWindow::promptUserSave()
+bool ImageWindow::promptUserSave()
 {
     if (m_guiClient->m_saveAction->isEnabled())
     {
         int result =
-            KMessageBox::warningYesNo(this,
+            KMessageBox::warningYesNoCancel(this,
                                       i18n("The image \"%1\" has been modified.\n"
                                            "Do you want to save it?")
-                                      .arg(m_urlCurrent.filename()));
+                                                 .arg(m_urlCurrent.filename()),
+                                            QString::null,
+                                            KStdGuiItem::save(),
+                                            KStdGuiItem::discard());
         if (result == KMessageBox::Yes)
-            slotSave();
+        {
+            return save();
+        }
+        else if (result == KMessageBox::No)
+        {
+            return true;
+        }
+        else
+            return false;
     }
+    return true;
 }
 
@@ -1025,5 +1049,7 @@ void ImageWindow::closeEvent(QCloseEvent
     if (!e) return;
 
-    promptUserSave();
+    if(!promptUserSave())
+        return;
+    
     e->accept();
 }

--- kdeextragear-3/digikam/utilities/imageeditor/imagewindow.h  #1.28:1.29
@@ -104,7 +104,8 @@ private:
     void readSettings();
     void saveSettings();
-    void promptUserSave();
+    bool promptUserSave();
     void plugActionAccel(KAction* action);
     void unplugActionAccel(KAction* action);
+    bool save();
 
 signals: