src/mainwindow.cpp

changeset 1206
743dc95e0be6
parent 1199
613a981223a6
--- a/src/mainwindow.cpp	Wed Mar 08 22:09:48 2017 +0200
+++ b/src/mainwindow.cpp	Wed Mar 08 22:48:43 2017 +0200
@@ -53,8 +53,7 @@
     QMainWindow (parent, flags),
     m_primitives(new PrimitiveManager(this)),
 	ui (*new Ui_MainWindow),
-	m_externalPrograms (nullptr),
-    m_settings (makeSettings (this)),
+    m_externalPrograms (nullptr),
 	m_documents (new DocumentManager (this)),
 	m_currentDocument (nullptr),
 	m_isSelectionLocked (false)
@@ -167,7 +166,6 @@
 {
 	delete m_primitives;
 	delete &ui;
-	delete m_settings;
 
 	for (Toolset* toolset : m_toolsets)
 		delete toolset;
@@ -585,7 +583,7 @@
 
 	// Save the configuration before leaving.
 	configuration().setHiddenToolbars (hiddenToolbars);
-	syncSettings();
+	configuration().sync();
 	ev->accept();
 }
 
@@ -944,7 +942,7 @@
 {
 	for (QAction* act : findChildren<QAction*>())
 	{
-		QKeySequence seq = m_settings->value ("shortcut_" + act->objectName(), act->shortcut()).value<QKeySequence>();
+		QKeySequence seq = configuration().value("shortcut_" + act->objectName(), act->shortcut()).value<QKeySequence>();
 		act->setShortcut (seq);
 	}
 }
@@ -955,12 +953,7 @@
 {
 	applyToActions ([&](QAction* act)
 	{
-		QString const key = "shortcut_" + act->objectName();
-
-		if (m_defaultShortcuts[act] != act->shortcut())
-			m_settings->setValue (key, act->shortcut());
-		else
-			m_settings->remove (key);
+		configuration().setValue("shortcut_" + act->objectName(), act->shortcut(), m_defaultShortcuts[act]);
 	});
 }
 
@@ -1029,30 +1022,6 @@
 	ui.ringToolSegmentsLabel->setText (format ("%1 / %2", numerator, denominator));
 }
 
-/*
- * Returns a settings object that interfaces the ini file.
- */
-QSettings* MainWindow::makeSettings(QObject* parent)
-{
-	QString path = qApp->applicationDirPath() + "/" UNIXNAME ".ini";
-	return new QSettings {path, QSettings::IniFormat, parent};
-}
-
-// ---------------------------------------------------------------------------------------------------------------------
-//
-void MainWindow::syncSettings()
-{
-	m_settings->sync();
-}
-
-// ---------------------------------------------------------------------------------------------------------------------
-//
-QVariant MainWindow::getConfigValue (QString name)
-{
-	QVariant value = m_settings->value (name, configuration().defaultValueByName (name));
-	return value;
-}
-
 // ---------------------------------------------------------------------------------------------------------------------
 //
 void MainWindow::createBlankDocument()

mercurial