|
From: Tapio V. <aa...@us...> - 2011-01-26 22:37:38
|
Module: editor
Branch: master
Commit: c8b396d8fdbc38dfa72d8c2223c1d36490018e14
Author: Tapio Vierros <tap...@gm...>
Date: Wed Jan 26 22:16:19 2011 +0200
Introduce QSettings: window size/pos is restored on app re-launch.
---
editorapp.cc | 27 +++++++++++++++++++++++++--
editorapp.hh | 2 ++
ffmpeg.cc | 1 -
main.cc | 2 ++
4 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index 857c4a6..a017c6b 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -7,6 +7,7 @@
#include <QWhatsThis>
#include <QUrl>
#include <QCloseEvent>
+#include <QSettings>
#include <phonon/AudioOutput>
#include <iostream>
#include "config.hh"
@@ -24,8 +25,8 @@ namespace {
EditorApp::EditorApp(QWidget *parent): QMainWindow(parent), projectFileName(), hasUnsavedChanges()
{
- showMaximized();
ui.setupUi(this);
+ readSettings();
noteGraph = new NoteGraphWidget(NULL);
ui.noteGraphScroller->setWidget(noteGraph);
@@ -598,7 +599,29 @@ void EditorApp::closeEvent(QCloseEvent *event)
{
if (promptSaving()) event->accept();
else event->ignore();
-}
+ writeSettings();
+}
+
+void EditorApp::readSettings()
+ {
+ QSettings settings; // Default QSettings parameters given in main()
+ // Read values
+ QPoint pos = settings.value("pos", QPoint()).toPoint();
+ QSize size = settings.value("size", QSize(800, 600)).toSize();
+ bool maximized = settings.value("maximized", false).toBool();
+ // Apply them
+ if (!pos.isNull()) move(pos);
+ resize(size);
+ if (maximized) showMaximized();
+ }
+
+void EditorApp::writeSettings()
+ {
+ QSettings settings; // Default QSettings parameters given in main()
+ settings.setValue("pos", pos());
+ settings.setValue("size", size());
+ settings.setValue("maximized", isMaximized());
+ }
AboutDialog::AboutDialog(QWidget* parent)
diff --git a/editorapp.hh b/editorapp.hh
index 5332042..a6baa25 100644
--- a/editorapp.hh
+++ b/editorapp.hh
@@ -39,6 +39,8 @@ private:
void saveProject(QString fileName);
void doOpStack();
void playButton();
+ void readSettings();
+ void writeSettings();
public slots:
void operationDone(const Operation &op);
diff --git a/ffmpeg.cc b/ffmpeg.cc
index 32031df..1858e4e 100644
--- a/ffmpeg.cc
+++ b/ffmpeg.cc
@@ -1,5 +1,4 @@
#include "ffmpeg.hh"
-
#include "config.hh"
#include "util.hh"
#include <iostream>
diff --git a/main.cc b/main.cc
index c155354..43438b8 100644
--- a/main.cc
+++ b/main.cc
@@ -9,6 +9,8 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
app.setApplicationName(PACKAGE);
app.setApplicationVersion(VERSION);
+ app.setOrganizationName("Performous Team");
+ app.setOrganizationDomain("performous.org");
EditorApp window;
window.show();
|