[libraries/ktextaddons] textautogeneratetext/widgets/promptswidget: improve textautogeneratepromptwidget

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 51c6c0509f3a0a75f703d3046d6a76eb34563fd9 by Laurent Montel.
Committed on 28/07/2026 at 19:49.
Pushed by mlaurent into branch 'master'.

improve textautogeneratepromptwidget

M  +7    -3    textautogeneratetext/widgets/promptswidget/autotests/textautogeneratepromptwidgettest.cpp
M  +10   -5    textautogeneratetext/widgets/promptswidget/textautogeneratepromptwidget.cpp
M  +2    -1    textautogeneratetext/widgets/promptswidget/textautogeneratepromptwidget.h

https://invent.kde.org/libraries/ktextaddons/-/commit/51c6c0509f3a0a75f703d3046d6a76eb34563fd9

diff --git a/textautogeneratetext/widgets/promptswidget/autotests/textautogeneratepromptwidgettest.cpp b/textautogeneratetext/widgets/promptswidget/autotests/textautogeneratepromptwidgettest.cpp
index ee1cb3600..06d1ac96b 100644
--- a/textautogeneratetext/widgets/promptswidget/autotests/textautogeneratepromptwidgettest.cpp
+++ b/textautogeneratetext/widgets/promptswidget/autotests/textautogeneratepromptwidgettest.cpp
@@ -28,9 +28,13 @@ void TextAutoGeneratePromptWidgetTest::shouldHaveDefaultValues()
     QVERIFY(mName);
     QVERIFY(mName->text().isEmpty());
 
-    auto mText = w.findChild<QPlainTextEdit *>(u"mText"_s);
-    QVERIFY(mText);
-    QVERIFY(mText->toPlainText().isEmpty());
+    auto mDescription = w.findChild<QPlainTextEdit *>(u"mDescription"_s);
+    QVERIFY(mDescription);
+    QVERIFY(mDescription->toPlainText().isEmpty());
+
+    auto mPrompt = w.findChild<QPlainTextEdit *>(u"mPrompt"_s);
+    QVERIFY(mPrompt);
+    QVERIFY(mPrompt->toPlainText().isEmpty());
 }
 
 #include "moc_textautogeneratepromptwidgettest.cpp"
diff --git a/textautogeneratetext/widgets/promptswidget/textautogeneratepromptwidget.cpp b/textautogeneratetext/widgets/promptswidget/textautogeneratepromptwidget.cpp
index 88c0d4f31..fbf8d006d 100644
--- a/textautogeneratetext/widgets/promptswidget/textautogeneratepromptwidget.cpp
+++ b/textautogeneratetext/widgets/promptswidget/textautogeneratepromptwidget.cpp
@@ -16,7 +16,8 @@ using namespace TextAutoGenerateText;
 TextAutoGeneratePromptWidget::TextAutoGeneratePromptWidget(QWidget *parent)
     : QWidget{parent}
     , mName(new QLineEdit(this))
-    , mText(new QPlainTextEdit(this))
+    , mDescription(new QPlainTextEdit(this))
+    , mPrompt(new QPlainTextEdit(this))
 {
     auto mainLayout = new QFormLayout(this);
     mainLayout->setObjectName(u"mainLayout"_s);
@@ -24,10 +25,12 @@ TextAutoGeneratePromptWidget::TextAutoGeneratePromptWidget(QWidget *parent)
 
     mName->setObjectName(u"mName"_s);
     KLineEditEventHandler::catchReturnKey(mName);
-    mText->setObjectName(u"mText"_s);
+    mDescription->setObjectName(u"mDescription"_s);
+    mPrompt->setObjectName(u"mPrompt"_s);
 
     mainLayout->addRow(i18n("Name:"), mName);
-    mainLayout->addRow(i18n("Description:"), mText);
+    mainLayout->addRow(i18n("Description:"), mDescription);
+    mainLayout->addRow(i18n("Prompt:"), mPrompt);
 }
 
 TextAutoGeneratePromptWidget::~TextAutoGeneratePromptWidget() = default;
@@ -35,13 +38,15 @@ TextAutoGeneratePromptWidget::~TextAutoGeneratePromptWidget() = default;
 void TextAutoGeneratePromptWidget::setPrompt(const TextAutoGenerateText::TextAutoGeneratePrompt &prompt)
 {
     mName->setText(prompt.name());
-    mText->setPlainText(prompt.text());
+    mDescription->setPlainText(prompt.description());
+    mPrompt->setPlainText(prompt.text());
 }
 
 TextAutoGenerateText::TextAutoGeneratePrompt TextAutoGeneratePromptWidget::prompt() const
 {
     TextAutoGenerateText::TextAutoGeneratePrompt prompt;
-    prompt.setText(mText->toPlainText());
+    prompt.setDescription(mDescription->toPlainText());
+    prompt.setText(mPrompt->toPlainText());
     prompt.setName(mName->text());
     return prompt;
 }
diff --git a/textautogeneratetext/widgets/promptswidget/textautogeneratepromptwidget.h b/textautogeneratetext/widgets/promptswidget/textautogeneratepromptwidget.h
index 46cf4468f..fb6c7f71a 100644
--- a/textautogeneratetext/widgets/promptswidget/textautogeneratepromptwidget.h
+++ b/textautogeneratetext/widgets/promptswidget/textautogeneratepromptwidget.h
@@ -24,6 +24,7 @@ public:
 
 private:
     QLineEdit *const mName;
-    QPlainTextEdit *const mText;
+    QPlainTextEdit *const mDescription;
+    QPlainTextEdit *const mPrompt;
 };
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.