Theme Editor: Enabled persistent window and panel locations
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26565 a1c6a512-1295-4272-9138-f99709370657
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp
index 92d400c..4268788 100644
--- a/utils/themeeditor/editorwindow.cpp
+++ b/utils/themeeditor/editorwindow.cpp
@@ -24,6 +24,7 @@
#include <QDesktopWidget>
#include <QFileSystemModel>
+#include <QSettings>
EditorWindow::EditorWindow(QWidget *parent) :
QMainWindow(parent),
@@ -37,17 +38,37 @@
void EditorWindow::loadSettings()
{
- /* When there are settings to load, they'll be loaded here */
- /* For now, we'll just set the window to take up most of the screen */
- QDesktopWidget* desktop = QApplication::desktop();
- QRect availableSpace = desktop->availableGeometry(desktop->primaryScreen());
- QRect buffer(availableSpace.left() + availableSpace.width() / 10,
- availableSpace.top() + availableSpace.height() / 10,
- availableSpace.width() * 8 / 10,
- availableSpace.height() * 8 / 10);
- this->setGeometry(buffer);
+ QSettings settings;
+ /* Main Window location */
+ settings.beginGroup("MainWindow");
+ QSize size = settings.value("size").toSize();
+ QPoint pos = settings.value("position").toPoint();
+ QByteArray state = settings.value("state").toByteArray();
+ settings.endGroup();
+
+ if(!(size.isNull() || pos.isNull() || state.isNull()))
+ {
+ resize(size);
+ move(pos);
+ restoreState(state);
+ }
+
+
+}
+
+void EditorWindow::saveSettings()
+{
+
+ QSettings settings;
+
+ /* Saving window and panel positions */
+ settings.beginGroup("MainWindow");
+ settings.setValue("position", pos());
+ settings.setValue("size", size());
+ settings.setValue("state", saveState());
+ settings.endGroup();
}
void EditorWindow::setupUI()
@@ -57,10 +78,6 @@
model->setRootPath(QDir::currentPath());
ui->fileTree->setModel(model);
- /* Connecting the buttons */
- QObject::connect(ui->fromTree, SIGNAL(pressed()),
- this, SLOT(updateCode()));
-
}
void EditorWindow::setupMenus()
@@ -97,6 +114,7 @@
void EditorWindow::closeEvent(QCloseEvent* event)
{
+ saveSettings();
event->accept();
}
diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h
index 2b64bde..157ee6a 100644
--- a/utils/themeeditor/editorwindow.h
+++ b/utils/themeeditor/editorwindow.h
@@ -48,6 +48,7 @@
private:
/* Setup functions */
void loadSettings();
+ void saveSettings();
void setupUI();
void setupMenus();
diff --git a/utils/themeeditor/editorwindow.ui b/utils/themeeditor/editorwindow.ui
index 0f6062d..b990f6e 100644
--- a/utils/themeeditor/editorwindow.ui
+++ b/utils/themeeditor/editorwindow.ui
@@ -14,7 +14,7 @@
<string>Rockbox Theme Editor</string>
</property>
<property name="windowIcon">
- <iconset resource="resources.qrc">
+ <iconset>
<normaloff>:/resources/resources/windowicon.png</normaloff>:/resources/resources/windowicon.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
@@ -195,9 +195,7 @@
</property>
</action>
</widget>
- <resources>
- <include location="resources.qrc"/>
- </resources>
+ <resources/>
<connections>
<connection>
<sender>actionQuit</sender>
diff --git a/utils/themeeditor/main.cpp b/utils/themeeditor/main.cpp
index 152f780..ad4ae6f 100644
--- a/utils/themeeditor/main.cpp
+++ b/utils/themeeditor/main.cpp
@@ -28,7 +28,6 @@
#include <iostream>
#include <QtGui/QApplication>
-#include <QTreeView>
#include "parsetreemodel.h"
@@ -36,6 +35,10 @@
{
QApplication app(argc, argv);
+ QCoreApplication::setApplicationName(QObject::tr("Rockbox Theme Editor"));
+ QCoreApplication::setApplicationVersion(QObject::tr("Pre-Alpha"));
+ QCoreApplication::setOrganizationName(QObject::tr("Rockbox"));
+
EditorWindow mainWindow;
mainWindow.show();