Commit 23906950 authored by jan.koester's avatar jan.koester
Browse files

test

parent ba6c7733
Loading
Loading
Loading
Loading
+30 −0
Changes for client/localapi.cpp: 30 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -220,6 +220,36 @@ void LocalApi::exportHtmlFile() {
    emit statusMessage("Exported HTML: " + path);
}

QString LocalApi::generateAiPrompt(const QString &userRequest) {
    QString prompt =
        "Generate an embeddable HTML snippet (NO <html>, <head>, <body>, or <!DOCTYPE> tags). "
        "The HTML will be embedded inside an existing page that already defines a theme via CSS variables.\n\n"
        "Available CSS variables for colors (use var(...) in your styles, do NOT use hardcoded color values):\n"
        "  --blogi-bg           (page background)\n"
        "  --blogi-surface      (card / panel background)\n"
        "  --blogi-surface-a    (elevated surface)\n"
        "  --blogi-text         (primary text color)\n"
        "  --blogi-text-muted   (secondary / muted text)\n"
        "  --blogi-accent       (accent / link color)\n"
        "  --blogi-accent-dark  (darker accent variant)\n"
        "  --blogi-border       (border color)\n"
        "  --blogi-bg-alt       (alternate background)\n"
        "  --blogi-error        (error / danger color)\n"
        "  --blogi-success-bg   (success background)\n"
        "  --blogi-success-text (success text)\n"
        "  --blogi-nav-active   (active navigation)\n"
        "  --blogi-nav-hover    (navigation hover)\n"
        "  --blogi-nav-border   (navigation border)\n\n"
        "Rules:\n"
        "- Use ONLY these CSS variables for colors, e.g. style=\"color: var(--blogi-text); background: var(--blogi-surface);\"\n"
        "- Do NOT define or override these variables\n"
        "- The snippet must work in both light and dark themes without modification\n"
        "- Use inline styles or a <style> block with scoped class names\n"
        "- Output ONLY the HTML, no explanation\n\n"
        "User request:\n" + userRequest;
    return prompt;
}

void LocalApi::saveDocument() {
    if (_currentFile.isEmpty()) {
        saveAsDocument();
+1 −0
Changes for client/localapi.h: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ public:
    Q_INVOKABLE void openDocument();
    Q_INVOKABLE void importHtmlFile();
    Q_INVOKABLE void exportHtmlFile();
    Q_INVOKABLE QString generateAiPrompt(const QString &userRequest);
    Q_INVOKABLE void saveDocument();
    Q_INVOKABLE void saveAsDocument();
    Q_INVOKABLE void publishToServer();
+93 −0
Changes for client/qml/AiPromptDialog.qml: 93 added lines, 0 removed lines.
Original line number Diff line number Diff line
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

Dialog {
    id: aiPromptDlg
    title: qsTr("Generate AI Prompt")
    parent: Overlay.overlay
    anchors.centerIn: parent
    modal: true
    width: 600
    height: 500
    standardButtons: Dialog.Close

    onOpened: {
        requestInput.text = ""
        promptOutput.text = ""
        requestInput.forceActiveFocus()
    }

    ColumnLayout {
        anchors.fill: parent
        spacing: 8

        Label {
            text: qsTr("Describe what HTML you need:")
            font.pixelSize: 12
            color: Theme.textSecondary
        }

        ScrollView {
            Layout.fillWidth: true
            Layout.preferredHeight: 80

            TextArea {
                id: requestInput
                placeholderText: qsTr("e.g. A pricing table with 3 columns...")
                wrapMode: Text.Wrap
                font.pixelSize: 13
                color: Theme.textPrimary
                background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: 4 }
            }
        }

        Button {
            text: qsTr("Generate Prompt")
            Layout.alignment: Qt.AlignRight
            enabled: requestInput.text.trim().length > 0
            onClicked: {
                promptOutput.text = localApi.generateAiPrompt(requestInput.text.trim())
            }
        }

        Label {
            text: qsTr("Generated prompt (copy and paste into your AI):")
            font.pixelSize: 12
            color: Theme.textSecondary
        }

        ScrollView {
            Layout.fillWidth: true
            Layout.fillHeight: true

            TextArea {
                id: promptOutput
                readOnly: true
                wrapMode: Text.Wrap
                font.pixelSize: 12
                font.family: "monospace"
                color: Theme.textPrimary
                background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: 4 }
                selectByMouse: true
            }
        }

        RowLayout {
            Layout.fillWidth: true
            spacing: 8

            Item { Layout.fillWidth: true }

            Button {
                text: qsTr("Select All & Copy")
                enabled: promptOutput.text.length > 0
                onClicked: {
                    promptOutput.selectAll()
                    promptOutput.copy()
                    root.setStatus(qsTr("Prompt copied to clipboard"))
                }
            }
        }
    }
}
+4 −0
Changes for client/qml/Main.qml: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ ApplicationWindow {
            Action { text: qsTr("&Import HTML..."); onTriggered: localApi.importHtmlFile() }
            Action { text: qsTr("&Export HTML..."); onTriggered: localApi.exportHtmlFile() }
            MenuSeparator {}
            Action { text: qsTr("AI &Prompt..."); onTriggered: aiPromptDlg.open() }
            MenuSeparator {}
            Action { text: qsTr("&Quit"); shortcut: StandardKey.Quit; onTriggered: Qt.quit() }
        }
        Menu {
@@ -153,4 +155,6 @@ ApplicationWindow {
            root.currentFile = path
        }
    }

    AiPromptDialog { id: aiPromptDlg }
}