#19434 restore window position on start

- store position and size on app end
- restore position and size on app start
This commit is contained in:
stojce 2013-10-07 21:04:36 +02:00
parent 7434686aae
commit 16d10775dc
2 changed files with 35 additions and 2 deletions

View file

@ -214,8 +214,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
cache->setCacheDirectory("interfaceCache");
_networkAccessManager->setCache(cache);
QRect available = desktop()->availableGeometry();
_window->resize(available.size());
restoreSizeAndPosition();
_window->setVisible(true);
_glWidget->setFocusPolicy(Qt::StrongFocus);
_glWidget->setFocus();
@ -230,6 +229,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
}
Application::~Application() {
storeSizeAndPosition();
NodeList::getInstance()->removeHook(&_voxels);
NodeList::getInstance()->removeHook(this);
NodeList::getInstance()->removeDomainListener(this);
@ -247,6 +247,37 @@ Application::~Application() {
delete _glWidget;
}
void Application::restoreSizeAndPosition() {
QSettings* settings = new QSettings(this);
QRect available = desktop()->availableGeometry();
settings->beginGroup("Window");
float x = loadSetting(settings, "x", 0);
float y = loadSetting(settings, "y", 0);
_window->move(x, y);
int width = loadSetting(settings, "width", available.width());
int height = loadSetting(settings, "height", available.height());
_window->resize(width, height);
settings->endGroup();
}
void Application::storeSizeAndPosition() {
QSettings* settings = new QSettings(this);
settings->beginGroup("Window");
settings->setValue("width", _window->rect().width());
settings->setValue("height", _window->rect().height());
settings->setValue("x", _window->pos().x());
settings->setValue("y", _window->pos().y());
settings->endGroup();
}
void Application::initializeGL() {
qDebug( "Created Display Window.\n" );

View file

@ -89,6 +89,8 @@ public:
Application(int& argc, char** argv, timeval &startup_time);
~Application();
void restoreSizeAndPosition();
void storeSizeAndPosition();
void initializeGL();
void paintGL();
void resizeGL(int width, int height);