GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
AppearanceSO.h
1 
29 #pragma once
30 
31 namespace GpgFrontend::UI {
32 
33 struct AppearanceSO {
34  int text_editor_font_size = 12;
35  int info_board_font_size = 12;
36  int tool_bar_icon_width = 24;
37  int tool_bar_icon_height = 24;
38  Qt::ToolButtonStyle tool_bar_button_style = Qt::ToolButtonTextUnderIcon;
39 
40  bool save_window_state;
41 
42  explicit AppearanceSO(const QJsonObject& j) {
43  if (const auto v = j["text_editor_font_size"]; v.isDouble()) {
44  text_editor_font_size = v.toInt();
45  }
46  if (const auto v = j["info_board_font_size"]; v.isDouble()) {
47  info_board_font_size = v.toInt();
48  }
49  if (const auto v = j["tool_bar_icon_width"]; v.isDouble()) {
50  tool_bar_icon_width = v.toInt();
51  }
52  if (const auto v = j["tool_bar_icon_height"]; v.isDouble()) {
53  tool_bar_icon_height = v.toInt();
54  }
55  if (const auto v = j["tool_bar_button_style"]; v.isDouble()) {
56  tool_bar_button_style = static_cast<Qt::ToolButtonStyle>(v.toInt());
57  }
58 
59  if (const auto v = j["save_window_state"]; v.isBool()) {
60  save_window_state = v.toBool();
61  }
62  }
63 
64  [[nodiscard]] auto ToJson() const -> QJsonObject {
65  QJsonObject j;
66  j["text_editor_font_size"] = text_editor_font_size;
67  j["info_board_font_size"] = info_board_font_size;
68  j["tool_bar_icon_width"] = tool_bar_icon_width;
69  j["tool_bar_icon_height"] = tool_bar_icon_height;
70  j["tool_bar_button_style"] = tool_bar_button_style;
71 
72  j["save_window_state"] = save_window_state;
73  return j;
74  }
75 };
76 
77 } // namespace GpgFrontend::UI
Definition: FileReadTask.cpp:31
Definition: AppearanceSO.h:33