[Ktutorial-commits] SF.net SVN: ktutorial:[218] trunk/ktutorial/ktutorial-editor/src
Status: Alpha
Brought to you by:
danxuliu
|
From: <dan...@us...> - 2010-03-30 05:03:53
|
Revision: 218
http://ktutorial.svn.sourceforge.net/ktutorial/?rev=218&view=rev
Author: danxuliu
Date: 2010-03-30 05:03:47 +0000 (Tue, 30 Mar 2010)
Log Message:
-----------
Add support to save and restore sessions.
Modified Paths:
--------------
trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp
trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h
trunk/ktutorial/ktutorial-editor/src/main.cpp
Modified: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp 2010-03-30 03:16:07 UTC (rev 217)
+++ trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp 2010-03-30 05:03:47 UTC (rev 218)
@@ -106,6 +106,17 @@
return queryCloseTutorial();
}
+void KTutorialEditor::readProperties(const KConfigGroup& configGroup) {
+ KUrl url = configGroup.readEntry("TutorialUrl");
+ if (!url.isEmpty()) {
+ loadTutorialFromUrl(url);
+ }
+}
+
+void KTutorialEditor::saveProperties(KConfigGroup& configGroup) {
+ configGroup.writeEntry("TutorialUrl", mTutorialUrl);
+}
+
//private:
bool KTutorialEditor::queryCloseTutorial() {
Modified: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h 2010-03-30 03:16:07 UTC (rev 217)
+++ trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h 2010-03-30 05:03:47 UTC (rev 218)
@@ -65,6 +65,26 @@
*/
virtual bool queryClose();
+ /**
+ * Restores the session based on the saved state.
+ * If "TutorialURL" is not empty, the tutorial is loaded from that URL.
+ *
+ * Reimplemented from KMainWindow::readProperties(const KConfigGroup&).
+ *
+ * @param configGroup The KConfigGroup to read the state from.
+ */
+ virtual void readProperties(const KConfigGroup& configGroup);
+
+ /**
+ * Saves the state to restore the session.
+ * The tutorial URL is saved as "TutorialURL".
+ *
+ * Reimplemented from KMainWindow::saveProperties(KConfigGroup&).
+ *
+ * @param configGroup The KConfigGroup to save the state to.
+ */
+ virtual void saveProperties(KConfigGroup& configGroup);
+
private:
/**
Modified: trunk/ktutorial/ktutorial-editor/src/main.cpp
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/main.cpp 2010-03-30 03:16:07 UTC (rev 217)
+++ trunk/ktutorial/ktutorial-editor/src/main.cpp 2010-03-30 05:03:47 UTC (rev 218)
@@ -41,6 +41,10 @@
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
+ if (app.isSessionRestored()) {
+ kRestoreMainWindows<KTutorialEditor>();
+ return app.exec();
+ }
KTutorialEditor* window = new KTutorialEditor();
window->show();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|