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