summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-17 22:14:45 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-08-17 22:32:05 +0200
commit2a7101c6544c7ce49ff6d306734a34b41a936166 (patch)
treeb57ea859b6ea766d964c4cdb0d9c3e39be026b1a
parentcb7e947f37695f97b023a8261e4586704fd28ece (diff)
gui/mapping-window: update to new api
-rw-r--r--gui/mapping-window.cpp49
-rw-r--r--gui/mapping-window.hpp6
2 files changed, 46 insertions, 9 deletions
diff --git a/gui/mapping-window.cpp b/gui/mapping-window.cpp
index 12b36e2a..96469e65 100644
--- a/gui/mapping-window.cpp
+++ b/gui/mapping-window.cpp
@@ -14,8 +14,6 @@ MapWidget::MapWidget(Mappings& m) :
{
ui.setupUi(this);
- m.load_mappings();
-
reload();
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
@@ -58,9 +56,14 @@ void MapWidget::reload()
for (int i = 0; qfcs[i].qfc; i++)
{
const bool altp = qfcs[i].altp;
+
Map& axis = m(qfcs[i].axis);
- spline* conf = altp ? &axis.spline_alt : &axis.spline_main;
- const auto& name = qfcs[i].altp ? axis.name2 : axis.name1;
+ spline& conf = altp ? axis.spline_alt : axis.spline_main;
+ const QString& name = altp ? axis.name2 : axis.name1;
+ bundle b = make_bundle(name);
+ conf.set_bundle(b);
+ qfcs[i].qfc->setConfig(&conf, b);
+
if (altp)
{
spline_widget& qfc = *qfcs[i].qfc;
@@ -75,20 +78,50 @@ void MapWidget::reload()
qfcs[i].qfc->set_snap(1, 5);
else
qfcs[i].qfc->set_snap(1, 5);
-
- qfcs[i].qfc->setConfig(conf, name);
}
}
}
+void MapWidget::closeEvent(QCloseEvent*)
+{
+ invalidate_dialog();
+}
+
+void MapWidget::save_dialog()
+{
+ s.b_map->save();
+
+ 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();
+ });
+ }
+}
+
+void MapWidget::invalidate_dialog()
+{
+ s.b_map->reload();
+
+ m.forall([](Map& s)
+ {
+ s.spline_main.reload();
+ s.spline_alt.reload();
+ s.opts.b_mapping_window->reload();
+ });
+}
+
void MapWidget::doOK()
{
- m.save_mappings();
+ save_dialog();
close();
}
void MapWidget::doCancel()
{
- m.invalidate_unsaved();
+ invalidate_dialog();
close();
}
diff --git a/gui/mapping-window.hpp b/gui/mapping-window.hpp
index aeaed211..cb589efc 100644
--- a/gui/mapping-window.hpp
+++ b/gui/mapping-window.hpp
@@ -14,7 +14,11 @@ private:
Mappings& m;
main_settings s;
- void closeEvent(QCloseEvent *) override { doCancel(); }
+ void closeEvent(QCloseEvent*) override;
+
+ void save_dialog();
+ void invalidate_dialog();
+
private slots:
void doOK();
void doCancel();