r23858 by jghali - Simplify code of ScribusMainWindow::reallySaveAsEps()

scribus-commit scribus-commit at lists.scribus.net
Fri May 29 21:28:38 UTC 2020


Author: jghali
Date: Fri May 29 21:28:38 2020
New Revision: 23858

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23858
Log:
Simplify code of ScribusMainWindow::reallySaveAsEps()

Modified:
    trunk/Scribus/scribus/scribus.cpp

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23858&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Fri May 29 21:28:38 2020
@@ -7293,27 +7293,25 @@
 			filename = di.currentPath() + "/" + getFileNameByPage(doc, doc->currentPage()->pageNr(), "eps");
 	}
 	filename = QDir::toNativeSeparators(filename);
-	QString wdir = ".";
-	QString prefsDocDir=m_prefsManager.documentDir();
-	if (!prefsDocDir.isEmpty())
-		wdir = m_prefsManager.prefsFile->getContext("dirs")->get("eps", prefsDocDir);
-	else
-		wdir = m_prefsManager.prefsFile->getContext("dirs")->get("eps", ".");
-	QString fn = CFileDialog( wdir, tr("Save As"), tr("%1;;All Files (*)").arg(m_formatsManager->extensionsForFormat(FormatsManager::EPS)), filename, fdHidePreviewCheckBox | fdNone);
-	if (!fn.isEmpty())
-	{
-		m_prefsManager.prefsFile->getContext("dirs")->set("eps", fn.left(fn.lastIndexOf("/")));
-		if (overwrite(this, fn))
-		{
-			QString epsError;
-			if (!DoSaveAsEps(fn, epsError))
-			{
-				QString message = tr("Cannot write the file: \n%1").arg(fn);
-				if (!epsError.isEmpty())
-					message += QString("\n%1").arg(epsError);
-				ScMessageBox::warning(this, CommonStrings::trWarning, message);
-			}
-		}
+
+	PrefsContext* dirsContext = m_prefsManager.prefsFile->getContext("dirs");
+	QString prefsDocDir = m_prefsManager.documentDir();
+	QString workingDir = dirsContext->get("eps", prefsDocDir.isEmpty() ? "." : prefsDocDir);
+	QString fn = CFileDialog(workingDir, tr("Save As"), tr("%1;;All Files (*)").arg(m_formatsManager->extensionsForFormat(FormatsManager::EPS)), filename, fdHidePreviewCheckBox | fdNone);
+	if (fn.isEmpty())
+		return;
+
+	m_prefsManager.prefsFile->getContext("dirs")->set("eps", fn.left(fn.lastIndexOf("/")));
+	if (!overwrite(this, fn))
+		return;
+
+	QString epsError;
+	if (!DoSaveAsEps(fn, epsError))
+	{
+		QString message = tr("Cannot write the file: \n%1").arg(fn);
+		if (!epsError.isEmpty())
+			message += QString("\n%1").arg(epsError);
+		ScMessageBox::warning(this, CommonStrings::trWarning, message);
 	}
 }
 




More information about the scribus-commit mailing list