Refactor saving of window geometry.

Closes #154
This commit is contained in:
Florian Geyer 2014-03-22 12:53:42 +01:00
parent f300ca5b7b
commit 1e2d1a1b17
2 changed files with 19 additions and 9 deletions

View File

@ -417,11 +417,24 @@ void MainWindow::databaseTabChanged(int tabIndex)
void MainWindow::closeEvent(QCloseEvent* event)
{
saveWindowInformation();
saveLastDatabases(event);
bool accept = saveLastDatabases();
if (accept) {
event->accept();
}
else {
event->ignore();
}
}
void MainWindow::saveLastDatabases(QCloseEvent* event)
void MainWindow::saveWindowInformation()
{
config()->set("Window/Geometry", saveGeometry());
}
bool MainWindow::saveLastDatabases()
{
bool accept;
m_openDatabases.clear();
bool openPreviousDatabasesOnStartup = config()->get("OpenPreviousDatabasesOnStartup").toBool();
@ -431,10 +444,10 @@ void MainWindow::saveLastDatabases(QCloseEvent* event)
}
if (!m_ui->tabWidget->closeAllDatabases()) {
event->ignore();
accept = false;
}
else {
event->accept();
accept = true;
}
if (openPreviousDatabasesOnStartup) {
@ -442,11 +455,8 @@ void MainWindow::saveLastDatabases(QCloseEvent* event)
this, SLOT(rememberOpenDatabases(QString)));
config()->set("LastOpenedDatabases", m_openDatabases);
}
}
void MainWindow::saveWindowInformation()
{
config()->set("Window/Geometry", saveGeometry());
return accept;
}
void MainWindow::showEntryContextMenu(const QPoint& globalPos)

View File

@ -68,7 +68,7 @@ private:
static const QString BaseWindowTitle;
void saveWindowInformation();
void saveLastDatabases(QCloseEvent* event);
bool saveLastDatabases();
const QScopedPointer<Ui::MainWindow> m_ui;
SignalMultiplexer m_actionMultiplexer;