Loading client/CMakeLists.txt +1 −0 Changes for client/CMakeLists.txt: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ qt_add_qml_module(blogi-editor qml/ConnectionPanel.qml qml/MediaBrowser.qml qml/PublishDialog.qml qml/publishhelper.js qml/AiPromptDialog.qml ) Loading client/localapi.cpp +32 −0 Changes for client/localapi.cpp: 32 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -482,12 +482,42 @@ void LocalApi::fetchSurveyList() { }); } QString LocalApi::collectRepeaterParams(QObject *repeater) { if (!repeater) return "{}"; QJsonObject params; int count = repeater->property("count").toInt(); for (int i = 0; i < count; ++i) { QObject *delegate = nullptr; QMetaObject::invokeMethod(repeater, "itemAt", Q_RETURN_ARG(QObject*, delegate), Q_ARG(int, i)); if (!delegate) continue; QString key = delegate->property("fieldKey").toString(); if (key.isEmpty()) continue; QVariant val = delegate->property("fieldValue"); if (val.typeId() == QMetaType::Bool) params[key] = val.toBool(); else params[key] = val.toString(); } return QString::fromUtf8(QJsonDocument(params).toJson(QJsonDocument::Compact)); } QString LocalApi::jsonSet(const QString &json, const QString &key, const QString &value) { QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8()); QJsonObject obj = doc.isObject() ? doc.object() : QJsonObject(); obj[key] = value; return QString::fromUtf8(QJsonDocument(obj).toJson(QJsonDocument::Compact)); } void LocalApi::publishToTarget(const QString &target, const QString ¶msJson) { if (!_pub->isConfigured()) { emit publishCompleted(false, "Not connected"); return; } qDebug() << "publishToTarget: target=" << target << "paramsJson=" << paramsJson; emit statusMessage("Publishing to " + target + "..."); QJsonArray cmds; Loading @@ -502,6 +532,8 @@ void LocalApi::publishToTarget(const QString &target, const QString ¶msJson) } cmds.append(cmd); qDebug() << "publishToTarget: sending=" << QJsonDocument(cmds).toJson(QJsonDocument::Compact); _pub->apiRequest(cmds, [this, target](bool ok, const QJsonArray &resp) { if (!ok) { emit publishCompleted(false, "Network error"); Loading client/localapi.h +2 −0 Changes for client/localapi.h: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -81,6 +81,8 @@ public: Q_INVOKABLE void fetchPublishTargets(); Q_INVOKABLE void publishToTarget(const QString &target, const QString ¶msJson); Q_INVOKABLE void publishToTargetOverwrite(const QString &target, const QString ¶msJson, const QString &existingId); Q_INVOKABLE QString collectRepeaterParams(QObject *repeater); Q_INVOKABLE QString jsonSet(const QString &json, const QString &key, const QString &value); /* File operations (called from QML menus) */ Q_INVOKABLE void newDocument(); Loading client/qml/ConnectionPanel.qml +29 −50 Changes for client/qml/ConnectionPanel.qml: 29 added lines, 50 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts import QtQuick.Dialogs import "publishhelper.js" as PH ColumnLayout { id: connPanel Loading Loading @@ -370,6 +371,13 @@ ColumnLayout { visible: connected property var fieldDef: modelData property bool isText: fieldDef.type === "text" || fieldDef.type === "textarea" || !fieldDef.type property bool isSelect: fieldDef.type === "select" property bool isCheck: fieldDef.type === "checkbox" property string fieldKey: fieldDef.key property var fieldValue: isSelect ? dynSelect.currentValue : isCheck ? dynCheck.checked : dynText.text Label { text: (fieldDef.label || fieldDef.key) + (fieldDef.required ? " *" : "") Loading @@ -377,46 +385,35 @@ ColumnLayout { } /* text field */ Loader { Layout.fillWidth: true active: fieldDef.type === "text" || fieldDef.type === "textarea" || fieldDef.type === undefined visible: active sourceComponent: TextField { TextField { id: dynText Layout.fillWidth: true visible: isText text: fieldDef.defaultValue || "" placeholderText: fieldDef.placeholder || "" font.pixelSize: 13; color: Theme.textPrimary background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } Component.onCompleted: fieldDef._control = dynText onEditingFinished: requestServerPreview() } } /* select field */ Loader { Layout.fillWidth: true active: fieldDef.type === "select" visible: active sourceComponent: ComboBox { ComboBox { id: dynSelect Layout.fillWidth: true visible: isSelect model: fieldDef.options || [] textRole: "label"; valueRole: "value" font.pixelSize: 13 palette.text: Theme.textPrimary palette.buttonText: Theme.textPrimary background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } Component.onCompleted: fieldDef._control = dynSelect onActivated: requestServerPreview() } } /* checkbox field */ Loader { Layout.fillWidth: true active: fieldDef.type === "checkbox" visible: active sourceComponent: CheckBox { CheckBox { id: dynCheck visible: isCheck checked: fieldDef.defaultValue === true || fieldDef.defaultValue === "true" text: fieldDef.label || fieldDef.key contentItem: Text { Loading @@ -424,12 +421,10 @@ ColumnLayout { leftPadding: parent.indicator.width + 4 verticalAlignment: Text.AlignVCenter } Component.onCompleted: fieldDef._control = dynCheck onToggled: requestServerPreview() } } } } /* Publish status */ Label { Loading Loading @@ -636,63 +631,47 @@ ColumnLayout { } var t = connPanel.publishTargets[connPanel.selectedTargetIndex] var fields = t.fields || [] for (var i = 0; i < fields.length; i++) fields[i]._control = null connPanel.currentPublishFields = fields publishFieldRepeater.model = fields publishStatusLabel.text = "" } function collectPublishParams() { var params = {} for (var i = 0; i < connPanel.currentPublishFields.length; i++) { var f = connPanel.currentPublishFields[i] var ctrl = f._control if (!ctrl) continue if (f.type === "select") params[f.key] = ctrl.currentValue || "" else if (f.type === "checkbox") params[f.key] = ctrl.checked else params[f.key] = ctrl.text || "" } return params return localApi.collectRepeaterParams(publishFieldRepeater) } function requestServerPreview() { if (!connected || connPanel.selectedTargetIndex < 0) return var t = connPanel.publishTargets[connPanel.selectedTargetIndex] var params = collectPublishParams() // Add color settings var paramsJson = collectPublishParams() // Add color settings via C++ helper if (connPanel.colorMode === "theme") { params["_color_mode"] = "theme" params["_color_scheme"] = themeSchemeCombo.currentText paramsJson = localApi.jsonSet(paramsJson, "_color_mode", "theme") paramsJson = localApi.jsonSet(paramsJson, "_color_scheme", themeSchemeCombo.currentText) } else if (connPanel.colorMode === "custom") { params["_color_mode"] = "custom" params["_color_custom"] = connPanel.customColor.toString() paramsJson = localApi.jsonSet(paramsJson, "_color_mode", "custom") paramsJson = localApi.jsonSet(paramsJson, "_color_custom", connPanel.customColor.toString()) } localApi.renderPreviewOnServer(connPanel.mobileMode, t.name, JSON.stringify(params)) localApi.renderPreviewOnServer(connPanel.mobileMode, t.name, paramsJson) } function doPublish(overwrite, existingId) { if (connPanel.selectedTargetIndex < 0) return var t = connPanel.publishTargets[connPanel.selectedTargetIndex] var params = collectPublishParams() var paramsJson = collectPublishParams() /* Validate required */ for (var i = 0; i < connPanel.currentPublishFields.length; i++) { var f = connPanel.currentPublishFields[i] if (f.required && (!params[f.key] || params[f.key].length === 0)) { publishStatusLabel.text = (f.label || f.key) + " is required" var err = PH.validateRequired(connPanel.currentPublishFields, paramsJson) if (err !== "") { publishStatusLabel.text = err publishStatusLabel.color = Theme.warning return } } publishStatusLabel.text = "Publishing..." publishStatusLabel.color = Theme.textMuted lastPublishTarget = t.name lastPublishParamsJson = JSON.stringify(params) lastPublishParamsJson = paramsJson if (overwrite) localApi.publishToTargetOverwrite(t.name, lastPublishParamsJson, existingId) Loading client/qml/PublishDialog.qml +14 −34 Changes for client/qml/PublishDialog.qml: 14 added lines, 34 removed lines. Original line number Diff line number Diff line import QtQuick import QtQuick.Controls import QtQuick.Layouts import "publishhelper.js" as PH Dialog { id: publishDlg Loading Loading @@ -84,7 +85,10 @@ Dialog { property bool isText: fieldDef.type === "text" || fieldDef.type === "textarea" || !fieldDef.type property bool isSelect: fieldDef.type === "select" property bool isCheck: fieldDef.type === "checkbox" property var fieldControl: isSelect ? selInput : isCheck ? chkInput : txtInput property string fieldKey: fieldDef.key property var fieldValue: isSelect ? selCtl.currentValue : isCheck ? chkCtl.checked : txtCtl.text Label { text: (fieldDef.label || fieldDef.key) + (fieldDef.required ? " *" : "") Loading @@ -94,7 +98,7 @@ Dialog { /* text field */ TextField { id: txtInput id: txtCtl Layout.fillWidth: true visible: isText text: fieldDef.defaultValue || "" Loading @@ -105,7 +109,7 @@ Dialog { /* select field */ ComboBox { id: selInput id: selCtl Layout.fillWidth: true visible: isSelect model: fieldDef.options || [] Loading @@ -119,7 +123,7 @@ Dialog { /* checkbox field */ CheckBox { id: chkInput id: chkCtl visible: isCheck checked: fieldDef.defaultValue === true || fieldDef.defaultValue === "true" text: fieldDef.label || fieldDef.key Loading Loading @@ -182,47 +186,23 @@ Dialog { publishStatus.text = "" } function collectParams() { var params = {} for (var i = 0; i < fieldRepeater.count; i++) { var delegate = fieldRepeater.itemAt(i) if (!delegate) continue var f = delegate.fieldDef var ctrl = delegate.fieldControl if (!ctrl) continue if (f.type === "select") { params[f.key] = ctrl.currentValue || "" } else if (f.type === "checkbox") { params[f.key] = ctrl.checked } else { params[f.key] = ctrl.text || "" } } return params } function doPublish(overwrite, existingId) { if (publishDlg.selectedTargetIndex < 0) return var t = publishDlg.targets[publishDlg.selectedTargetIndex] var params = collectParams() /* Validate required fields */ for (var i = 0; i < fieldRepeater.count; i++) { var delegate = fieldRepeater.itemAt(i) if (!delegate) continue var f = delegate.fieldDef if (f.required && (!params[f.key] || params[f.key].length === 0)) { publishStatus.text = (f.label || f.key) + " is required" lastParamsJson = localApi.collectRepeaterParams(fieldRepeater) var err = PH.validateRequired(publishDlg.currentFields, lastParamsJson) if (err !== "") { publishStatus.text = err publishStatus.color = Theme.warning return } } publishStatus.text = "Publishing..." publishStatus.color = Theme.textMuted lastTarget = t.name lastParamsJson = JSON.stringify(params) if (overwrite) { localApi.publishToTargetOverwrite(t.name, lastParamsJson, existingId) Loading Loading
client/CMakeLists.txt +1 −0 Changes for client/CMakeLists.txt: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ qt_add_qml_module(blogi-editor qml/ConnectionPanel.qml qml/MediaBrowser.qml qml/PublishDialog.qml qml/publishhelper.js qml/AiPromptDialog.qml ) Loading
client/localapi.cpp +32 −0 Changes for client/localapi.cpp: 32 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -482,12 +482,42 @@ void LocalApi::fetchSurveyList() { }); } QString LocalApi::collectRepeaterParams(QObject *repeater) { if (!repeater) return "{}"; QJsonObject params; int count = repeater->property("count").toInt(); for (int i = 0; i < count; ++i) { QObject *delegate = nullptr; QMetaObject::invokeMethod(repeater, "itemAt", Q_RETURN_ARG(QObject*, delegate), Q_ARG(int, i)); if (!delegate) continue; QString key = delegate->property("fieldKey").toString(); if (key.isEmpty()) continue; QVariant val = delegate->property("fieldValue"); if (val.typeId() == QMetaType::Bool) params[key] = val.toBool(); else params[key] = val.toString(); } return QString::fromUtf8(QJsonDocument(params).toJson(QJsonDocument::Compact)); } QString LocalApi::jsonSet(const QString &json, const QString &key, const QString &value) { QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8()); QJsonObject obj = doc.isObject() ? doc.object() : QJsonObject(); obj[key] = value; return QString::fromUtf8(QJsonDocument(obj).toJson(QJsonDocument::Compact)); } void LocalApi::publishToTarget(const QString &target, const QString ¶msJson) { if (!_pub->isConfigured()) { emit publishCompleted(false, "Not connected"); return; } qDebug() << "publishToTarget: target=" << target << "paramsJson=" << paramsJson; emit statusMessage("Publishing to " + target + "..."); QJsonArray cmds; Loading @@ -502,6 +532,8 @@ void LocalApi::publishToTarget(const QString &target, const QString ¶msJson) } cmds.append(cmd); qDebug() << "publishToTarget: sending=" << QJsonDocument(cmds).toJson(QJsonDocument::Compact); _pub->apiRequest(cmds, [this, target](bool ok, const QJsonArray &resp) { if (!ok) { emit publishCompleted(false, "Network error"); Loading
client/localapi.h +2 −0 Changes for client/localapi.h: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -81,6 +81,8 @@ public: Q_INVOKABLE void fetchPublishTargets(); Q_INVOKABLE void publishToTarget(const QString &target, const QString ¶msJson); Q_INVOKABLE void publishToTargetOverwrite(const QString &target, const QString ¶msJson, const QString &existingId); Q_INVOKABLE QString collectRepeaterParams(QObject *repeater); Q_INVOKABLE QString jsonSet(const QString &json, const QString &key, const QString &value); /* File operations (called from QML menus) */ Q_INVOKABLE void newDocument(); Loading
client/qml/ConnectionPanel.qml +29 −50 Changes for client/qml/ConnectionPanel.qml: 29 added lines, 50 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts import QtQuick.Dialogs import "publishhelper.js" as PH ColumnLayout { id: connPanel Loading Loading @@ -370,6 +371,13 @@ ColumnLayout { visible: connected property var fieldDef: modelData property bool isText: fieldDef.type === "text" || fieldDef.type === "textarea" || !fieldDef.type property bool isSelect: fieldDef.type === "select" property bool isCheck: fieldDef.type === "checkbox" property string fieldKey: fieldDef.key property var fieldValue: isSelect ? dynSelect.currentValue : isCheck ? dynCheck.checked : dynText.text Label { text: (fieldDef.label || fieldDef.key) + (fieldDef.required ? " *" : "") Loading @@ -377,46 +385,35 @@ ColumnLayout { } /* text field */ Loader { Layout.fillWidth: true active: fieldDef.type === "text" || fieldDef.type === "textarea" || fieldDef.type === undefined visible: active sourceComponent: TextField { TextField { id: dynText Layout.fillWidth: true visible: isText text: fieldDef.defaultValue || "" placeholderText: fieldDef.placeholder || "" font.pixelSize: 13; color: Theme.textPrimary background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } Component.onCompleted: fieldDef._control = dynText onEditingFinished: requestServerPreview() } } /* select field */ Loader { Layout.fillWidth: true active: fieldDef.type === "select" visible: active sourceComponent: ComboBox { ComboBox { id: dynSelect Layout.fillWidth: true visible: isSelect model: fieldDef.options || [] textRole: "label"; valueRole: "value" font.pixelSize: 13 palette.text: Theme.textPrimary palette.buttonText: Theme.textPrimary background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } Component.onCompleted: fieldDef._control = dynSelect onActivated: requestServerPreview() } } /* checkbox field */ Loader { Layout.fillWidth: true active: fieldDef.type === "checkbox" visible: active sourceComponent: CheckBox { CheckBox { id: dynCheck visible: isCheck checked: fieldDef.defaultValue === true || fieldDef.defaultValue === "true" text: fieldDef.label || fieldDef.key contentItem: Text { Loading @@ -424,12 +421,10 @@ ColumnLayout { leftPadding: parent.indicator.width + 4 verticalAlignment: Text.AlignVCenter } Component.onCompleted: fieldDef._control = dynCheck onToggled: requestServerPreview() } } } } /* Publish status */ Label { Loading Loading @@ -636,63 +631,47 @@ ColumnLayout { } var t = connPanel.publishTargets[connPanel.selectedTargetIndex] var fields = t.fields || [] for (var i = 0; i < fields.length; i++) fields[i]._control = null connPanel.currentPublishFields = fields publishFieldRepeater.model = fields publishStatusLabel.text = "" } function collectPublishParams() { var params = {} for (var i = 0; i < connPanel.currentPublishFields.length; i++) { var f = connPanel.currentPublishFields[i] var ctrl = f._control if (!ctrl) continue if (f.type === "select") params[f.key] = ctrl.currentValue || "" else if (f.type === "checkbox") params[f.key] = ctrl.checked else params[f.key] = ctrl.text || "" } return params return localApi.collectRepeaterParams(publishFieldRepeater) } function requestServerPreview() { if (!connected || connPanel.selectedTargetIndex < 0) return var t = connPanel.publishTargets[connPanel.selectedTargetIndex] var params = collectPublishParams() // Add color settings var paramsJson = collectPublishParams() // Add color settings via C++ helper if (connPanel.colorMode === "theme") { params["_color_mode"] = "theme" params["_color_scheme"] = themeSchemeCombo.currentText paramsJson = localApi.jsonSet(paramsJson, "_color_mode", "theme") paramsJson = localApi.jsonSet(paramsJson, "_color_scheme", themeSchemeCombo.currentText) } else if (connPanel.colorMode === "custom") { params["_color_mode"] = "custom" params["_color_custom"] = connPanel.customColor.toString() paramsJson = localApi.jsonSet(paramsJson, "_color_mode", "custom") paramsJson = localApi.jsonSet(paramsJson, "_color_custom", connPanel.customColor.toString()) } localApi.renderPreviewOnServer(connPanel.mobileMode, t.name, JSON.stringify(params)) localApi.renderPreviewOnServer(connPanel.mobileMode, t.name, paramsJson) } function doPublish(overwrite, existingId) { if (connPanel.selectedTargetIndex < 0) return var t = connPanel.publishTargets[connPanel.selectedTargetIndex] var params = collectPublishParams() var paramsJson = collectPublishParams() /* Validate required */ for (var i = 0; i < connPanel.currentPublishFields.length; i++) { var f = connPanel.currentPublishFields[i] if (f.required && (!params[f.key] || params[f.key].length === 0)) { publishStatusLabel.text = (f.label || f.key) + " is required" var err = PH.validateRequired(connPanel.currentPublishFields, paramsJson) if (err !== "") { publishStatusLabel.text = err publishStatusLabel.color = Theme.warning return } } publishStatusLabel.text = "Publishing..." publishStatusLabel.color = Theme.textMuted lastPublishTarget = t.name lastPublishParamsJson = JSON.stringify(params) lastPublishParamsJson = paramsJson if (overwrite) localApi.publishToTargetOverwrite(t.name, lastPublishParamsJson, existingId) Loading
client/qml/PublishDialog.qml +14 −34 Changes for client/qml/PublishDialog.qml: 14 added lines, 34 removed lines. Original line number Diff line number Diff line import QtQuick import QtQuick.Controls import QtQuick.Layouts import "publishhelper.js" as PH Dialog { id: publishDlg Loading Loading @@ -84,7 +85,10 @@ Dialog { property bool isText: fieldDef.type === "text" || fieldDef.type === "textarea" || !fieldDef.type property bool isSelect: fieldDef.type === "select" property bool isCheck: fieldDef.type === "checkbox" property var fieldControl: isSelect ? selInput : isCheck ? chkInput : txtInput property string fieldKey: fieldDef.key property var fieldValue: isSelect ? selCtl.currentValue : isCheck ? chkCtl.checked : txtCtl.text Label { text: (fieldDef.label || fieldDef.key) + (fieldDef.required ? " *" : "") Loading @@ -94,7 +98,7 @@ Dialog { /* text field */ TextField { id: txtInput id: txtCtl Layout.fillWidth: true visible: isText text: fieldDef.defaultValue || "" Loading @@ -105,7 +109,7 @@ Dialog { /* select field */ ComboBox { id: selInput id: selCtl Layout.fillWidth: true visible: isSelect model: fieldDef.options || [] Loading @@ -119,7 +123,7 @@ Dialog { /* checkbox field */ CheckBox { id: chkInput id: chkCtl visible: isCheck checked: fieldDef.defaultValue === true || fieldDef.defaultValue === "true" text: fieldDef.label || fieldDef.key Loading Loading @@ -182,47 +186,23 @@ Dialog { publishStatus.text = "" } function collectParams() { var params = {} for (var i = 0; i < fieldRepeater.count; i++) { var delegate = fieldRepeater.itemAt(i) if (!delegate) continue var f = delegate.fieldDef var ctrl = delegate.fieldControl if (!ctrl) continue if (f.type === "select") { params[f.key] = ctrl.currentValue || "" } else if (f.type === "checkbox") { params[f.key] = ctrl.checked } else { params[f.key] = ctrl.text || "" } } return params } function doPublish(overwrite, existingId) { if (publishDlg.selectedTargetIndex < 0) return var t = publishDlg.targets[publishDlg.selectedTargetIndex] var params = collectParams() /* Validate required fields */ for (var i = 0; i < fieldRepeater.count; i++) { var delegate = fieldRepeater.itemAt(i) if (!delegate) continue var f = delegate.fieldDef if (f.required && (!params[f.key] || params[f.key].length === 0)) { publishStatus.text = (f.label || f.key) + " is required" lastParamsJson = localApi.collectRepeaterParams(fieldRepeater) var err = PH.validateRequired(publishDlg.currentFields, lastParamsJson) if (err !== "") { publishStatus.text = err publishStatus.color = Theme.warning return } } publishStatus.text = "Publishing..." publishStatus.color = Theme.textMuted lastTarget = t.name lastParamsJson = JSON.stringify(params) if (overwrite) { localApi.publishToTargetOverwrite(t.name, lastParamsJson, existingId) Loading