r21098 by fschmid -
scribus-commit
scribus-commit at lists.scribus.net
Sun Mar 20 10:40:04 UTC 2016
Author: fschmid
Date: Sun Mar 20 10:40:04 2016
New Revision: 21098
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21098
Log:
Fixed Bug #8788: Automatic recovery
Added:
trunk/Scribus/scribus/ui/recoverdialog.cpp
trunk/Scribus/scribus/ui/recoverdialog.h
trunk/Scribus/scribus/ui/recoverdialog.ui (with props)
Modified:
trunk/Scribus/scribus/CMakeLists.txt
trunk/Scribus/scribus/prefsmanager.cpp
trunk/Scribus/scribus/prefsstructs.h
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribus.h
trunk/Scribus/scribus/scribuscore.cpp
trunk/Scribus/scribus/ui/prefs_documentsetup.cpp
trunk/Scribus/scribus/ui/prefs_documentsetupbase.ui
Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21098&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/CMakeLists.txt Sun Mar 20 10:40:04 2016
@@ -177,6 +177,7 @@
ui/propertywidget_orphansbase.ui
ui/propertywidget_pathtextbase.ui
ui/propertywidget_textcolorbase.ui
+ ui/recoverdialog.ui
ui/replacecolors.ui
ui/replaceonecolor.ui
ui/resourcemanagerbase.ui
@@ -459,6 +460,7 @@
ui/propertywidget_textcolor.h
ui/proptree.h
ui/query.h
+ ui/recoverdialog.h
ui/replacecolors.h
ui/replaceonecolor.h
ui/resourcemanager.h
@@ -921,6 +923,7 @@
ui/propertywidgetbase.cpp
ui/proptree.cpp
ui/query.cpp
+ ui/recoverdialog.cpp
ui/replacecolors.cpp
ui/replaceonecolor.cpp
ui/resourcemanager.cpp
Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21098&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp (original)
+++ trunk/Scribus/scribus/prefsmanager.cpp Sun Mar 20 10:40:04 2016
@@ -329,6 +329,7 @@
appPrefs.docSetupPrefs.saveCompressed = false;
appPrefs.docSetupPrefs.AutoSaveLocation = true;
appPrefs.docSetupPrefs.AutoSaveDir = "";
+ appPrefs.miscPrefs.saveEmergencyFile = true;
int dpi = qApp->desktop()->logicalDpiX();
if ((dpi < 60) || (dpi > 200))
dpi = 72;
@@ -416,6 +417,7 @@
appPrefs.docSetupPrefs.pagePositioning = singlePage;
appPrefs.fontPrefs.askBeforeSubstitute = true;
appPrefs.miscPrefs.haveStylePreview = true;
+ appPrefs.miscPrefs.saveEmergencyFile = true;
// lorem ipsum defaults
appPrefs.miscPrefs.useStandardLI = false;
appPrefs.miscPrefs.paragraphsLI = 10;
@@ -1440,6 +1442,7 @@
deMiscellaneous.setAttribute("ShowStylePreview", static_cast<int>(appPrefs.miscPrefs.haveStylePreview));
deMiscellaneous.setAttribute("LoremIpsumUseStandard", static_cast<int>(appPrefs.miscPrefs.useStandardLI));
deMiscellaneous.setAttribute("LoremIpsumParagraphs", appPrefs.miscPrefs.paragraphsLI);
+ deMiscellaneous.setAttribute("saveEmergencyFile", static_cast<int>(appPrefs.miscPrefs.saveEmergencyFile));
elem.appendChild(deMiscellaneous);
@@ -2012,6 +2015,7 @@
appPrefs.miscPrefs.haveStylePreview = static_cast<bool>(dc.attribute("ShowStylePreview", "1").toInt());
appPrefs.miscPrefs.useStandardLI = static_cast<bool>(dc.attribute("LoremIpsumUseStandard", "0").toInt());
appPrefs.miscPrefs.paragraphsLI = dc.attribute("LoremIpsumParagraphs", "10").toInt();
+ appPrefs.miscPrefs.saveEmergencyFile = static_cast<bool>(dc.attribute("saveEmergencyFile", "1").toInt());
}
Modified: trunk/Scribus/scribus/prefsstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21098&path=/trunk/Scribus/scribus/prefsstructs.h
==============================================================================
--- trunk/Scribus/scribus/prefsstructs.h (original)
+++ trunk/Scribus/scribus/prefsstructs.h Sun Mar 20 10:40:04 2016
@@ -414,6 +414,7 @@
struct MiscellaneousPrefs
{
bool haveStylePreview; //! Show previews in the Style setup areas like Style Manager
+ bool saveEmergencyFile; //! true = try to save emergency files when crashing
// lorem ipsum
bool useStandardLI; //! Use the standard Lorem Ipsum text
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21098&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sun Mar 20 10:40:04 2016
@@ -227,6 +227,7 @@
#include "ui/propertiespalette_text.h"
#include "ui/propertiespalette_xyz.h"
#include "ui/query.h"
+#include "ui/recoverdialog.h"
#include "ui/replacecolors.h"
#include "ui/resourcemanager.h"
#include "ui/sccombobox.h"
@@ -1996,6 +1997,81 @@
return m__arrowKeyDown;
}
+QStringList ScribusMainWindow::findRecoverableFile()
+{
+ QSet<QString> foundFiles;
+ if (!m_prefsManager->appPrefs.docSetupPrefs.AutoSaveDir.isEmpty())
+ {
+ QDir dirAuto(m_prefsManager->appPrefs.docSetupPrefs.AutoSaveDir, "*_emergency_*.sla", QDir::Name | QDir::Time, QDir::Files | QDir::NoSymLinks | QDir::NoDot | QDir::NoDotDot);
+ QFileInfoList aList = dirAuto.entryInfoList();
+ if (aList.count() > 0)
+ {
+ for (int a = 0; a < aList.count(); a++)
+ {
+ foundFiles.insert(aList[a].absoluteFilePath());
+ }
+ }
+ QDir dirAuto2(m_prefsManager->appPrefs.docSetupPrefs.AutoSaveDir, "*_autosave_*.sla", QDir::Name | QDir::Time, QDir::Files | QDir::NoSymLinks | QDir::NoDot | QDir::NoDotDot);
+ QFileInfoList aList2 = dirAuto2.entryInfoList();
+ if (aList2.count() > 0)
+ {
+ for (int a = 0; a < aList2.count(); a++)
+ {
+ foundFiles.insert(aList2[a].absoluteFilePath());
+ }
+ }
+ }
+ QDir dirDoc(m_prefsManager->documentDir(), "*_emergency_*.sla", QDir::Name | QDir::Time, QDir::Files | QDir::NoSymLinks | QDir::NoDot | QDir::NoDotDot);
+ QFileInfoList dList = dirDoc.entryInfoList();
+ for (int a = 0; a < dList.count(); a++)
+ {
+ foundFiles.insert(dList[a].absoluteFilePath());
+ }
+ QDir dirDoc2(m_prefsManager->documentDir(), "*_autosave_*.sla", QDir::Name | QDir::Time, QDir::Files | QDir::NoSymLinks | QDir::NoDot | QDir::NoDotDot);
+ QFileInfoList dList2 = dirDoc2.entryInfoList();
+ for (int a = 0; a < dList2.count(); a++)
+ {
+ foundFiles.insert(dList2[a].absoluteFilePath());
+ }
+ QDir dirHome(QDir::toNativeSeparators(QDir::homePath()), "*_emergency_*.sla", QDir::Name | QDir::Time, QDir::Files | QDir::NoSymLinks | QDir::NoDot | QDir::NoDotDot);
+ QFileInfoList hList = dirHome.entryInfoList();
+ for (int a = 0; a < hList.count(); a++)
+ {
+ foundFiles.insert(hList[a].absoluteFilePath());
+ }
+ QDir dirHome2(QDir::toNativeSeparators(QDir::homePath()), "*_autosave_*.sla", QDir::Name | QDir::Time, QDir::Files | QDir::NoSymLinks | QDir::NoDot | QDir::NoDotDot);
+ QFileInfoList hList2 = dirHome2.entryInfoList();
+ for (int a = 0; a < hList2.count(); a++)
+ {
+ foundFiles.insert(hList2[a].absoluteFilePath());
+ }
+ return foundFiles.toList();
+}
+
+void ScribusMainWindow::recoverFile(QStringList foundFiles)
+{
+ appModeHelper->setStartupActionsEnabled(false);
+ RecoverDialog* dia = new RecoverDialog(this, foundFiles);
+ if (dia->exec())
+ {
+ if (!dia->recoverFiles.isEmpty())
+ {
+ for (int i = 0; i < dia->recoverFiles.count(); ++i)
+ {
+ loadDoc(dia->recoverFiles[i]);
+ QFileInfo fi(dia->recoverFiles[i]);
+ doc->setName(fi.absolutePath() + "/" + dia->recoverNames[i] + ".sla");
+ doc->hasName = true;
+ updateActiveWindowCaption(doc->DocName);
+ outlinePalette->setDoc(doc);
+ if (outlinePalette->isVisible())
+ outlinePalette->BuildTree();
+ }
+ }
+ }
+ delete dia;
+}
+
void ScribusMainWindow::startUpDialog()
{
bool docSet = false;
@@ -8165,6 +8241,8 @@
void ScribusMainWindow::emergencySave()
{
emergencyActivated=true;
+ if (!m_prefsManager->appPrefs.miscPrefs.saveEmergencyFile)
+ return;
std::cout << "Calling Emergency Save" << std::endl;
QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
if (windows.isEmpty())
Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21098&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Sun Mar 20 10:40:04 2016
@@ -171,6 +171,8 @@
QStringList scrapbookNames();
void updateLayerMenu();
void emergencySave();
+ QStringList findRecoverableFile();
+ void recoverFile(QStringList foundFiles);
/**
* @brief Returns true if an arrow key is pressed down.
Modified: trunk/Scribus/scribus/scribuscore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21098&path=/trunk/Scribus/scribus/scribuscore.cpp
==============================================================================
--- trunk/Scribus/scribus/scribuscore.cpp (original)
+++ trunk/Scribus/scribus/scribuscore.cpp Sun Mar 20 10:40:04 2016
@@ -126,6 +126,7 @@
connect(ScQApp, SIGNAL(lastWindowClosed()), ScQApp, SLOT(quit()));
scribus->show();
+ QStringList recoverFiles = scribus->findRecoverableFile();
int subsRet=scribus->ShowSubs();
if (subsRet==0)
{
@@ -134,10 +135,13 @@
for (int i = 0; i < m_Files.size(); ++i)
scribus->loadDoc(m_Files.at(i));
}
+ else if ((recoverFiles.count() > 0) && usingGUI())
+ {
+ scribus->recoverFile(recoverFiles);
+ }
else
{
- if (PrefsManager::instance()->appPrefs.uiPrefs.showStartupDialog
- && usingGUI())
+ if (PrefsManager::instance()->appPrefs.uiPrefs.showStartupDialog && usingGUI())
scribus->startUpDialog();
else
scribus->setFocus();
Modified: trunk/Scribus/scribus/ui/prefs_documentsetup.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21098&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 20 10:40:04 2016
@@ -39,6 +39,7 @@
else
{
pageSizeLinkToolButton->hide();
+ emergencyCheckBox->hide();
}
pageLayoutButtonGroup->setId(singlePageRadioButton,0);
@@ -181,6 +182,7 @@
// bleedsWidget->setPageSize(prefsPageSizeName);
bleedsWidget->setMarginPreset(prefsData->docSetupPrefs.marginPreset);
saveCompressedCheckBox->setChecked(prefsData->docSetupPrefs.saveCompressed);
+ emergencyCheckBox->setChecked(prefsData->miscPrefs.saveEmergencyFile);
autosaveCheckBox->setChecked( prefsData->docSetupPrefs.AutoSave );
autosaveIntervalSpinBox->setValue(prefsData->docSetupPrefs.AutoSaveTime / 1000 / 60);
autosaveCountSpinBox->setValue(prefsData->docSetupPrefs.AutoSaveCount);
@@ -213,6 +215,7 @@
prefsData->docSetupPrefs.margins=marginsWidget->margins();
prefsData->docSetupPrefs.bleeds=bleedsWidget->margins();
prefsData->docSetupPrefs.saveCompressed=saveCompressedCheckBox->isChecked();
+ prefsData->miscPrefs.saveEmergencyFile = emergencyCheckBox->isChecked();
prefsData->docSetupPrefs.AutoSave=autosaveCheckBox->isChecked();
prefsData->docSetupPrefs.AutoSaveTime = autosaveIntervalSpinBox->value() * 1000 * 60;
prefsData->docSetupPrefs.AutoSaveCount = autosaveCountSpinBox->value();
Modified: trunk/Scribus/scribus/ui/prefs_documentsetupbase.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21098&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 20 10:40:04 2016
@@ -484,6 +484,13 @@
<widget class="QCheckBox" name="saveCompressedCheckBox">
<property name="text">
<string>Save in Compressed Format</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="emergencyCheckBox">
+ <property name="text">
+ <string>Try to save an "Emergency File" in case of a Crash</string>
</property>
</widget>
</item>
More information about the scribus-commit
mailing list