1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-10-06 09:07:19 +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())); connect(r, SIGNAL(triggered()), SLOT(openRecent()));
} }
recentSep = file->addSeparator(); 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(archivewidget, SIGNAL(selectedFileChanged(QString)), viewer, SLOT(showFile(QString)));
connect(viewer, SIGNAL(fileOpened(QString)), SLOT(openFileChanged(QString))); connect(viewer, SIGNAL(fileOpened(QString)), SLOT(openFileChanged(QString)));
QSettings settings("OpenRW", "rwviewer");
restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("windowState").toByteArray());
updateRecentArchives(); updateRecentArchives();
} }
@ -72,11 +70,22 @@ void ViewerWindow::openArchive(const QString& name)
updateRecentArchives(); 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) void ViewerWindow::closeEvent(QCloseEvent* event)
{ {
QSettings settings("OpenRW", "rwviewer"); QSettings settings("OpenRW", "rwviewer");
settings.setValue("geometry", saveGeometry()); settings.setValue("window/geometry", saveGeometry());
settings.setValue("windowState", saveState()); settings.setValue("window/windowState", saveState());
QMainWindow::closeEvent(event); QMainWindow::closeEvent(event);
} }

View File

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