r21083 by fschmid -

scribus-commit scribus-commit at lists.scribus.net
Sun Mar 13 12:44:54 UTC 2016


Author: fschmid
Date: Sun Mar 13 12:44:54 2016
New Revision: 21083

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21083
Log:
Fixed Bug #10220: Configurable directory for .autosaved doc
and Bug #10887: No autosave for unsaved files

Modified:
    trunk/Scribus/scribus/fileloader.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
    trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
    trunk/Scribus/scribus/prefsmanager.cpp
    trunk/Scribus/scribus/prefsstructs.h
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h
    trunk/Scribus/scribus/ui/prefs_documentsetup.cpp
    trunk/Scribus/scribus/ui/prefs_documentsetup.h
    trunk/Scribus/scribus/ui/prefs_documentsetupbase.ui

Modified: trunk/Scribus/scribus/fileloader.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21083&path=/trunk/Scribus/scribus/fileloader.cpp
==============================================================================
--- trunk/Scribus/scribus/fileloader.cpp	(original)
+++ trunk/Scribus/scribus/fileloader.cpp	Sun Mar 13 12:44:54 2016
@@ -237,6 +237,8 @@
 	currDoc->setAutoSaveTime(m_prefsManager->appPrefs.docSetupPrefs.AutoSaveTime);
 	currDoc->setAutoSaveCount(m_prefsManager->appPrefs.docSetupPrefs.AutoSaveCount);
 	currDoc->setAutoSaveKeep(m_prefsManager->appPrefs.docSetupPrefs.AutoSaveKeep);
+	currDoc->setAutoSaveInDocDir(m_prefsManager->appPrefs.docSetupPrefs.AutoSaveLocation);
+	currDoc->setAutoSaveDir(m_prefsManager->appPrefs.docSetupPrefs.AutoSaveDir);
 	m_ReplacedFonts = currDoc->AllFonts->getSubstitutions();
 	//dummyScFaces.clear();
 	bool ret = false;

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21083&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp	Sun Mar 13 12:44:54 2016
@@ -2085,6 +2085,8 @@
 	m_Doc->setAutoSaveTime(attrs.valueAsInt("AutoSaveTime", 600000));
 	m_Doc->setAutoSaveKeep(attrs.valueAsBool("AutoSaveKeep", false));
 	m_Doc->setAutoSaveCount(attrs.valueAsInt("AutoSaveCount", 5));
+	m_Doc->setAutoSaveInDocDir(attrs.valueAsBool("AUtoSaveInDocDir", true));
+	m_Doc->setAutoSaveDir(attrs.valueAsString("AutoSaveDir", ""));
 	double leftScratch;
 	// FIXME A typo in early 1.3cvs (MAR 05) means we must support loading of
 	// FIXME 'ScatchLeft' for a while too. This can be removed in a few months.

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21083&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp	Sun Mar 13 12:44:54 2016
@@ -328,6 +328,8 @@
 	docu.writeAttribute("AutoSaveTime", m_Doc->autoSaveTime());
 	docu.writeAttribute("AutoSaveCount", m_Doc->autoSaveCount());
 	docu.writeAttribute("AutoSaveKeep", static_cast<int>(m_Doc->autoSaveKeep()));
+	docu.writeAttribute("AUtoSaveInDocDir", static_cast<int>(m_Doc->autoSaveInDocDir()));
+	docu.writeAttribute("AutoSaveDir", m_Doc->autoSaveDir());
 	docu.writeAttribute("ScratchBottom", m_Doc->scratch()->bottom());
 	docu.writeAttribute("ScratchLeft", m_Doc->scratch()->left());
 	docu.writeAttribute("ScratchRight", m_Doc->scratch()->right());

Modified: trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21083&path=/trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp	(original)
+++ trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp	Sun Mar 13 12:44:54 2016
@@ -1776,11 +1776,19 @@
 		getTextChunkWidth(e, chunkWidth);
 	for(QDomNode n = e.firstChild(); !n.isNull(); n = n.nextSibling())
 	{
-		if (n.isElement() && (parseTagName(n.toElement()) == "tspan"))
-		{
-			QList<PageItem*> el = parseTextSpan(n.toElement(), currentPos, chunkWidth);
-			for (int ec = 0; ec < el.count(); ++ec)
-				GElements.append(el.at(ec));
+		if (n.isElement())
+		{
+			if (parseTagName(n.toElement()) == "tspan")
+			{
+				QList<PageItem*> el = parseTextSpan(n.toElement(), currentPos, chunkWidth);
+				for (int ec = 0; ec < el.count(); ++ec)
+					GElements.append(el.at(ec));
+			}
+			else if (parseTagName(n.toElement()) == "textPath")
+			{
+				GElements = parseText(n.toElement());
+				break;
+			}
 		}
 		if (n.isText())
 		{

Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21083&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp	(original)
+++ trunk/Scribus/scribus/prefsmanager.cpp	Sun Mar 13 12:44:54 2016
@@ -327,6 +327,8 @@
 	appPrefs.docSetupPrefs.AutoSaveCount = 5;
 	appPrefs.docSetupPrefs.AutoSaveKeep = false;
 	appPrefs.docSetupPrefs.saveCompressed = false;
+	appPrefs.docSetupPrefs.AutoSaveLocation = true;
+	appPrefs.docSetupPrefs.AutoSaveDir = "";
 	int dpi = qApp->desktop()->logicalDpiX();
 	if ((dpi < 60) || (dpi > 200))
 		dpi = 72;
@@ -1382,6 +1384,8 @@
 	deDocumentSetup.setAttribute("AutoSaveTime", appPrefs.docSetupPrefs.AutoSaveTime);
 	deDocumentSetup.setAttribute("AutoSaveCount", appPrefs.docSetupPrefs.AutoSaveCount);
 	deDocumentSetup.setAttribute("AutoSaveKeep", static_cast<int>(appPrefs.docSetupPrefs.AutoSaveKeep));
+	deDocumentSetup.setAttribute("AutoSaveLoc", static_cast<int>(appPrefs.docSetupPrefs.AutoSaveLocation));
+	deDocumentSetup.setAttribute("AutoSaveDir", appPrefs.docSetupPrefs.AutoSaveDir);
 	deDocumentSetup.setAttribute("SaveCompressed", static_cast<int>(appPrefs.docSetupPrefs.saveCompressed));
 	deDocumentSetup.setAttribute("BleedTop", ScCLocale::toQStringC(appPrefs.docSetupPrefs.bleeds.top()));
 	deDocumentSetup.setAttribute("BleedLeft", ScCLocale::toQStringC(appPrefs.docSetupPrefs.bleeds.left()));
@@ -1993,6 +1997,8 @@
 			appPrefs.docSetupPrefs.AutoSaveTime  = dc.attribute("AutoSaveTime", "600000").toInt();
 			appPrefs.docSetupPrefs.AutoSaveCount  = dc.attribute("AutoSaveCount", "5").toInt();
 			appPrefs.docSetupPrefs.AutoSaveKeep = static_cast<bool>(dc.attribute("AutoSaveKeep", "0").toInt());
+			appPrefs.docSetupPrefs.AutoSaveLocation = static_cast<bool>(dc.attribute("AutoSaveLoc", "1").toInt());
+			appPrefs.docSetupPrefs.AutoSaveDir = dc.attribute("AutoSaveDir","");
 			appPrefs.docSetupPrefs.saveCompressed = static_cast<bool>(dc.attribute("SaveCompressed", "0").toInt());
 			appPrefs.docSetupPrefs.bleeds.setTop(ScCLocale::toDoubleC(dc.attribute("BleedTop"), 0.0));
 			appPrefs.docSetupPrefs.bleeds.setLeft(ScCLocale::toDoubleC(dc.attribute("BleedLeft"), 0.0));

Modified: trunk/Scribus/scribus/prefsstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21083&path=/trunk/Scribus/scribus/prefsstructs.h
==============================================================================
--- trunk/Scribus/scribus/prefsstructs.h	(original)
+++ trunk/Scribus/scribus/prefsstructs.h	Sun Mar 13 12:44:54 2016
@@ -179,6 +179,8 @@
 	int AutoSaveTime;
 	int AutoSaveCount;
 	bool AutoSaveKeep;
+	bool AutoSaveLocation;
+	QString AutoSaveDir;
 	bool saveCompressed;
 };
 

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21083&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Sun Mar 13 12:44:54 2016
@@ -8175,17 +8175,25 @@
 		ActWin = (ScribusWin*)windows.at(i)->widget();
 		doc = ActWin->doc();
 		view = ActWin->view();
+		doc->autoSaveTimer->stop();
+		doc->setMasterPageMode(false);
 		doc->setModified(false);
+		QString base = tr("Document");
+		QString path = m_prefsManager->documentDir();
+		QString fileName = "";
 		if (doc->hasName)
 		{
-			std::cout << "Saving: " << doc->DocName.toStdString() << ".emergency" << std::endl;
-			doc->autoSaveTimer->stop();
-			QString emName = doc->DocName+".emergency";
-			if (doc->DocName.right(2) == "gz")
-				emName += ".gz";
-			FileLoader fl(emName);
-			fl.saveFile(emName, doc, 0);
-		}
+			QFileInfo fi(doc->DocName);
+			base = fi.baseName();
+			path = fi.absolutePath();
+		}
+		QDateTime dat = QDateTime::currentDateTime();
+		if ((!doc->prefsData().docSetupPrefs.AutoSaveLocation) && (!doc->prefsData().docSetupPrefs.AutoSaveDir.isEmpty()))
+			path = doc->prefsData().docSetupPrefs.AutoSaveDir;
+		fileName = QDir::cleanPath(path + "/" + base + QString("_emergency_%1.sla").arg(dat.toString("dd_MM_yyyy_hh_mm")));
+		std::cout << "Saving: " << fileName.toStdString() << std::endl;
+		FileLoader fl(fileName);
+		fl.saveFile(fileName, doc, 0);
 		view->close();
 		uint numPages=doc->Pages->count();
 		for (uint a=0; a<numPages; ++a)

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21083&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Sun Mar 13 12:44:54 2016
@@ -16406,12 +16406,22 @@
 
 void ScribusDoc::slotAutoSave()
 {
-	if (hasName && isModified())
+	if (isModified())
 	{
 		autoSaveTimer->stop();
-		QFileInfo fi(DocName);
+		QString base = tr("Document");
+		QString path = m_docPrefsData.pathPrefs.documents;
+		QString fileName = "";
+		if (hasName)
+		{
+			QFileInfo fi(DocName);
+			base = fi.baseName();
+			path = fi.absolutePath();
+		}
 		QDateTime dat = QDateTime::currentDateTime();
-		QString fileName = QDir::cleanPath(fi.path() + "/" + fi.baseName() + QString("_autosave_%1.sla").arg(dat.toString("dd_MM_yyyy_hh_mm")));
+		if ((!m_docPrefsData.docSetupPrefs.AutoSaveLocation) && (!m_docPrefsData.docSetupPrefs.AutoSaveDir.isEmpty()))
+			path = m_docPrefsData.docSetupPrefs.AutoSaveDir;
+		fileName = QDir::cleanPath(path + "/" + base + QString("_autosave_%1.sla").arg(dat.toString("dd_MM_yyyy_hh_mm")));
 		FileLoader fl(fileName);
 		if (fl.saveFile(fileName, this, 0))
 		{

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21083&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h	(original)
+++ trunk/Scribus/scribus/scribusdoc.h	Sun Mar 13 12:44:54 2016
@@ -161,11 +161,15 @@
 	int autoSaveTime() const  { return m_docPrefsData.docSetupPrefs.AutoSaveTime; }
 	int autoSaveCount() const  { return m_docPrefsData.docSetupPrefs.AutoSaveCount; }
 	bool autoSaveKeep() const  { return m_docPrefsData.docSetupPrefs.AutoSaveKeep; }
+	bool autoSaveInDocDir() const  { return m_docPrefsData.docSetupPrefs.AutoSaveLocation; }
+	QString autoSaveDir() const { return m_docPrefsData.docSetupPrefs.AutoSaveDir; }
 	bool autoSaveClockDisplay() const  { return m_docPrefsData.displayPrefs.showAutosaveClockOnCanvas; }
 	void setAutoSave(bool b) { m_docPrefsData.docSetupPrefs.AutoSave=b; }
 	void setAutoSaveTime(int i) { m_docPrefsData.docSetupPrefs.AutoSaveTime=i; }
 	void setAutoSaveCount(int i) { m_docPrefsData.docSetupPrefs.AutoSaveCount=i; }
 	void setAutoSaveKeep(bool i) { m_docPrefsData.docSetupPrefs.AutoSaveKeep=i; }
+	void setAutoSaveInDocDir(bool i) { m_docPrefsData.docSetupPrefs.AutoSaveLocation=i; }
+	void setAutoSaveDir(QString i) { m_docPrefsData.docSetupPrefs.AutoSaveDir = i; }
 	//FIXME (maybe) :non const, the loaders make a mess here
 	PDFOptions& pdfOptions() { return m_docPrefsData.pdfPrefs; }
 	ObjAttrVector& itemAttributes() { return m_docPrefsData.itemAttrPrefs.defaultItemAttributes; }

Modified: trunk/Scribus/scribus/ui/prefs_documentsetup.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21083&path=/trunk/Scribus/scribus/ui/prefs_documentsetup.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_documentsetup.cpp	(original)
+++ trunk/Scribus/scribus/ui/prefs_documentsetup.cpp	Sun Mar 13 12:44:54 2016
@@ -5,6 +5,7 @@
 for which a new license (GPL+exception) is in place.
 */
 #include <QButtonGroup>
+#include <QFileDialog>
 
 #include "ui/prefs_documentsetup.h"
 #include "commonstrings.h"
@@ -61,6 +62,7 @@
 	connect(pageLayoutButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(pageLayoutChanged(int)));
 	connect(pageUnitsComboBox, SIGNAL(activated(int)), this, SLOT(unitChange()));
 	connect(undoCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotUndo(bool)));
+	connect(changeAutoDir, SIGNAL(clicked()), this, SLOT(changeAutoDocDir()));
 }
 
 Prefs_DocumentSetup::~Prefs_DocumentSetup()
@@ -183,6 +185,8 @@
 	autosaveIntervalSpinBox->setValue(prefsData->docSetupPrefs.AutoSaveTime / 1000 / 60);
 	autosaveCountSpinBox->setValue(prefsData->docSetupPrefs.AutoSaveCount);
 	autosaveKeepCheckBox->setChecked(prefsData->docSetupPrefs.AutoSaveKeep);
+	autosaveDocRadio->setChecked(prefsData->docSetupPrefs.AutoSaveLocation);
+	autosaveDirEdit->setText(prefsData->docSetupPrefs.AutoSaveDir);
 	undoCheckBox->setChecked(PrefsManager::instance()->prefsFile->getContext("undo")->getBool("enabled", true));
 	int undoLength = UndoManager::instance()->getHistoryLength();
 	if (undoLength == -1)
@@ -209,6 +213,8 @@
 	prefsData->docSetupPrefs.AutoSaveTime = autosaveIntervalSpinBox->value() * 1000 * 60;
 	prefsData->docSetupPrefs.AutoSaveCount = autosaveCountSpinBox->value();
 	prefsData->docSetupPrefs.AutoSaveKeep = autosaveKeepCheckBox->isChecked();
+	prefsData->docSetupPrefs.AutoSaveLocation = autosaveDocRadio->isChecked();
+	prefsData->docSetupPrefs.AutoSaveDir = autosaveDirEdit->text();
 	bool undoActive=undoCheckBox->isChecked();
 	if (!undoActive)
 		UndoManager::instance()->clearStack();
@@ -376,6 +382,13 @@
 	resizeMasterPageMargins=applyMarginsToAllMasterPagesCheckBox->isChecked();
 }
 
+void Prefs_DocumentSetup::changeAutoDocDir()
+{
+	QString s = QFileDialog::getExistingDirectory(this, tr("Choose a Directory"), autosaveDirEdit->text());
+	if (!s.isEmpty())
+		autosaveDirEdit->setText( QDir::toNativeSeparators(s) );
+}
+
 void Prefs_DocumentSetup::emitSectionChange()
 {
 	emit changeToOtherSection("Prefs_PageSizes");

Modified: trunk/Scribus/scribus/ui/prefs_documentsetup.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21083&path=/trunk/Scribus/scribus/ui/prefs_documentsetup.h
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_documentsetup.h	(original)
+++ trunk/Scribus/scribus/ui/prefs_documentsetup.h	Sun Mar 13 12:44:54 2016
@@ -54,6 +54,7 @@
 		void setPageSize();
 		void slotUndo(bool);
 		void unitChange();
+		void changeAutoDocDir();
 		void emitSectionChange();
 
 	protected:

Modified: trunk/Scribus/scribus/ui/prefs_documentsetupbase.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21083&path=/trunk/Scribus/scribus/ui/prefs_documentsetupbase.ui
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_documentsetupbase.ui	(original)
+++ trunk/Scribus/scribus/ui/prefs_documentsetupbase.ui	Sun Mar 13 12:44:54 2016
@@ -579,6 +579,46 @@
             </size>
            </property>
           </spacer>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <widget class="QRadioButton" name="autosaveDocRadio">
+         <property name="text">
+          <string>Save into the same Directory as Document</string>
+         </property>
+         <property name="checked">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout_3">
+         <property name="spacing">
+          <number>1</number>
+         </property>
+         <item>
+          <widget class="QRadioButton" name="autosaveDirRadio">
+           <property name="text">
+            <string>Save into:</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QLineEdit" name="autosaveDirEdit"/>
+         </item>
+         <item>
+          <widget class="QPushButton" name="changeAutoDir">
+           <property name="maximumSize">
+            <size>
+             <width>20</width>
+             <height>16777215</height>
+            </size>
+           </property>
+           <property name="text">
+            <string>...</string>
+           </property>
+          </widget>
          </item>
         </layout>
        </item>




More information about the scribus-commit mailing list