Commit 7019de7c authored by Laurent Montel's avatar Laurent Montel 😁

Fix install implement language tool

parent ad51953a
......@@ -18,6 +18,7 @@
*/
#include "languagetoolcomboboxtest.h"
#include "languagetoolcombobox.h"
#include <QTest>
QTEST_MAIN(LanguageToolComboBoxTest)
LanguageToolComboBoxTest::LanguageToolComboBoxTest(QObject *parent)
......@@ -25,3 +26,9 @@ LanguageToolComboBoxTest::LanguageToolComboBoxTest(QObject *parent)
{
}
void LanguageToolComboBoxTest::shouldHaveDefaultValue()
{
LanguageToolComboBox w;
QCOMPARE(w.count(), 0);
}
......@@ -28,6 +28,8 @@ class LanguageToolComboBoxTest : public QObject
public:
explicit LanguageToolComboBoxTest(QObject *parent = nullptr);
~LanguageToolComboBoxTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // LANGUAGETOOLCOMBOBOXTEST_H
......@@ -33,7 +33,7 @@ LanguageToolConfigDialogTest::LanguageToolConfigDialogTest(QObject *parent)
void LanguageToolConfigDialogTest::shouldHaveDefaultValue()
{
LanguageToolConfigDialog w(nullptr, true);
LanguageToolConfigDialog w(nullptr);
QVERIFY(!w.windowTitle().isEmpty());
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
......
......@@ -20,6 +20,8 @@
#include "languagetoolconfigwidgettest.h"
#include "languagetoolconfigwidget.h"
#include <QCheckBox>
#include <QLabel>
#include <QLineEdit>
#include <QTest>
#include <QVBoxLayout>
QTEST_MAIN(LanguageToolConfigWidgetTest)
......@@ -40,4 +42,15 @@ void LanguageToolConfigWidgetTest::shouldHaveDefaultValue()
QCheckBox *mUseLocalInstance = w.findChild<QCheckBox *>(QStringLiteral("uselocalinstance"));
QVERIFY(mUseLocalInstance);
QVERIFY(!mUseLocalInstance->text().isEmpty());
QVERIFY(!mUseLocalInstance->isChecked());
QLabel *instancePathLabel = w.findChild<QLabel *>(QStringLiteral("instancepath"));
QVERIFY(instancePathLabel);
QVERIFY(!instancePathLabel->text().isEmpty());
QVERIFY(!instancePathLabel->isEnabled());
QLineEdit *mInstancePath = w.findChild<QLineEdit *>(QStringLiteral("instancepath"));
QVERIFY(mInstancePath);
QVERIFY(mInstancePath->text().isEmpty());
QVERIFY(!mInstancePath->isEnabled());
}
......@@ -25,3 +25,13 @@ LanguageToolGrammarErrorTest::LanguageToolGrammarErrorTest(QObject *parent)
: QObject(parent)
{
}
void LanguageToolGrammarErrorTest::shouldParseJson_data()
{
//TODO
}
void LanguageToolGrammarErrorTest::shouldParseJson()
{
//TODO
}
......@@ -28,6 +28,9 @@ class LanguageToolGrammarErrorTest : public QObject
public:
explicit LanguageToolGrammarErrorTest(QObject *parent = nullptr);
~LanguageToolGrammarErrorTest() = default;
private Q_SLOTS:
void shouldParseJson_data();
void shouldParseJson();
};
#endif // LANGUAGETOOLGRAMMARERRORTEST_H
......@@ -22,3 +22,9 @@ target_link_libraries(kmaillanguagetool
KF5::MessageComposer
grammarcommon
)
set_target_properties(kmaillanguagetool
PROPERTIES OUTPUT_NAME kmaillanguagetool VERSION ${KDEPIMADDONS_LIB_VERSION} SOVERSION ${KDEPIMADDONS_LIB_SOVERSION}
)
install(TARGETS kmaillanguagetool ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP)
......@@ -25,14 +25,14 @@
#include <KConfigGroup>
#include <KSharedConfig>
LanguageToolConfigDialog::LanguageToolConfigDialog(QWidget *parent, bool disableMessageBox)
LanguageToolConfigDialog::LanguageToolConfigDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(i18n("Configure Grammalecte"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainlayout"));
mConfigWidget = new LanguageToolConfigWidget(this, disableMessageBox);
mConfigWidget = new LanguageToolConfigWidget(this);
mConfigWidget->setObjectName(QStringLiteral("configwidget"));
mainLayout->addWidget(mConfigWidget);
......
......@@ -26,7 +26,7 @@ class LIBKMAILLANGUAGETOOL_EXPORT LanguageToolConfigDialog : public QDialog
{
Q_OBJECT
public:
explicit LanguageToolConfigDialog(QWidget *parent = nullptr, bool disableMessageBox = false);
explicit LanguageToolConfigDialog(QWidget *parent = nullptr);
~LanguageToolConfigDialog();
private:
Q_DISABLE_COPY(LanguageToolConfigDialog)
......
......@@ -19,15 +19,16 @@
#include "languagetoolconfigwidget.h"
#include <KMessageBox>
#include <KLocalizedString>
#include <QVBoxLayout>
#include <QCheckBox>
#include <QLineEdit>
#include <QLabel>
#include <QVariant>
#include <KUrlRequester>
LanguageToolConfigWidget::LanguageToolConfigWidget(QWidget *parent, bool disableMessageBox)
LanguageToolConfigWidget::LanguageToolConfigWidget(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
......@@ -37,6 +38,21 @@ LanguageToolConfigWidget::LanguageToolConfigWidget(QWidget *parent, bool disable
mUseLocalInstance = new QCheckBox(i18n("Use Local Instance"), this);
mUseLocalInstance->setObjectName(QStringLiteral("uselocalinstance"));
mainLayout->addWidget(mUseLocalInstance);
QLabel *instancePathLabel = new QLabel(i18n("Instance Path:"), this);
instancePathLabel->setObjectName(QStringLiteral("instancepath"));
instancePathLabel->setEnabled(false);
mainLayout->addWidget(instancePathLabel);
mInstancePath = new QLineEdit(this);
mInstancePath->setObjectName(QStringLiteral("instancepath"));
mInstancePath->setEnabled(false);
mainLayout->addWidget(mInstancePath);
connect(mUseLocalInstance, &QCheckBox::clicked, this, [this, instancePathLabel](bool b) {
instancePathLabel->setEnabled(b);
mInstancePath->setEnabled(b);}
);
}
LanguageToolConfigWidget::~LanguageToolConfigWidget()
......
......@@ -23,18 +23,19 @@
#include <QWidget>
#include "libkmaillanguagetool_export.h"
class QCheckBox;
class KUrlRequester;
class QLineEdit;
class LIBKMAILLANGUAGETOOL_EXPORT LanguageToolConfigWidget : public QWidget
{
Q_OBJECT
public:
explicit LanguageToolConfigWidget(QWidget *parent = nullptr, bool disableMessageBox = false);
explicit LanguageToolConfigWidget(QWidget *parent = nullptr);
~LanguageToolConfigWidget();
void loadSettings();
void saveSettings();
private:
Q_DISABLE_COPY(LanguageToolConfigWidget)
QCheckBox *mUseLocalInstance = nullptr;
QLineEdit *mInstancePath = nullptr;
};
#endif // LANGUAGETOOLCONFIGWIDGET_H
......@@ -61,6 +61,7 @@ void LanguageToolManager::loadSettings()
KConfigGroup grp(KSharedConfig::openConfig(), "LanguageTool");
mLanguageToolPath = grp.readEntry(QStringLiteral("languagetoolpath"), QStringLiteral("https://languagetool.org/api/v2/check"));
mLanguage = grp.readEntry(QStringLiteral("language"), QStringLiteral("en"));
//TODO add options ?
}
void LanguageToolManager::saveSettings()
......
......@@ -38,7 +38,7 @@ QVector<GrammarError> LanguageToolParser::parseResult(const QJsonObject &obj) co
QVector<GrammarError> infos;
const QJsonArray array = obj.value(QLatin1String("matches")).toArray();
for (const QJsonValue &current : array) {
qDebug() << " current " << current;
//qDebug() << " current " << current;
if (current.type() == QJsonValue::Object) {
const QJsonObject languageToolObject = current.toObject();
LanguageToolGrammarError error;
......
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