KTextAddons

ollamacomboboxwidget.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 "ollamacomboboxwidget.h"
8#include <KLocalizedString>
9#include <QComboBox>
10#include <QHBoxLayout>
11#include <QToolButton>
12
13OllamaComboBoxWidget::OllamaComboBoxWidget(QWidget *parent)
14 : QWidget{parent}
15 , mModelComboBox(new QComboBox(this))
16{
17 auto mainLayout = new QHBoxLayout(this);
18 mainLayout->setObjectName(QStringLiteral("mainLayout"));
19 mainLayout->setContentsMargins({});
20
21 mModelComboBox->setObjectName(QStringLiteral("mModelComboBox"));
22 mainLayout->addWidget(mModelComboBox);
23
24 auto buttonReloadSettings = new QToolButton(this);
25 buttonReloadSettings->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
26 buttonReloadSettings->setObjectName(QStringLiteral("buttonReloadSettings"));
27 buttonReloadSettings->setToolTip(i18nc("@info:tooltip", "Reload Model"));
28 mainLayout->addWidget(buttonReloadSettings);
29 connect(buttonReloadSettings, &QToolButton::clicked, this, &OllamaComboBoxWidget::reloadModel);
30}
31
32OllamaComboBoxWidget::~OllamaComboBoxWidget() = default;
33
34void OllamaComboBoxWidget::setModels(const QStringList &lst)
35{
36 mModelComboBox->clear();
37 mModelComboBox->addItems(lst);
38 mModelComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
39}
40
41void OllamaComboBoxWidget::setCurrentModel(const QString &str)
42{
43 const int index = mModelComboBox->findText(str);
44 if (index >= 0) {
45 mModelComboBox->setCurrentIndex(index);
46 }
47}
48
49QString OllamaComboBoxWidget::currentModel() const
50{
51 return mModelComboBox->currentText();
52}
53
54#include "moc_ollamacomboboxwidget.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void clicked(bool checked)
QIcon fromTheme(const QString &name)
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.