summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gui/mapping-window.cpp11
-rw-r--r--logic/mappings.hpp6
-rw-r--r--options/bundle.cpp9
-rw-r--r--options/bundle.hpp1
-rw-r--r--options/group.cpp12
-rw-r--r--options/group.hpp2
-rw-r--r--spline-widget/spline.cpp9
-rw-r--r--spline-widget/spline.hpp1
8 files changed, 36 insertions, 15 deletions
diff --git a/gui/mapping-window.cpp b/gui/mapping-window.cpp
index 96469e65..47e12c31 100644
--- a/gui/mapping-window.cpp
+++ b/gui/mapping-window.cpp
@@ -89,15 +89,18 @@ void MapWidget::closeEvent(QCloseEvent*)
void MapWidget::save_dialog()
{
- s.b_map->save();
+ mem<QSettings> settings_ = group::ini_file();
+ QSettings& settings = *settings_;
+
+ s.b_map->save_deferred(settings);
for (int i = 0; i < 6; i++)
{
m.forall([&](Map& s)
{
- s.spline_main.save();
- s.spline_alt.save();
- s.opts.b_mapping_window->save();
+ s.spline_main.save(settings);
+ s.spline_alt.save(settings);
+ s.opts.b_mapping_window->save_deferred(settings);
});
}
}
diff --git a/logic/mappings.hpp b/logic/mappings.hpp
index 942f53d2..15752624 100644
--- a/logic/mappings.hpp
+++ b/logic/mappings.hpp
@@ -27,10 +27,10 @@ struct Map final
{
}
- void save()
+ void save(QSettings& s)
{
- spline_main.save();
- spline_alt.save();
+ spline_main.save(s);
+ spline_alt.save(s);
}
void load()
diff --git a/options/bundle.cpp b/options/bundle.cpp
index a60810c5..fa1a214c 100644
--- a/options/bundle.cpp
+++ b/options/bundle.cpp
@@ -37,7 +37,7 @@ bool bundle::contains(const QString &name) const
return transient.contains(name);
}
-void bundle::save()
+void bundle::save_deferred(QSettings& s)
{
if (group_name == "")
return;
@@ -51,7 +51,7 @@ void bundle::save()
qDebug() << "bundle" << group_name << "changed, saving";
modified_ = true;
saved = transient;
- saved.save();
+ saved.save_deferred(s);
}
}
@@ -59,6 +59,11 @@ void bundle::save()
emit saving();
}
+void bundle::save()
+{
+ save_deferred(*group::ini_file());
+}
+
bool bundle::modifiedp() const // XXX unused
{
QMutexLocker l(const_cast<QMutex*>(&mtx));
diff --git a/options/bundle.hpp b/options/bundle.hpp
index 56d48f60..0283c911 100644
--- a/options/bundle.hpp
+++ b/options/bundle.hpp
@@ -41,6 +41,7 @@ public:
void store_kv(const QString& name, const QVariant& datum);
bool contains(const QString& name) const;
void save();
+ void save_deferred(QSettings& s);
bool modifiedp() const;
template<typename t>
diff --git a/options/group.cpp b/options/group.cpp
index 8aa381fc..d710afad 100644
--- a/options/group.cpp
+++ b/options/group.cpp
@@ -24,14 +24,18 @@ group::group(const QString& name) : name(name)
void group::save() const
{
+ save_deferred(*ini_file());
+}
+
+void group::save_deferred(QSettings& s) const
+{
if (name == "")
return;
- auto s = ini_file();
- s->beginGroup(name);
+ s.beginGroup(name);
for (auto& i : kvs)
- s->setValue(i.first, i.second);
- s->endGroup();
+ s.setValue(i.first, i.second);
+ s.endGroup();
}
void group::put(const QString &s, const QVariant &d)
diff --git a/options/group.hpp b/options/group.hpp
index 0deddfa8..05ef3b4b 100644
--- a/options/group.hpp
+++ b/options/group.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "export.hpp"
+#include "compat/util.hpp"
#include <map>
#include <memory>
#include <QString>
@@ -19,6 +20,7 @@ private:
public:
group(const QString& name);
void save() const;
+ void save_deferred(QSettings& s) const;
void put(const QString& s, const QVariant& d);
bool contains(const QString& s) const;
static QString ini_directory();
diff --git a/spline-widget/spline.cpp b/spline-widget/spline.cpp
index da67f0d4..c71076f4 100644
--- a/spline-widget/spline.cpp
+++ b/spline-widget/spline.cpp
@@ -254,10 +254,15 @@ void spline::reload()
s->b->reload();
}
-void spline::save()
+void spline::save(QSettings& settings)
{
if (s && s->b)
- s->b->save();
+ s->b->save_deferred(settings);
+}
+
+void spline::save()
+{
+ save(*group::ini_file());
}
void spline::set_bundle(bundle b)
diff --git a/spline-widget/spline.hpp b/spline-widget/spline.hpp
index 4f6531b9..5b0b3afc 100644
--- a/spline-widget/spline.hpp
+++ b/spline-widget/spline.hpp
@@ -70,6 +70,7 @@ private:
public:
void reload();
+ void save(QSettings& s);
void save();
void set_bundle(bundle b);