Commit 0e22ee0d authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add reset button

parent cb233761
Pipeline #67742 passed with stage
in 54 minutes and 24 seconds
......@@ -10,6 +10,7 @@
#include <KLocalizedString>
#include <KSharedConfig>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
namespace
......@@ -27,11 +28,12 @@ LanguageToolConfigDialog::LanguageToolConfigDialog(QWidget *parent)
mConfigWidget->setObjectName(QStringLiteral("configwidget"));
mainLayout->addWidget(mConfigWidget);
auto box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
auto box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Reset, this);
box->setObjectName(QStringLiteral("box"));
mainLayout->addWidget(box);
connect(box, &QDialogButtonBox::accepted, this, &LanguageToolConfigDialog::accept);
connect(box, &QDialogButtonBox::rejected, this, &LanguageToolConfigDialog::reject);
connect(box->button(QDialogButtonBox::Reset), &QPushButton::clicked, mConfigWidget, &LanguageToolConfigWidget::resetValue);
readConfig();
}
......
......@@ -75,6 +75,7 @@ LanguageToolConfigWidget::LanguageToolConfigWidget(QWidget *parent)
mLanguageToolUpdateCombobox->refreshListOfLanguages();
loadSettings();
updateWidgets(mUseLocalInstance->isChecked());
connect(this, &LanguageToolConfigWidget::resetValue, this, &LanguageToolConfigWidget::slotResetValue);
}
LanguageToolConfigWidget::~LanguageToolConfigWidget()
......@@ -82,6 +83,13 @@ LanguageToolConfigWidget::~LanguageToolConfigWidget()
saveSettings();
}
void LanguageToolConfigWidget::slotResetValue()
{
mUseLocalInstance->setChecked(false);
mInstancePath->setText(QStringLiteral("https://api.languagetoolplus.com/v2"));
updateWidgets(false);
}
void LanguageToolConfigWidget::updateWidgets(bool enabled)
{
mInstancePathLabel->setEnabled(enabled);
......
......@@ -22,9 +22,13 @@ public:
void loadSettings();
void saveSettings();
Q_SIGNALS:
void resetValue();
private:
Q_DISABLE_COPY(LanguageToolConfigWidget)
void updateWidgets(bool enabled);
void slotResetValue();
QCheckBox *mUseLocalInstance = nullptr;
QLineEdit *mInstancePath = nullptr;
QLabel *mInstancePathLabel = nullptr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment