KTextAddons

textautogenerateheaderwidget.cpp
1/*
2 SPDX-FileCopyrightText: 2025 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "textautogenerateheaderwidget.h"
8#include "widgets/textautogenerateconfiguredialog.h"
9#include <KLocalizedString>
10#include <QHBoxLayout>
11#include <QLabel>
12#include <QToolButton>
13using namespace Qt::Literals::StringLiterals;
14using namespace TextAutogenerateText;
15TextAutogenerateHeaderWidget::TextAutogenerateHeaderWidget(QWidget *parent)
16 : QWidget{parent}
17 , mEngineName(new QLabel(this))
18 , mConfigureEngine(new QToolButton(this))
19 , mClearChat(new QToolButton(this))
20{
21 auto mainLayout = new QHBoxLayout(this);
22 mainLayout->setObjectName("mainLayout"_L1);
23 mainLayout->setContentsMargins({});
24
25 mEngineName->setObjectName("mEngineName"_L1);
26 mainLayout->addWidget(mEngineName);
27 QFont f = mEngineName->font();
28 f.setBold(true);
29 f.setItalic(true);
30 mEngineName->setFont(f);
31
32 mConfigureEngine->setObjectName("mConfigureEngine"_L1);
33 mConfigureEngine->setToolTip(i18nc("@info:tooltip", "Configure…"));
34 mConfigureEngine->setAutoRaise(true);
35 mConfigureEngine->setIcon(QIcon::fromTheme(QStringLiteral("settings-configure")));
36 mainLayout->addWidget(mConfigureEngine);
37 mainLayout->addStretch(1);
38 connect(mConfigureEngine, &QToolButton::clicked, this, &TextAutogenerateHeaderWidget::slotConfigureEngine);
39
40 mClearChat->setObjectName("mClearChat"_L1);
41 mClearChat->setToolTip(i18nc("@info:tooltip", "Clear"));
42 mClearChat->setAutoRaise(true);
43 mClearChat->setIcon(QIcon::fromTheme(QStringLiteral("edit-clear-all")));
44 mainLayout->addWidget(mClearChat);
45 connect(mClearChat, &QToolButton::clicked, this, &TextAutogenerateHeaderWidget::clearModel);
46}
47
48TextAutogenerateHeaderWidget::~TextAutogenerateHeaderWidget() = default;
49
50void TextAutogenerateHeaderWidget::updateEngineName(const QString &engineName)
51{
52 mEngineName->setText(engineName);
53}
54
55void TextAutogenerateHeaderWidget::slotConfigureEngine()
56{
57 TextAutogenerateText::TextAutogenerateConfigureDialog d(this);
58 if (d.exec()) {
59 d.saveSettings();
60 Q_EMIT configChanged();
61 }
62}
63
64#include "moc_textautogenerateheaderwidget.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void clicked(bool checked)
void setBold(bool enable)
void setItalic(bool enable)
QIcon fromTheme(const QString &name)
Q_EMITQ_EMIT
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Apr 18 2025 12:00:52 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.