7#include "languagetoolconfigwidget.h"
8#include "languagetoolcombobox.h"
9#include "languagetoolmanager.h"
10#include "languagetoolupdatecombobox.h"
11#include <KLineEditEventHandler>
12#include <KLocalizedString>
19using namespace TextGrammarCheck;
20LanguageToolConfigWidget::LanguageToolConfigWidget(
QWidget *parent)
22 , mUseLocalInstance(new
QCheckBox(
i18nc(
"@option:check",
"Use Local Instance"), this))
24 , mInstancePathLabel(new
QLabel(
i18nc(
"@label:textbox",
"Instance Path:"), this))
25 , mLanguageToolCombobox(new LanguageToolComboBox(this))
26 , mLanguageToolUpdateCombobox(new LanguageToolUpdateComboBox(this))
29 mainLayout->setObjectName(QStringLiteral(
"mainlayout"));
30 mainLayout->setContentsMargins({});
32 mUseLocalInstance->setObjectName(QStringLiteral(
"uselocalinstance"));
33 mainLayout->addWidget(mUseLocalInstance);
36 instanceLayout->
setObjectName(QStringLiteral(
"instancelayout"));
37 instanceLayout->setContentsMargins({});
38 mInstancePathLabel->setObjectName(QStringLiteral(
"instancepath"));
39 mInstancePathLabel->setEnabled(
false);
40 instanceLayout->addWidget(mInstancePathLabel);
42 mInstancePath->setObjectName(QStringLiteral(
"instancepath"));
43 mInstancePath->setEnabled(
false);
44 mInstancePath->setClearButtonEnabled(
true);
46 instanceLayout->addWidget(mInstancePath);
47 mainLayout->addLayout(instanceLayout);
52 languageLayout->
setObjectName(QStringLiteral(
"languagelayout"));
53 auto languageLabel =
new QLabel(
i18nc(
"@label:textbox",
"Language:"),
this);
54 languageLabel->setObjectName(QStringLiteral(
"languageLabel"));
55 languageLayout->addWidget(languageLabel);
57 mLanguageToolCombobox->setObjectName(QStringLiteral(
"languagecombobox"));
58 languageLayout->addWidget(mLanguageToolCombobox);
59 mLanguageToolUpdateCombobox->setLanguageToolCombobox(mLanguageToolCombobox);
60 mLanguageToolUpdateCombobox->setParentWidget(
this);
63 refreshButton->setObjectName(QStringLiteral(
"refreshbutton"));
65 refreshButton->setToolTip(
i18nc(
"@info:tooltip",
"Refresh"));
66 if (!LanguageToolManager::self()->allowToGetListOfLanguages()) {
67 refreshButton->setVisible(
false);
69 languageLayout->addWidget(refreshButton);
71 if (LanguageToolManager::self()->allowToGetListOfLanguages()) {
72 mLanguageToolUpdateCombobox->checkListOfLanguagesFromSpecificPath(LanguageToolManager::convertToLanguagePath(mInstancePath->text()));
76 mainLayout->addLayout(languageLayout);
78 mainLayout->addStretch(1);
79 mLanguageToolUpdateCombobox->refreshListOfLanguages();
81 updateWidgets(mUseLocalInstance->isChecked());
82 connect(
this, &LanguageToolConfigWidget::resetValue,
this, &LanguageToolConfigWidget::slotResetValue);
85LanguageToolConfigWidget::~LanguageToolConfigWidget()
90void LanguageToolConfigWidget::slotResetValue()
93 mInstancePath->
setText(QStringLiteral(
"https://api.languagetoolplus.com/v2"));
97void LanguageToolConfigWidget::updateWidgets(
bool enabled)
103void LanguageToolConfigWidget::loadSettings()
105 mUseLocalInstance->
setChecked(LanguageToolManager::self()->useLocalInstance());
106 mInstancePath->
setText(LanguageToolManager::self()->languageToolPath());
107 mLanguageToolCombobox->setLanguage(LanguageToolManager::self()->language());
110void LanguageToolConfigWidget::saveSettings()
112 LanguageToolManager::self()->setUseLocalInstance(mUseLocalInstance->
isChecked());
113 LanguageToolManager::self()->setLanguageToolPath(mInstancePath->
text());
114 LanguageToolManager::self()->setLanguage(mLanguageToolCombobox->language());
115 LanguageToolManager::self()->saveSettings();
118#include "moc_languagetoolconfigwidget.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void catchReturnKey(QObject *lineEdit)
QIcon fromTheme(const QString &name)
void setText(const QString &)
void setObjectName(QAnyStringView name)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)