+ issue #0000175: Auto save function
This commit is contained in:
parent
9cb63295e9
commit
16f813281c
|
@ -109,6 +109,7 @@ void AutoSaver::saveDocument(const std::string& name)
|
|||
<< "<AutoRecovery SchemaVersion=\"1\">" << endl;
|
||||
str << " <Status>Created</Status>" << endl;
|
||||
str << " <Label>" << doc->Label.getValue() << "</Label>" << endl; // store the document's current label
|
||||
str << " <FileName>" << doc->FileName.getValue() << "</FileName>" << endl; // store the document's current filename
|
||||
str << "</AutoRecovery>" << endl;
|
||||
file.close();
|
||||
}
|
||||
|
|
|
@ -200,6 +200,22 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="prefRecovery">
|
||||
<property name="text">
|
||||
<string>Run AutoRecovery at startup</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>RecoveryEnabled</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="prefAutoSaveEnabled">
|
||||
|
@ -244,7 +260,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="Line" name="line1_2_3">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
|
@ -257,7 +273,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="prefSaveThumbnail">
|
||||
<property name="text">
|
||||
<string>Save thumbnail into project file when saving document</string>
|
||||
|
@ -270,7 +286,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
|
|
|
@ -77,6 +77,7 @@ void DlgSettingsDocumentImp::saveSettings()
|
|||
prefAuthor->onSave();
|
||||
prefSetAuthorOnSave->onSave();
|
||||
prefCompany->onSave();
|
||||
prefRecovery->onSave();
|
||||
prefAutoSaveEnabled->onSave();
|
||||
prefAutoSaveTimeout->onSave();
|
||||
|
||||
|
@ -104,6 +105,7 @@ void DlgSettingsDocumentImp::loadSettings()
|
|||
prefAuthor->onRestore();
|
||||
prefSetAuthorOnSave->onRestore();
|
||||
prefCompany->onRestore();
|
||||
prefRecovery->onRestore();
|
||||
prefAutoSaveEnabled->onRestore();
|
||||
prefAutoSaveTimeout->onRestore();
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ public:
|
|||
QString projectFile;
|
||||
QString xmlFile;
|
||||
QString label;
|
||||
QString fileName;
|
||||
QString tooltip;
|
||||
Status status;
|
||||
};
|
||||
|
@ -154,7 +155,8 @@ void DocumentRecovery::accept()
|
|||
// If something goes wrong an exception will be thrown here
|
||||
document->restore();
|
||||
|
||||
document->FileName.setValue(std::string());
|
||||
file = it->fileName;
|
||||
document->FileName.setValue(file.toUtf8().constData());
|
||||
document->Label.setValue(it->label.toUtf8().constData());
|
||||
|
||||
// Set the modified flag so that the user cannot close by accident
|
||||
|
@ -233,6 +235,7 @@ void DocumentRecoveryPrivate::writeRecoveryInfo(const DocumentRecoveryPrivate::I
|
|||
break;
|
||||
}
|
||||
str << " <Label>" << info.label << "</Label>" << endl;
|
||||
str << " <FileName>" << info.fileName << "</FileName>" << endl;
|
||||
str << "</AutoRecovery>" << endl;
|
||||
file.close();
|
||||
}
|
||||
|
@ -260,6 +263,10 @@ DocumentRecoveryPrivate::Info DocumentRecoveryPrivate::getRecoveryInfo(const QFi
|
|||
info.label = cfg[QString::fromLatin1("Label")];
|
||||
}
|
||||
|
||||
if (cfg.contains(QString::fromLatin1("FileName"))) {
|
||||
info.fileName = cfg[QString::fromLatin1("FileName")];
|
||||
}
|
||||
|
||||
if (cfg.contains(QString::fromLatin1("Status"))) {
|
||||
QString status = cfg[QString::fromLatin1("Status")];
|
||||
if (status == QLatin1String("Success"))
|
||||
|
@ -299,6 +306,7 @@ DocumentRecoveryPrivate::XmlConfig DocumentRecoveryPrivate::readXmlFile(const QS
|
|||
|
||||
QVector<QString> filter;
|
||||
filter << QString::fromLatin1("Label");
|
||||
filter << QString::fromLatin1("FileName");
|
||||
filter << QString::fromLatin1("Status");
|
||||
|
||||
QDomElement child;
|
||||
|
|
Loading…
Reference in New Issue
Block a user