MCPcopy Create free account
hub / github.com/MultiMC/Launcher / writeThemeJson

Function writeThemeJson

launcher/ui/themes/CustomTheme.cpp:83–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83static bool writeThemeJson(const QString &path, const QPalette &palette, double fadeAmount, QColor fadeColor, QString name, QString widgets)
84{
85 QJsonObject rootObj;
86 rootObj.insert("name", name);
87 rootObj.insert("widgets", widgets);
88
89 QJsonObject colorsObj;
90 auto insertColor = [&](QPalette::ColorRole role, QString colorName)
91 {
92 colorsObj.insert(colorName, palette.color(role).name());
93 };
94
95 // palette
96 insertColor(QPalette::Window, "Window");
97 insertColor(QPalette::WindowText, "WindowText");
98 insertColor(QPalette::Base, "Base");
99 insertColor(QPalette::AlternateBase, "AlternateBase");
100 insertColor(QPalette::ToolTipBase, "ToolTipBase");
101 insertColor(QPalette::ToolTipText, "ToolTipText");
102 insertColor(QPalette::Text, "Text");
103 insertColor(QPalette::Button, "Button");
104 insertColor(QPalette::ButtonText, "ButtonText");
105 insertColor(QPalette::BrightText, "BrightText");
106 insertColor(QPalette::Link, "Link");
107 insertColor(QPalette::Highlight, "Highlight");
108 insertColor(QPalette::HighlightedText, "HighlightedText");
109
110 // fade
111 colorsObj.insert("fadeColor", fadeColor.name());
112 colorsObj.insert("fadeAmount", fadeAmount);
113
114 rootObj.insert("colors", colorsObj);
115 try
116 {
117 Json::write(rootObj, path);
118 return true;
119 }
120 catch (const Exception &e)
121 {
122 qWarning() << "Failed to write theme json to" << path;
123 return false;
124 }
125}
126
127CustomTheme::CustomTheme(ITheme* baseTheme, QString folder)
128{

Callers 1

CustomThemeMethod · 0.85

Calls 3

insertMethod · 0.80
writeFunction · 0.50
nameMethod · 0.45

Tested by

no test coverage detected