Commit 03f1ef13 authored by jan.koester's avatar jan.koester
Browse files

test

parent 4e01730b
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -885,6 +885,32 @@ void LocalApi::fetchMedia(const QString &albumId) {
    });
}

void LocalApi::calcMediaDimensions(const QString &mediaId, int width, int height) {
    if (mediaId.isEmpty() || (width <= 0 && height <= 0)) return;

    QJsonArray cmds;
    QJsonObject cmd;
    cmd["command"] = "media_create_preview";
    cmd["media_id"] = mediaId;
    if (width > 0) cmd["width"] = width;
    if (height > 0) cmd["height"] = height;
    cmds.append(cmd);

    _pub->apiRequest(cmds, [this, mediaId](bool ok, const QJsonArray &resp) {
        if (!ok) return;
        for (int i = 0; i < resp.size(); ++i) {
            QJsonObject obj = resp.at(i).toObject();
            if (obj.value("status").toString() == "success") {
                int w = obj.value("width").toInt();
                int h = obj.value("height").toInt();
                if (w > 0 && h > 0)
                    emit mediaDimensionsReady(mediaId, w, h);
                return;
            }
        }
    });
}

void LocalApi::fetchPublishTargets() {
    QJsonArray cmds;
    QJsonObject cmd;