GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
WindowStateSO.h
1 
29 #pragma once
30 
31 namespace GpgFrontend::UI {
32 
33 struct WindowStateSO {
34  bool window_save = false;
35  QString window_state_data;
36  int x = 100;
37  int y = 100;
38  int width = 400;
39  int height = 200;
40 
41  WindowStateSO() = default;
42 
43  explicit WindowStateSO(const QJsonObject &j) {
44  if (const auto v = j["window_save"]; v.isBool()) window_save = v.toBool();
45  if (const auto v = j["window_state_data"]; v.isString()) {
46  window_state_data = v.toString();
47  }
48  if (const auto v = j["x"]; v.isDouble()) x = v.toInt();
49  if (const auto v = j["y"]; v.isDouble()) y = v.toInt();
50  if (const auto v = j["width"]; v.isDouble()) width = v.toInt();
51  if (const auto v = j["height"]; v.isDouble()) height = v.toInt();
52  }
53 
54  [[nodiscard]] auto Json() const -> QJsonObject {
55  QJsonObject j;
56  j["window_save"] = window_save;
57  j["window_state_data"] = window_state_data;
58  j["x"] = x;
59  j["y"] = y;
60  j["width"] = width;
61  j["height"] = height;
62  return j;
63  }
64 };
65 } // namespace GpgFrontend::UI
Definition: FileReadTask.cpp:31
Definition: WindowStateSO.h:33