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 #include "imp/action.hpp"
8 #include "core/tool_id.hpp"
9 
10 namespace horizon {
11 using json = nlohmann::json;
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 
27  void load_from_json(const json &j);
28  json serialize() const;
29 };
30 
32 public:
33  bool drag_start_track = true;
34  bool highlight_on_top = true;
35  bool show_text_in_tracks = true;
36 
37  void load_from_json(const json &j);
38  json serialize() const;
39 };
40 
42 public:
43  std::map<std::pair<ActionID, ToolID>, std::map<ActionCatalogItem::Availability, std::vector<KeySequence>>> keys;
44 
45  void load_from_json(const json &j);
46  void append_from_json(const json &j);
47  json serialize() const;
48 };
49 
51 public:
52  bool smooth_zoom_2d = true;
53  bool smooth_zoom_3d = false;
54 
55  void load_from_json(const json &j);
56  json serialize() const;
57 };
58 
60 public:
61  bool enable = false;
62  std::string url = "https://dev-partinfo.kitspace.org/graphql";
63  std::string preferred_distributor;
64  bool ignore_moq_gt_1 = true;
65  unsigned int max_price_breaks = 3;
66  unsigned int cache_days = 5;
67  bool is_enabled() const;
68 
69  void load_from_json(const json &j);
70  json serialize() const;
71 };
72 
73 class Preferences {
74 public:
75  Preferences();
76  void set_filename(const std::string &filename);
77  void load();
78  void load_default();
79  void load_from_json(const json &j);
80  void save();
81  static std::string get_preferences_filename();
82  json serialize() const;
83 
84  CanvasPreferences canvas_non_layer;
85  CanvasPreferences canvas_layer;
86  SchematicPreferences schematic;
87  BoardPreferences board;
88  KeySequencesPreferences key_sequences;
89  ZoomPreferences zoom;
90  bool capture_output = false;
91  PartInfoPreferences partinfo;
92 
93  typedef sigc::signal<void> type_signal_changed;
94  type_signal_changed signal_changed()
95  {
96  return s_signal_changed;
97  }
98 
99 private:
100  std::string filename;
101  type_signal_changed s_signal_changed;
102 };
103 } // namespace horizon
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::SchematicPreferences
Definition: preferences.hpp:22
horizon::Preferences
Definition: preferences.hpp:73
horizon::Appearance
Definition: appearance.hpp:7
horizon::CanvasPreferences
Definition: preferences.hpp:13
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:161
horizon::PartInfoPreferences
Definition: preferences.hpp:59
horizon::ZoomPreferences
Definition: preferences.hpp:50
horizon::BoardPreferences
Definition: preferences.hpp:31
horizon::KeySequencesPreferences
Definition: preferences.hpp:41