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  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  std::string url = "https://dev-partinfo.kitspace.org/graphql";
79  std::string preferred_distributor;
80  bool ignore_moq_gt_1 = true;
81  unsigned int max_price_breaks = 3;
82  unsigned int cache_days = 5;
83 
84  void load_from_json(const json &j);
85  json serialize() const;
86 };
87 
89 public:
90  std::string client_id;
91  std::string client_secret;
92  std::string site = "DE";
93  std::string currency = "EUR";
94  unsigned int max_price_breaks = 3;
95 
96  void load_from_json(const json &j);
97  json serialize() const;
98 };
99 
101 public:
102  bool enable = true;
103  bool remember = true;
104  bool show_in_tool = true;
105 
106  void load_from_json(const json &j);
107  json serialize() const;
108 };
109 
111 public:
112  bool switch_layers = true;
113  bool switch_sheets = true;
114  bool drag_polygon_edges = true;
115  bool drag_to_move = true;
116 
117  void load_from_json(const json &j);
118  json serialize() const;
119 };
120 
121 class Preferences {
122 public:
123  Preferences();
124  void set_filename(const std::string &filename);
125  void load();
126  void load_default();
127  void load_from_json(const json &j);
128  void save();
129  static std::string get_preferences_filename();
130  json serialize() const;
131 
132  CanvasPreferences canvas_non_layer;
133  CanvasPreferences canvas_layer;
134  SchematicPreferences schematic;
135  BoardPreferences board;
136  KeySequencesPreferences key_sequences;
137  ZoomPreferences zoom;
138  bool capture_output = false;
139 
140  enum class StockInfoProviderSel { NONE, PARTINFO, DIGIKEY };
141  StockInfoProviderSel stock_info_provider = StockInfoProviderSel::NONE;
142 
143  PartInfoPreferences partinfo;
144  DigiKeyApiPreferences digikey_api;
145  ActionBarPreferences action_bar;
146  InToolKeySequencesPreferences in_tool_key_sequences;
147  MousePreferences mouse;
148 
149  bool show_pull_request_tools = false;
150  bool hud_debug = false;
151 
152  typedef sigc::signal<void> type_signal_changed;
153  type_signal_changed signal_changed()
154  {
155  return s_signal_changed;
156  }
157 
158 private:
159  std::string filename;
160  type_signal_changed s_signal_changed;
161 };
162 } // namespace horizon
Definition: preferences.hpp:100
Definition: appearance.hpp:7
Definition: preferences.hpp:34
Definition: preferences.hpp:15
Definition: preferences.hpp:88
Definition: preferences.hpp:55
Definition: preferences.hpp:46
Definition: preferences.hpp:110
Definition: preferences.hpp:76
Definition: preferences.hpp:121
Definition: preferences.hpp:24
Definition: preferences.hpp:64
a class to store JSON values
Definition: json.hpp:170
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62