r16689 by jghali - #10070: Save in Scripter Console uses wrong save directory

scribus-commit scribus-commit at lists.scribus.net
Fri Jun 24 19:13:18 UTC 2011


Author: jghali
Date: Fri Jun 24 19:13:18 2011
New Revision: 16689

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16689
Log:
#10070: Save in Scripter Console uses wrong save directory

Modified:
    branches/Version135/Scribus/scribus/plugins/scriptplugin/pconsole.cpp

Modified: branches/Version135/Scribus/scribus/plugins/scriptplugin/pconsole.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16689&path=/branches/Version135/Scribus/scribus/plugins/scriptplugin/pconsole.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/plugins/scriptplugin/pconsole.cpp (original)
+++ branches/Version135/Scribus/scribus/plugins/scriptplugin/pconsole.cpp Fri Jun 24 19:13:18 2011
@@ -191,14 +191,25 @@
 void PythonConsole::slot_saveAs()
 {
 	QString oldFname = filename;
+	QString dirName  = QDir::homePath();
+	if (!filename.isEmpty())
+	{
+		QFileInfo fInfo(filename);
+		QDir fileDir = fInfo.absoluteDir();
+		if (fileDir.exists())
+			dirName = fileDir.absolutePath();
+	}
 	filename = QFileDialog::getSaveFileName(this,
 			tr("Save the Python Commands in File"),
-			".",
+			dirName,
 			tr("Python Scripts (*.py *.PY)"));
-	if (filename.isNull())
+	if (filename.isEmpty())
+	{
+		filename = oldFname;
 		return;
-	QFile f(filename);
-	if (f.exists())
+	}
+	// #10070 : not needed QFileDialog::getSaveFileName() will ask overwrite confirmation by itself
+	/*if (QFile::exists(filename))
 	{
 		QString fn = QDir::toNativeSeparators(filename);
 		if (ScMessageBox::warning(this, CommonStrings::trWarning,
@@ -208,27 +219,29 @@
 			filename = oldFname;
 			return;
 		}
-	}
+	}*/
 	slot_save();
 }
 
 void PythonConsole::slot_saveOutput()
 {
+	QString dname = QDir::homePath();
 	QString fname = QFileDialog::getSaveFileName(this,
 			tr("Save Current Output"),
-			".",
+			dname,
 			tr("Text Files (*.txt)"));
-	if (fname == QString::null)
+	if (fname.isEmpty())
 		return;
 	QFile f(fname);
-	if (!f.exists())
+	// #10070 : not needed QFileDialog::getSaveFileName() will ask overwrite confirmation by itself
+	/*if (f.exists())
 	{
 		QString fn = QDir::toNativeSeparators(filename);
 		if (QMessageBox::warning(this, CommonStrings::trWarning,
 			"<qt>" + tr(QString("File %1 already exists. Do you want to replace it?").arg(fn).toLocal8Bit().constData()) + "</qt>",
 			QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
 			return;
-	}
+	}*/
 	// save
 	if (f.open(QIODevice::WriteOnly))
 	{




More information about the scribus-commit mailing list