Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit a83fc922 authored by Laurent Montel's avatar Laurent Montel 😁

Allow to reload settings

parent 9400070e
......@@ -29,6 +29,9 @@
#include <QScrollArea>
#include <QFormLayout>
#include <QVariant>
#include <QStackedWidget>
#include <QLabel>
#include <QToolButton>
#include <KUrlRequester>
GrammalecteConfigWidget::GrammalecteConfigWidget(QWidget *parent, bool disableMessageBox)
......@@ -65,6 +68,7 @@ void GrammalecteConfigWidget::loadGrammarSettings()
void GrammalecteConfigWidget::slotGetSettingsError()
{
mStackedWidget->setCurrentWidget(mReloadSettingsWidget);
if (!mDisableDialogBox) {
KMessageBox::error(this, i18n("Impossible to get options. Please verify that you have grammalected installed."), i18n("Error during Extracting Options"));
}
......@@ -72,6 +76,7 @@ void GrammalecteConfigWidget::slotGetSettingsError()
void GrammalecteConfigWidget::slotGetSettingsFinished(const QVector<GrammalecteGenerateConfigOptionJob::Option> &result)
{
mStackedWidget->setCurrentWidget(mScrollArea);
mListOptions.clear();
mListOptions.reserve(result.count());
delete mGrammarTabWidget->layout();
......@@ -93,14 +98,38 @@ void GrammalecteConfigWidget::slotGetSettingsFinished(const QVector<GrammalecteG
QWidget *GrammalecteConfigWidget::addGrammarTab()
{
QScrollArea *area = new QScrollArea(this);
area->setWidgetResizable(true);
mStackedWidget = new QStackedWidget(this);
mStackedWidget->setObjectName(QStringLiteral("stackedwidget"));
mScrollArea = new QScrollArea(this);
mScrollArea->setObjectName(QStringLiteral("scrollarea"));
mScrollArea->setWidgetResizable(true);
mGrammarTabWidget = new QWidget;
mGrammarTabWidget->setObjectName(QStringLiteral("grammar"));
QVBoxLayout *layout = new QVBoxLayout(mGrammarTabWidget);
layout->setObjectName(QStringLiteral("grammartablayout"));
area->setWidget(mGrammarTabWidget);
return area;
mScrollArea->setWidget(mGrammarTabWidget);
mStackedWidget->addWidget(mScrollArea);
mReloadSettingsWidget = new QWidget;
mReloadSettingsWidget->setObjectName(QStringLiteral("reloadwidget"));
mStackedWidget->addWidget(mReloadSettingsWidget);
QVBoxLayout *reloadSettingsLayout = new QVBoxLayout(mReloadSettingsWidget);
reloadSettingsLayout->setObjectName(QStringLiteral("reloadSettingsLayout"));
QHBoxLayout *horizontallayout = new QHBoxLayout;
reloadSettingsLayout->addLayout(horizontallayout);
QLabel *label = new QLabel(i18n("Reload Settings"), this);
label->setObjectName(QStringLiteral("label"));
horizontallayout->addWidget(label);
QToolButton *buttonReloadSettings = new QToolButton(this);
buttonReloadSettings->setObjectName(QStringLiteral("buttonReloadSettings"));
horizontallayout->addWidget(buttonReloadSettings);
connect(buttonReloadSettings, &QToolButton::clicked, this, &GrammalecteConfigWidget::loadGrammarSettings);
reloadSettingsLayout->addStretch(1);
return mStackedWidget;
}
QWidget *GrammalecteConfigWidget::addGeneralTab()
......
......@@ -25,6 +25,8 @@
#include "grammalectegenerateconfigoptionjob.h"
class QCheckBox;
class KUrlRequester;
class QStackedWidget;
class QScrollArea;
class LIBKMAILGRAMMALECTE_EXPORT GrammalecteConfigWidget : public QWidget
{
Q_OBJECT
......@@ -43,7 +45,10 @@ private:
QList<QCheckBox *> mListOptions;
QWidget *addGeneralTab();
QWidget *addGrammarTab();
QStackedWidget *mStackedWidget = nullptr;
QWidget *mGrammarTabWidget = nullptr;
QWidget *mReloadSettingsWidget = nullptr;
QScrollArea *mScrollArea = nullptr;
KUrlRequester *mPythonPath = nullptr;
KUrlRequester *mGrammalectePath = nullptr;
bool mDisableDialogBox = false;
......
......@@ -103,6 +103,7 @@ void GrammalecteGenerateConfigOptionJob::slotFinished(int exitCode, QProcess::Ex
{
if (exitStatus != 0 || exitCode != 0) {
qCWarning(LIBGRAMMALECTE_PLUGIN_LOG) << "GrammalecteGenerateConfigOptionJob ERROR: " << mLastError;
Q_EMIT error();
} else {
Q_EMIT finished(parseResult());
}
......
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