17class EditorSettings :
public QObject
21 Q_PROPERTY (
double x READ getX WRITE setX NOTIFY xChanged)
22 Q_PROPERTY (
double y READ getY WRITE setY NOTIFY yChanged)
24 double horizontalZoomLevel READ getHorizontalZoomLevel WRITE
25 setHorizontalZoomLevel NOTIFY horizontalZoomLevelChanged)
28 EditorSettings (QObject * parent =
nullptr) : QObject (parent) { }
34 double getX ()
const {
return scroll_start_x_; }
37 auto clamped_x = clamp_scroll_start_x (x);
41 scroll_start_x_ = clamped_x;
42 Q_EMIT xChanged (scroll_start_x_);
44 Q_SIGNAL
void xChanged (
double x);
46 double getY ()
const {
return scroll_start_y_; }
49 auto clamped_y = clamp_scroll_start_y (y);
52 scroll_start_y_ = clamped_y;
53 Q_EMIT yChanged (scroll_start_y_);
55 Q_SIGNAL
void yChanged (
double y);
57 double getHorizontalZoomLevel ()
const {
return hzoom_level_; }
58 void setHorizontalZoomLevel (
double hzoom_level)
62 hzoom_level_ = hzoom_level;
63 Q_EMIT horizontalZoomLevelChanged (hzoom_level);
65 Q_SIGNAL
void horizontalZoomLevelChanged (
double hzoom_level);
69 double clamp_scroll_start_x (
double x);
71 double clamp_scroll_start_y (
double y);
79 friend void init_from (
81 const EditorSettings &other,
84 obj.scroll_start_x_ = other.scroll_start_x_;
85 obj.scroll_start_y_ = other.scroll_start_y_;
86 obj.hzoom_level_ = other.hzoom_level_;
90 static constexpr auto kScrollStartXKey =
"scrollStartX"sv;
91 static constexpr auto kScrollStartYKey =
"scrollStartY"sv;
92 static constexpr auto kHZoomLevelKey =
"hZoomLevel"sv;
93 friend void to_json (nlohmann::json &j,
const EditorSettings &settings);
94 friend void from_json (
const nlohmann::json &j,
EditorSettings &settings);
98 double scroll_start_x_ = 0;
101 double scroll_start_y_ = 0;
104 double hzoom_level_ = 1.0;