src/mainwindow.cpp

changeset 1335
5530161fcd47
parent 1328
d68d1ce89d05
child 1339
1f342d5abc85
--- a/src/mainwindow.cpp	Sat Mar 24 13:55:08 2018 +0200
+++ b/src/mainwindow.cpp	Sat Mar 24 15:54:41 2018 +0200
@@ -61,6 +61,8 @@
 {
 	m_messageLog = new MessageManager {this};
 	ui.setupUi (this);
+	this->restoreGeometry(config::mainWindowGeometry());
+	this->restoreState(config::mainWindowState());
 	m_updatingTabs = false;
 	m_tabs = new QTabBar;
 	m_tabs->setTabsClosable (true);
@@ -137,14 +139,6 @@
 		}
 	}
 
-	for (QVariant const& toolbarname : config::hiddenToolbars())
-	{
-		QToolBar* toolbar = findChild<QToolBar*> (toolbarname.toString());
-
-		if (toolbar)
-			toolbar->hide();
-	}
-
 	// If this is the first start, get the user to configuration. Especially point
 	// them to the profile tab, it's the most important form to fill in.
 	if (config::firstStart())
@@ -418,28 +412,21 @@
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
-void MainWindow::closeEvent (QCloseEvent* ev)
+void MainWindow::closeEvent(QCloseEvent* event)
 {
 	// Check whether it's safe to close all files.
-	if (not m_documents->isSafeToCloseAll())
+	if (m_documents->isSafeToCloseAll())
 	{
-		ev->ignore();
-		return;
+		// Store the state of the main window before closing.
+		config::setMainWindowGeometry(this->saveGeometry());
+		config::setMainWindowState(this->saveState());
+		settingsObject().sync();
+		event->accept();
 	}
-
-	// Save the toolbar set
-	QStringList hiddenToolbars;
-
-	for (QToolBar* toolbar : findChildren<QToolBar*>())
+	else
 	{
-		if (toolbar->isHidden())
-			hiddenToolbars << toolbar->objectName();
+		event->ignore();
 	}
-
-	// Save the configuration before leaving.
-	config::setHiddenToolbars (hiddenToolbars);
-	settingsObject().sync();
-	ev->accept();
 }
 
 // ---------------------------------------------------------------------------------------------------------------------

mercurial