Merge pull request #1047 from stojce/19434

Code Review for Job #19434
This commit is contained in:
ZappoMan 2013-10-11 12:52:13 -07:00
commit c6df36a40b
2 changed files with 35 additions and 2 deletions

View file

@ -211,8 +211,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();
@ -227,6 +226,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);
@ -243,6 +243,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

@ -91,6 +91,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);