summaryrefslogtreecommitdiffstats
path: root/src/save_restore_session.cpp
diff options
context:
space:
mode:
authorJan Darmochwal2010-10-02 18:50:09 +0200
committerJan Darmochwal2010-10-02 18:50:09 +0200
commit6117049617df720fb744a90773a3580b3450b005 (patch)
treec3b605ab7a7c2e9fd9d14572e8c0e69432d6ac76 /src/save_restore_session.cpp
parentfixed bad copy & paste in CMakeLists.txt (diff)
downloadvmchooser-6117049617df720fb744a90773a3580b3450b005.tar.gz
vmchooser-6117049617df720fb744a90773a3580b3450b005.tar.xz
vmchooser-6117049617df720fb744a90773a3580b3450b005.zip
Qt port is almost complete (at least it compiles)
Major change: * struct DataEntry has become class Session with sub-classes XSession and VSession * functions from addInfo.cpp, addPrinters.cpp, addScanners.cpp, readLinSess.cpp, readXmlDir.cpp, runImage.cpp have been moved to XSession and VSession Several minor changes: * new files globals.h and globals.cpp for global variables (replaces constants.h and paths.h) * replaced (all) libxml2, (much) std:: and (most) boost:: stuff by Qt stuff Things left to do: * remove tons of debug printfs * show error messages on errors * tidy up anyoption stuff in main() * highlight session run previously * readGroupXml stuff * tree view (with "X Sessions" and "Virtual Sessions" sections) instead of list view for session selection
Diffstat (limited to 'src/save_restore_session.cpp')
-rw-r--r--src/save_restore_session.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/save_restore_session.cpp b/src/save_restore_session.cpp
new file mode 100644
index 0000000..ec292a2
--- /dev/null
+++ b/src/save_restore_session.cpp
@@ -0,0 +1,35 @@
+#include <QDir>
+#include <QIODevice>
+#include <QString>
+
+void writeSessionName(QString name) {
+ // TODO: use constants
+ QDir saveFileDir(QDir::homePath() + "/.openslx");
+ QString saveFileName("vmchooser_prev_session");
+
+ if (! saveFileDir.exists()) {
+ if (! saveFileDir.mkpath(saveFileDir.path())) {
+ // TODO: error
+ return;
+ }
+ }
+
+ QFile saveFile(saveFileDir.path() + "/" + saveFileName);
+ if (!saveFile.open(QIODevice::WriteOnly) ||
+ saveFile.write(name.toUtf8().data()) == -1) {
+ // TODO: error
+ }
+}
+
+QString readSessionName() {
+ QString saveFileDir(QDir::homePath() + "/.openslx");
+ QString saveFileName("vmchooser_prev_session");
+
+ QFile saveFile(saveFileDir + "/" + saveFileName);
+
+ if (saveFile.open(QIODevice::ReadOnly)) {
+ return QString(saveFile.readAll());
+ } else {
+ return QString();
+ }
+}