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 
8 namespace horizon {
9 using json = nlohmann::json;
10 
11 enum class ActionID;
12 enum class ToolID;
13 enum class InToolActionID;
14 
16 public:
17  Appearance appearance;
18  void load_from_json(const json &j);
19  void load_colors_from_json(const json &j);
20  json serialize() const;
21  json serialize_colors() const;
22 };
23 
25 public:
26  bool show_all_junctions = false;
27  bool drag_start_net_line = true;
28  bool bend_non_ortho = true;
29 
30  void load_from_json(const json &j);
31  json serialize() const;
32 };
33 
35 public:
36  bool drag_start_track = true;
37  bool highlight_on_top = true;
38  bool show_text_in_tracks = true;
39  bool show_text_in_vias = true;
40  bool move_using_router = true;
41 
42  void load_from_json(const json &j);
43  json serialize() const;
44 };
45 
47 public:
48  std::map<ActionToolID, std::map<ActionCatalogItem::Availability, std::vector<KeySequence>>> keys;
49 
50  void load_from_json(const json &j);
51  void append_from_json(const json &j);
52  json serialize() const;
53 };
54 
56 public:
57  std::map<InToolActionID, std::vector<KeySequence>> keys;
58 
59  void load_from_json(const json &j);
60  void append_from_json(const json &j);
61  json serialize() const;
62 };
63 
65 public:
66  bool smooth_zoom_2d = true;
67  bool smooth_zoom_3d = false;
68  bool touchpad_pan = false;
69 
70  void load_from_json(const json &j);
71  json serialize() const;
72 };
73 
75 public:
76  bool enable = false;
77  std::string url = "https://dev-partinfo.kitspace.org/graphql";
78  std::string preferred_distributor;
79  bool ignore_moq_gt_1 = true;
80  unsigned int max_price_breaks = 3;
81  unsigned int cache_days = 5;
82  bool is_enabled() const;
83 
84  void load_from_json(const json &j);
85  json serialize() const;
86 };
87 
89 public:
90  bool enable = true;
91  bool remember = true;
92 
93  void load_from_json(const json &j);
94  json serialize() const;
95 };
96 
97 class Preferences {
98 public:
99  Preferences();
100  void set_filename(const std::string &filename);
101  void load();
102  void load_default();
103  void load_from_json(const json &j);
104  void save();
105  static std::string get_preferences_filename();
106  json serialize() const;
107 
108  CanvasPreferences canvas_non_layer;
109  CanvasPreferences canvas_layer;
110  SchematicPreferences schematic;
111  BoardPreferences board;
112  KeySequencesPreferences key_sequences;
113  ZoomPreferences zoom;
114  bool capture_output = false;
115  PartInfoPreferences partinfo;
116  ActionBarPreferences action_bar;
117  InToolKeySequencesPreferences in_tool_key_sequences;
118 
119 
120  typedef sigc::signal<void> type_signal_changed;
121  type_signal_changed signal_changed()
122  {
123  return s_signal_changed;
124  }
125 
126 private:
127  std::string filename;
128  type_signal_changed s_signal_changed;
129 };
130 } // namespace horizon
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::SchematicPreferences
Definition: preferences.hpp:24
horizon::ActionBarPreferences
Definition: preferences.hpp:88
horizon::Preferences
Definition: preferences.hpp:97
horizon::Appearance
Definition: appearance.hpp:7
horizon::CanvasPreferences
Definition: preferences.hpp:15
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:166
horizon::PartInfoPreferences
Definition: preferences.hpp:74
horizon::ZoomPreferences
Definition: preferences.hpp:64
horizon::InToolKeySequencesPreferences
Definition: preferences.hpp:55
horizon::BoardPreferences
Definition: preferences.hpp:34
horizon::KeySequencesPreferences
Definition: preferences.hpp:46