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

View File

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