1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-07-08 13:54:52 +02:00

Fix window status restoration

This commit is contained in:
Daniel Evans 2014-02-12 07:12:40 +00:00
parent 1b9687dedd
commit 25ecdf0533
2 changed files with 18 additions and 7 deletions

View File

@ -35,15 +35,13 @@ ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags): QMainWindow(
connect(r, SIGNAL(triggered()), SLOT(openRecent()));
}
recentSep = file->addSeparator();
file->addAction("E&xit", QApplication::instance(), SLOT(quit()), QKeySequence::Quit);
auto ex = file->addAction("E&xit");
ex->setShortcut(QKeySequence::Quit);
connect(ex, SIGNAL(triggered()), QApplication::instance(), SLOT(closeAllWindows()));
connect(archivewidget, SIGNAL(selectedFileChanged(QString)), viewer, SLOT(showFile(QString)));
connect(viewer, SIGNAL(fileOpened(QString)), SLOT(openFileChanged(QString)));
QSettings settings("OpenRW", "rwviewer");
restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("windowState").toByteArray());
updateRecentArchives();
}
@ -72,11 +70,22 @@ void ViewerWindow::openArchive(const QString& name)
updateRecentArchives();
}
void ViewerWindow::showEvent(QShowEvent*)
{
static bool first = true;
if(first) {
QSettings settings("OpenRW", "rwviewer");
restoreGeometry(settings.value("window/geometry").toByteArray());
restoreState(settings.value("window/windowState").toByteArray());
first = false;
}
}
void ViewerWindow::closeEvent(QCloseEvent* event)
{
QSettings settings("OpenRW", "rwviewer");
settings.setValue("geometry", saveGeometry());
settings.setValue("windowState", saveState());
settings.setValue("window/geometry", saveGeometry());
settings.setValue("window/windowState", saveState());
QMainWindow::closeEvent(event);
}

View File

@ -19,6 +19,8 @@ public:
void openArchive(const QString& name);
virtual void showEvent(QShowEvent*);
virtual void closeEvent(QCloseEvent*);
public slots: