Horizon
preferences.hpp
1 #pragma once
2 #include "canvas/appearance.hpp"
3 #include "canvas3d/spacenav_prefs.hpp"
4 #include "nlohmann/json_fwd.hpp"
5 #include <sigc++/sigc++.h>
6 #include <string>
7 #include "imp/action_catalog.hpp"
8 
9 namespace horizon {
10 using json = nlohmann::json;
11 
12 enum class InToolActionID;
13 
15 public:
16  Appearance appearance;
17  void load_from_json(const json &j);
18  void load_colors_from_json(const json &j);
19  json serialize() const;
20  json serialize_colors() const;
21 };
22 
24 public:
25  bool show_all_junctions = false;
26  bool drag_start_net_line = true;
27  bool bend_non_ortho = true;
28 
29  void load_from_json(const json &j);
30  json serialize() const;
31 };
32 
34 public:
35  bool drag_start_track = true;
36  bool highlight_on_top = true;
37  bool show_text_in_tracks = true;
38  bool show_text_in_vias = true;
39  bool move_using_router = true;
40 
41  void load_from_json(const json &j);
42  json serialize() const;
43 };
44 
46 public:
47  std::map<ActionToolID, std::map<ActionCatalogItem::Availability, std::vector<KeySequence>>> keys;
48 
49  void load_from_json(const json &j);
50  void append_from_json(const json &j);
51  json serialize() const;
52 };
53 
55 public:
56  std::map<InToolActionID, std::vector<KeySequence>> keys;
57 
58  void load_from_json(const json &j);
59  void append_from_json(const json &j);
60  json serialize() const;
61 };
62 
64 public:
65  bool smooth_zoom_2d = true;
66  bool smooth_zoom_3d = false;
67  bool touchpad_pan = false;
68  float zoom_factor = 50;
69  bool keyboard_zoom_to_cursor = false;
70 
71  void load_from_json(const json &j);
72  json serialize() const;
73 };
74 
76 public:
77  bool show_hints = true;
78  unsigned int max_depth = 50;
79 
80  void load_from_json(const json &j);
81  json serialize() const;
82 };
83 
85 public:
86  std::string url = "https://dev-partinfo.kitspace.org/graphql";
87  std::string preferred_distributor;
88  bool ignore_moq_gt_1 = true;
89  unsigned int max_price_breaks = 3;
90  unsigned int cache_days = 5;
91 
92  void load_from_json(const json &j);
93  json serialize() const;
94 };
95 
97 public:
98  std::string client_id;
99  std::string client_secret;
100  std::string site = "DE";
101  std::string currency = "EUR";
102  unsigned int max_price_breaks = 3;
103 
104  void load_from_json(const json &j);
105  json serialize() const;
106 };
107 
109 public:
110  bool enable = true;
111  bool remember = true;
112  bool show_in_tool = true;
113 
114  void load_from_json(const json &j);
115  json serialize() const;
116 };
117 
119 public:
120  bool switch_layers = true;
121  bool switch_sheets = true;
122  bool drag_polygon_edges = true;
123  bool drag_to_move = true;
124 
125  void load_from_json(const json &j);
126  json serialize() const;
127 };
128 
130 public:
131  bool dark_theme = false;
132 
133  void load_from_json(const json &j);
134  json serialize() const;
135 };
136 
138 public:
139  SpacenavPrefs prefs;
140 
141  std::vector<ActionID> buttons;
142 
143  void load_from_json(const json &j);
144  json serialize() const;
145 };
146 
147 class Preferences {
148 public:
149  Preferences();
150  void set_filename(const std::string &filename);
151  void load();
152  void load_default();
153  void load_from_json(const json &j);
154  void save();
155  static std::string get_preferences_filename();
156  json serialize() const;
157 
158  CanvasPreferences canvas_non_layer;
159  CanvasPreferences canvas_layer;
160  SchematicPreferences schematic;
161  BoardPreferences board;
162  KeySequencesPreferences key_sequences;
163  ZoomPreferences zoom;
164  bool capture_output = false;
165 
166  enum class StockInfoProviderSel { NONE, PARTINFO, DIGIKEY };
167  StockInfoProviderSel stock_info_provider = StockInfoProviderSel::NONE;
168 
169  PartInfoPreferences partinfo;
170  DigiKeyApiPreferences digikey_api;
171  ActionBarPreferences action_bar;
172  InToolKeySequencesPreferences in_tool_key_sequences;
173  MousePreferences mouse;
174  UndoRedoPreferences undo_redo;
175  AppearancePreferences appearance;
176  SpacenavPreferences spacenav;
177 
178  bool show_pull_request_tools = false;
179  bool hud_debug = false;
180 
181  typedef sigc::signal<void> type_signal_changed;
182  type_signal_changed signal_changed()
183  {
184  return s_signal_changed;
185  }
186 
187 private:
188  std::string filename;
189  type_signal_changed s_signal_changed;
190 };
191 } // namespace horizon
Definition: preferences.hpp:108
Definition: preferences.hpp:129
Definition: appearance.hpp:7
Definition: preferences.hpp:33
Definition: preferences.hpp:14
Definition: preferences.hpp:96
Definition: preferences.hpp:54
Definition: preferences.hpp:45
Definition: preferences.hpp:118
Definition: preferences.hpp:84
Definition: preferences.hpp:147
Definition: preferences.hpp:23
Definition: preferences.hpp:137
Definition: preferences.hpp:75
Definition: preferences.hpp:63
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