diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-04-30 13:47:03 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-04-30 13:47:03 +0200 |
commit | 9bbdba9eab28c2ba44002bada4b3bb1c0962bd90 (patch) | |
tree | 4a56a077b8597395dd0f38c5ab9cb0c87862afa1 /linux | |
parent | e95ece83335b85ed063f8ea903acc71d5a2fb995 (diff) | |
download | qtlocation-mapboxgl-9bbdba9eab28c2ba44002bada4b3bb1c0962bd90.tar.gz |
remove concept of settings object from library
Diffstat (limited to 'linux')
-rw-r--r-- | linux/llmr-app.gyp | 4 | ||||
-rw-r--r-- | linux/main.cpp | 29 | ||||
-rw-r--r-- | linux/settings.cpp | 55 | ||||
-rw-r--r-- | linux/settings.hpp | 19 |
4 files changed, 21 insertions, 86 deletions
diff --git a/linux/llmr-app.gyp b/linux/llmr-app.gyp index 8cf352554d..d979f00b48 100644 --- a/linux/llmr-app.gyp +++ b/linux/llmr-app.gyp @@ -10,8 +10,8 @@ 'type': 'executable', 'sources': [ './main.cpp', - './settings.cpp', - './settings.hpp', + '../common/settings_json.cpp', + '../common/settings_json.hpp', '../common/glfw_view.hpp', '../common/glfw_view.cpp', '../common/curl_request.cpp', diff --git a/linux/main.cpp b/linux/main.cpp index 32ae04cca9..2c7440c876 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -4,15 +4,15 @@ #include <signal.h> #include <getopt.h> -#include "settings.hpp" +#include "../common/settings_json.hpp" #include "../common/glfw_view.hpp" -MapView *mapView = nullptr; +GLFWView *view = nullptr; void quit_handler(int) { - if (mapView) { + if (view) { fprintf(stderr, "waiting for quit...\n"); - glfwSetWindowShouldClose(mapView->window, true); + glfwSetWindowShouldClose(view->window, true); glfwPostEmptyEvent(); } else { exit(0); @@ -40,13 +40,22 @@ int main(int argc, char *argv[]) { sigIntHandler.sa_flags = 0; sigaction(SIGINT, &sigIntHandler, NULL); - // main loop + view = new GLFWView(); + llmr::Map map(*view); + + // Load settings llmr::Settings_JSON settings; - mapView = new MapView(settings, fullscreen_flag); - mapView->init(); - int ret = mapView->run(); - mapView->settings.sync(); - delete mapView; + map.setLonLatZoom(settings.longitude, settings.latitude, settings.zoom); + map.setAngle(settings.angle); + map.setDebug(settings.debug); + + int ret = view->run(); + + // Save settings + map.getLonLatZoom(settings.longitude, settings.latitude, settings.zoom); + settings.angle = map.getAngle(); + settings.debug = map.getDebug(); + settings.save(); return ret; } diff --git a/linux/settings.cpp b/linux/settings.cpp deleted file mode 100644 index 73df446f6a..0000000000 --- a/linux/settings.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "settings.hpp" -#include "rapidjson/prettywriter.h" -#include "rapidjson/filestream.h" -#include "rapidjson/document.h" -#include <stdio.h> - -using namespace llmr; - -Settings_JSON::Settings_JSON() -{ -} - -void Settings_JSON::load() -{ - FILE *settingsFile = fopen("/tmp/llmr-native.json", "r"); - if (settingsFile != NULL) { - rapidjson::FileStream is(settingsFile); - rapidjson::Document document; - document.ParseStream<0>(is); - if (document.IsArray()) { - longitude = document[rapidjson::SizeType(0)].GetDouble(); - latitude = document[1].GetDouble(); - scale = document[2].GetDouble(); - angle = document[3].GetDouble(); - debug = document[4].GetBool(); - } - } -} - -void Settings_JSON::persist() -{ -} - -void Settings_JSON::sync() -{ - - rapidjson::FileStream s(fopen("/tmp/llmr-native.json", "w")); - rapidjson::PrettyWriter<rapidjson::FileStream> writer(s); - writer.StartArray(); - writer.Double(longitude); - writer.Double(latitude); - writer.Double(scale); - writer.Double(angle); - writer.Bool(debug); - writer.EndArray(); -} - -void Settings_JSON::clear() -{ - longitude = 0; - latitude = 0; - scale = 0; - angle = 0; - debug = false; -} diff --git a/linux/settings.hpp b/linux/settings.hpp deleted file mode 100644 index a171e8ab8f..0000000000 --- a/linux/settings.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef LLMR_JSON_SETTINGS -#define LLMR_JSON_SETTINGS - -#include <llmr/map/settings.hpp> - -namespace llmr { - -class Settings_JSON : public Settings { -public: - Settings_JSON(); - virtual void load(); - virtual void persist(); - virtual void sync(); - virtual void clear(); -}; - -} - -#endif |