19class EditorSettings :
public QObject
23 Q_PROPERTY (
double x READ getX WRITE setX NOTIFY xChanged)
24 Q_PROPERTY (
double y READ getY WRITE setY NOTIFY yChanged)
26 double horizontalZoomLevel READ getHorizontalZoomLevel WRITE
27 setHorizontalZoomLevel NOTIFY horizontalZoomLevelChanged)
30 EditorSettings (QObject * parent =
nullptr) : QObject (parent) { }
36 double getX ()
const {
return scroll_start_x_; }
39 auto clamped_x = clamp_scroll_start_x (x);
43 scroll_start_x_ = clamped_x;
44 Q_EMIT xChanged (scroll_start_x_);
46 Q_SIGNAL
void xChanged (
double x);
48 double getY ()
const {
return scroll_start_y_; }
51 auto clamped_y = clamp_scroll_start_y (y);
54 scroll_start_y_ = clamped_y;
55 Q_EMIT yChanged (scroll_start_y_);
57 Q_SIGNAL
void yChanged (
double y);
59 double getHorizontalZoomLevel ()
const {
return hzoom_level_; }
60 void setHorizontalZoomLevel (
double hzoom_level)
64 hzoom_level_ = hzoom_level;
65 Q_EMIT horizontalZoomLevelChanged (hzoom_level);
67 Q_SIGNAL
void horizontalZoomLevelChanged (
double hzoom_level);
71 double clamp_scroll_start_x (
double x);
73 double clamp_scroll_start_y (
double y);
81 friend void init_from (
83 const EditorSettings &other,
86 obj.scroll_start_x_ = other.scroll_start_x_;
87 obj.scroll_start_y_ = other.scroll_start_y_;
88 obj.hzoom_level_ = other.hzoom_level_;
92 static constexpr auto kScrollStartXKey =
"scrollStartX"sv;
93 static constexpr auto kScrollStartYKey =
"scrollStartY"sv;
94 static constexpr auto kHZoomLevelKey =
"hZoomLevel"sv;
95 friend void to_json (nlohmann::json &j,
const EditorSettings &settings);
96 friend void from_json (
const nlohmann::json &j,
EditorSettings &settings);
100 double scroll_start_x_ = 0;
103 double scroll_start_y_ = 0;
106 double hzoom_level_ = 1.0;