Horizon
preferences.hpp
1 #pragma once
2 #include "canvas/appearance.hpp"
3 #include "canvas3d/spacenav_prefs.hpp"
4 #include "canvas/input_devices_prefs.hpp"
5 #include "nlohmann/json_fwd.hpp"
6 #include <sigc++/sigc++.h>
7 #include <string>
8 #include "imp/action_catalog.hpp"
9 
10 namespace horizon {
11 using json = nlohmann::json;
12 
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  float zoom_factor = 50;
70  bool keyboard_zoom_to_cursor = false;
71 
72  void load_from_json(const json &j);
73  json serialize() const;
74 };
75 
77 public:
78  bool show_hints = true;
79  unsigned int max_depth = 50;
80 
81  void load_from_json(const json &j);
82  json serialize() const;
83 };
84 
86 public:
87  std::string url = "https://dev-partinfo.kitspace.org/graphql";
88  std::string preferred_distributor;
89  bool ignore_moq_gt_1 = true;
90  unsigned int max_price_breaks = 3;
91  unsigned int cache_days = 5;
92 
93  void load_from_json(const json &j);
94  json serialize() const;
95 };
96 
98 public:
99  std::string client_id;
100  std::string client_secret;
101  std::string site = "DE";
102  std::string currency = "EUR";
103  unsigned int max_price_breaks = 3;
104 
105  void load_from_json(const json &j);
106  json serialize() const;
107 };
108 
110 public:
111  bool enable = true;
112  bool remember = true;
113  bool show_in_tool = true;
114 
115  void load_from_json(const json &j);
116  json serialize() const;
117 };
118 
120 public:
121  bool switch_layers = true;
122  bool switch_sheets = true;
123  bool drag_polygon_edges = true;
124  bool drag_to_move = true;
125 
126  void load_from_json(const json &j);
127  json serialize() const;
128 };
129 
131 public:
132  bool vertical_layout = false;
133 
134  void load_from_json(const json &j);
135  json serialize() const;
136 };
137 
139 public:
140  bool dark_theme = false;
141 
142  void load_from_json(const json &j);
143  json serialize() const;
144 };
145 
147 public:
148  SpacenavPrefs prefs;
149 
150  std::vector<ActionID> buttons;
151 
152  void load_from_json(const json &j);
153  json serialize() const;
154 };
155 
157 public:
158  InputDevicesPrefs prefs;
159 
160  void load_from_json(const json &j);
161  json serialize() const;
162 };
163 
164 class Preferences {
165 public:
166  Preferences();
167  void set_filename(const std::string &filename);
168  void load();
169  void load_default();
170  void load_from_json(const json &j);
171  void save();
172  static std::string get_preferences_filename();
173  json serialize() const;
174 
175  CanvasPreferences canvas_non_layer;
176  CanvasPreferences canvas_layer;
177  SchematicPreferences schematic;
178  BoardPreferences board;
179  KeySequencesPreferences key_sequences;
180  ZoomPreferences zoom;
181  bool capture_output = false;
182 
183  enum class StockInfoProviderSel { NONE, PARTINFO, DIGIKEY };
184  StockInfoProviderSel stock_info_provider = StockInfoProviderSel::NONE;
185 
186  PartInfoPreferences partinfo;
187  DigiKeyApiPreferences digikey_api;
188  ActionBarPreferences action_bar;
189  InToolKeySequencesPreferences in_tool_key_sequences;
190  MousePreferences mouse;
191  UndoRedoPreferences undo_redo;
192  AppearancePreferences appearance;
193  ToolBarPreferences tool_bar;
194  SpacenavPreferences spacenav;
195  InputDevicesPreferences input_devices;
196 
197  bool show_pull_request_tools = false;
198  bool hud_debug = false;
199 
200  typedef sigc::signal<void> type_signal_changed;
201  type_signal_changed signal_changed()
202  {
203  return s_signal_changed;
204  }
205 
206 private:
207  std::string filename;
208  type_signal_changed s_signal_changed;
209 };
210 } // namespace horizon
Definition: preferences.hpp:109
Definition: preferences.hpp:138
Definition: appearance.hpp:7
Definition: preferences.hpp:34
Definition: preferences.hpp:15
Definition: preferences.hpp:97
Definition: preferences.hpp:55
Definition: preferences.hpp:156
Definition: input_devices_prefs.hpp:6
Definition: preferences.hpp:46
Definition: preferences.hpp:119
Definition: preferences.hpp:85
Definition: preferences.hpp:164
Definition: preferences.hpp:24
Definition: preferences.hpp:146
Definition: preferences.hpp:130
Definition: preferences.hpp:76
Definition: preferences.hpp:64
a class to store JSON values
Definition: json.hpp:177
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62
Definition: spacenav_prefs.hpp:4