Loading client/documentmanager.cpp +12 −3 Changes for client/documentmanager.cpp: 12 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -656,9 +656,18 @@ QString DocumentManager::getElementProperties(const QString &uuid) { json_object_new_string(el->getInstanceId().c_str())); /* Merge properties from inner_resp */ json_object *props = nullptr; if (json_object_object_get_ex(inner_resp, "properties", &props)) { json_object_object_add(resp, "properties", json_object_get(props)); json_object *data_obj = nullptr; if (json_object_object_get_ex(inner_resp, "data", &data_obj)) { json_object *props_str = nullptr; if (json_object_object_get_ex(data_obj, "properties", &props_str)) { const char *ps = json_object_get_string(props_str); if (ps) { json_object *parsed = json_tokener_parse(ps); if (parsed) { json_object_object_add(resp, "properties", parsed); } } } } json_object *schema = nullptr; if (json_object_object_get_ex(schema_resp, "schema", &schema)) { Loading client/widgets/image/image.cpp +51 −2 Changes for client/widgets/image/image.cpp: 51 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -454,9 +454,58 @@ extern "C" { img.setAttribute("alt", alt.c_str()); img.setAttribute("class", responsiveClass.c_str()); // Compute effective width/height, auto-calculating from aspect ratio std::string effWidth = width; std::string effHeight = height; if (realWidth > 0 && realHeight > 0) { // If width is a pixel value and height is auto, compute height if (effHeight == "auto" && !effWidth.empty() && effWidth != "auto") { try { // Check if width is a plain number or ends with "px" std::string wVal = effWidth; bool isPx = false; if (wVal.size() > 2 && wVal.substr(wVal.size()-2) == "px") { wVal = wVal.substr(0, wVal.size()-2); isPx = true; } double w = std::stod(wVal); if (isPx || (w > 0 && wVal.find('%') == std::string::npos && wVal.find("em") == std::string::npos && wVal.find("vw") == std::string::npos && wVal.find("vh") == std::string::npos)) { double h = w * realHeight / realWidth; effHeight = std::to_string(static_cast<int>(h + 0.5)) + "px"; if (!isPx && effWidth.find("px") == std::string::npos) effWidth += "px"; } } catch (...) {} } // If height is a pixel value and width is auto, compute width else if (effWidth == "auto" && !effHeight.empty() && effHeight != "auto") { try { std::string hVal = effHeight; bool isPx = false; if (hVal.size() > 2 && hVal.substr(hVal.size()-2) == "px") { hVal = hVal.substr(0, hVal.size()-2); isPx = true; } double h = std::stod(hVal); if (isPx || (h > 0 && hVal.find('%') == std::string::npos && hVal.find("em") == std::string::npos && hVal.find("vw") == std::string::npos && hVal.find("vh") == std::string::npos)) { double w = h * realWidth / realHeight; effWidth = std::to_string(static_cast<int>(w + 0.5)) + "px"; if (!isPx && effHeight.find("px") == std::string::npos) effHeight += "px"; } } catch (...) {} } } std::string style; style += "width: " + width + ";"; style += " height: " + height + ";"; style += "width: " + effWidth + ";"; style += " height: " + effHeight + ";"; style += " object-fit: " + objectFit + ";"; if (borderRadius != "0") { style += " border-radius: " + borderRadius + ";"; Loading Loading
client/documentmanager.cpp +12 −3 Changes for client/documentmanager.cpp: 12 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -656,9 +656,18 @@ QString DocumentManager::getElementProperties(const QString &uuid) { json_object_new_string(el->getInstanceId().c_str())); /* Merge properties from inner_resp */ json_object *props = nullptr; if (json_object_object_get_ex(inner_resp, "properties", &props)) { json_object_object_add(resp, "properties", json_object_get(props)); json_object *data_obj = nullptr; if (json_object_object_get_ex(inner_resp, "data", &data_obj)) { json_object *props_str = nullptr; if (json_object_object_get_ex(data_obj, "properties", &props_str)) { const char *ps = json_object_get_string(props_str); if (ps) { json_object *parsed = json_tokener_parse(ps); if (parsed) { json_object_object_add(resp, "properties", parsed); } } } } json_object *schema = nullptr; if (json_object_object_get_ex(schema_resp, "schema", &schema)) { Loading
client/widgets/image/image.cpp +51 −2 Changes for client/widgets/image/image.cpp: 51 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -454,9 +454,58 @@ extern "C" { img.setAttribute("alt", alt.c_str()); img.setAttribute("class", responsiveClass.c_str()); // Compute effective width/height, auto-calculating from aspect ratio std::string effWidth = width; std::string effHeight = height; if (realWidth > 0 && realHeight > 0) { // If width is a pixel value and height is auto, compute height if (effHeight == "auto" && !effWidth.empty() && effWidth != "auto") { try { // Check if width is a plain number or ends with "px" std::string wVal = effWidth; bool isPx = false; if (wVal.size() > 2 && wVal.substr(wVal.size()-2) == "px") { wVal = wVal.substr(0, wVal.size()-2); isPx = true; } double w = std::stod(wVal); if (isPx || (w > 0 && wVal.find('%') == std::string::npos && wVal.find("em") == std::string::npos && wVal.find("vw") == std::string::npos && wVal.find("vh") == std::string::npos)) { double h = w * realHeight / realWidth; effHeight = std::to_string(static_cast<int>(h + 0.5)) + "px"; if (!isPx && effWidth.find("px") == std::string::npos) effWidth += "px"; } } catch (...) {} } // If height is a pixel value and width is auto, compute width else if (effWidth == "auto" && !effHeight.empty() && effHeight != "auto") { try { std::string hVal = effHeight; bool isPx = false; if (hVal.size() > 2 && hVal.substr(hVal.size()-2) == "px") { hVal = hVal.substr(0, hVal.size()-2); isPx = true; } double h = std::stod(hVal); if (isPx || (h > 0 && hVal.find('%') == std::string::npos && hVal.find("em") == std::string::npos && hVal.find("vw") == std::string::npos && hVal.find("vh") == std::string::npos)) { double w = h * realWidth / realHeight; effWidth = std::to_string(static_cast<int>(w + 0.5)) + "px"; if (!isPx && effHeight.find("px") == std::string::npos) effHeight += "px"; } } catch (...) {} } } std::string style; style += "width: " + width + ";"; style += " height: " + height + ";"; style += "width: " + effWidth + ";"; style += " height: " + effHeight + ";"; style += " object-fit: " + objectFit + ";"; if (borderRadius != "0") { style += " border-radius: " + borderRadius + ";"; Loading