mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-13 00:36:32 +02:00
Move (re)storeSizeAndGeometry out of Application
Moved to MainWindow
This commit is contained in:
parent
5266ae5397
commit
6bda5de5e5
4 changed files with 47 additions and 43 deletions
|
@ -399,7 +399,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
|
||||
_window->setCentralWidget(glCanvas.data());
|
||||
|
||||
restoreSizeAndPosition();
|
||||
_window->restoreGeometry();
|
||||
|
||||
_window->setVisible(true);
|
||||
glCanvas->setFocusPolicy(Qt::StrongFocus);
|
||||
|
@ -475,7 +475,7 @@ Application::~Application() {
|
|||
qInstallMessageHandler(NULL);
|
||||
|
||||
saveSettings();
|
||||
storeSizeAndPosition();
|
||||
_window->saveGeometry();
|
||||
|
||||
int DELAY_TIME = 1000;
|
||||
UserActivityLogger::getInstance().close(DELAY_TIME);
|
||||
|
@ -520,37 +520,6 @@ void Application::saveSettings() {
|
|||
_numChangedSettings = 0;
|
||||
}
|
||||
|
||||
|
||||
void Application::restoreSizeAndPosition() {
|
||||
QRect available = desktop()->availableGeometry();
|
||||
|
||||
QMutexLocker locker(&_settingsMutex);
|
||||
_settings->beginGroup("Window");
|
||||
|
||||
int x = (int)loadSetting(_settings, "x", 0);
|
||||
int y = (int)loadSetting(_settings, "y", 0);
|
||||
_window->move(x, y);
|
||||
|
||||
int width = (int)loadSetting(_settings, "width", available.width());
|
||||
int height = (int)loadSetting(_settings, "height", available.height());
|
||||
_window->resize(width, height);
|
||||
|
||||
_settings->endGroup();
|
||||
}
|
||||
|
||||
void Application::storeSizeAndPosition() {
|
||||
QMutexLocker locker(&_settingsMutex);
|
||||
_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.");
|
||||
|
||||
|
|
|
@ -140,11 +140,9 @@ public:
|
|||
Application(int& argc, char** argv, QElapsedTimer &startup_time);
|
||||
~Application();
|
||||
|
||||
void restoreSizeAndPosition();
|
||||
void loadScripts();
|
||||
QString getPreviousScriptLocation();
|
||||
void setPreviousScriptLocation(const QString& previousScriptLocation);
|
||||
void storeSizeAndPosition();
|
||||
void clearScriptsBeforeRunning();
|
||||
void initializeGL();
|
||||
void paintGL();
|
||||
|
|
|
@ -9,9 +9,8 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "Menu.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QEvent>
|
||||
#include <QMoveEvent>
|
||||
#include <QResizeEvent>
|
||||
|
@ -19,8 +18,43 @@
|
|||
#include <QHideEvent>
|
||||
#include <QWindowStateChangeEvent>
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent) :
|
||||
QMainWindow(parent) {
|
||||
#include <Settings.h>
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) {
|
||||
}
|
||||
|
||||
void MainWindow::restoreGeometry() {
|
||||
QRect available = qApp->desktop()->availableGeometry();
|
||||
|
||||
Settings settings;
|
||||
settings.beginGroup("Window");
|
||||
|
||||
int x = (int)loadSetting(&settings, "x", 0);
|
||||
int y = (int)loadSetting(&settings, "y", 0);
|
||||
move(x, y);
|
||||
|
||||
int width = (int)loadSetting(&settings, "width", available.width());
|
||||
int height = (int)loadSetting(&settings, "height", available.height());
|
||||
resize(width, height);
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void MainWindow::saveGeometry() {
|
||||
Settings settings;
|
||||
settings.beginGroup("Window");
|
||||
|
||||
settings.setValue("width", rect().width());
|
||||
settings.setValue("height", rect().height());
|
||||
|
||||
settings.setValue("x", pos().x());
|
||||
settings.setValue("y", pos().y());
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void MainWindow::moveEvent(QMoveEvent* event) {
|
||||
|
|
|
@ -14,12 +14,15 @@
|
|||
|
||||
#include <QMainWindow>
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainWindow(QWidget* parent = NULL);
|
||||
|
||||
|
||||
public slots:
|
||||
void restoreGeometry();
|
||||
void saveGeometry();
|
||||
|
||||
signals:
|
||||
void windowGeometryChanged(QRect geometry);
|
||||
void windowShown(bool shown);
|
||||
|
|
Loading…
Reference in a new issue