Horizon
preferences.hpp
1 #pragma once
2 #include "canvas/appearance.hpp"
3 #include "nlohmann/json_fwd.hpp"
4 #include <sigc++/sigc++.h>
5 #include <string>
6 #include "imp/action_catalog.hpp"
7 #include "imp/action.hpp"
8 #include "core/tool_id.hpp"
9 
10 namespace horizon {
11 using json = nlohmann::json;
12 
14 public:
15  Appearance appearance;
16  void load_from_json(const json &j);
17  void load_colors_from_json(const json &j);
18  json serialize() const;
19  json serialize_colors() const;
20 };
21 
23 public:
24  bool show_all_junctions = false;
25  bool drag_start_net_line = true;
26 
27  void load_from_json(const json &j);
28  json serialize() const;
29 };
30 
32 public:
33  bool drag_start_track = true;
34 
35  void load_from_json(const json &j);
36  json serialize() const;
37 };
38 
40 public:
41  std::map<std::pair<ActionID, ToolID>, std::map<ActionCatalogItem::Availability, std::vector<KeySequence2>>> keys;
42 
43  void load_from_json(const json &j);
44  void append_from_json(const json &j);
45  json serialize() const;
46 };
47 
49 public:
50  bool smooth_zoom_2d = true;
51  bool smooth_zoom_3d = false;
52 
53  void load_from_json(const json &j);
54  json serialize() const;
55 };
56 
57 class Preferences : public sigc::trackable {
58 public:
59  Preferences();
60  void set_filename(const std::string &filename);
61  void load();
62  void load_default();
63  void load_from_json(const json &j);
64  void save();
65  static std::string get_preferences_filename();
66  json serialize() const;
67 
68  CanvasPreferences canvas_non_layer;
69  CanvasPreferences canvas_layer;
70  SchematicPreferences schematic;
71  BoardPreferences board;
72  KeySequencesPreferences key_sequences;
73  ZoomPreferences zoom;
74 
75  typedef sigc::signal<void> type_signal_changed;
76  type_signal_changed signal_changed()
77  {
78  return s_signal_changed;
79  }
80 
81 private:
82  std::string filename;
83  type_signal_changed s_signal_changed;
84 };
85 } // namespace horizon
a class to store JSON values
Definition: json.hpp:161
Definition: preferences.hpp:13
Definition: preferences.hpp:22
Definition: appearance.hpp:7
Definition: block.cpp:9
Definition: preferences.hpp:31
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
Definition: preferences.hpp:39
Definition: preferences.hpp:57
Definition: preferences.hpp:48