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 623d1267 authored by Laurent Montel's avatar Laurent Montel 😁

Allow to close grammar checker

parent d5690474
......@@ -38,6 +38,7 @@ GrammalecteInterface::GrammalecteInterface(KActionCollection *ac, QWidget *paren
mGrammarResultWidget = new GrammalecteResultWidget(this);
connect(mGrammarResultWidget, &GrammalecteResultWidget::replaceText, this, &GrammalecteInterface::slotReplaceText);
connect(mGrammarResultWidget, &GrammalecteResultWidget::checkAgain, this, &GrammalecteInterface::checkAgain);
connect(mGrammarResultWidget, &GrammalecteResultWidget::closeChecker, this, &GrammalecteInterface::closeChecker);
layout->addWidget(mGrammarResultWidget);
createAction(ac);
......@@ -68,11 +69,16 @@ void GrammalecteInterface::slotActivateGrammalecte(bool state)
checkAgain();
Q_EMIT activateView(this);
} else {
mGrammarResultWidget->hide();
Q_EMIT activateView(nullptr);
closeChecker();
}
}
void GrammalecteInterface::closeChecker()
{
mGrammarResultWidget->hide();
Q_EMIT activateView(nullptr);
}
KToggleAction *GrammalecteInterface::action() const
{
return mAction;
......@@ -97,3 +103,4 @@ void GrammalecteInterface::checkAgain()
qCWarning(KMAIL_EDITOR_GRAMMALECTE_PLUGIN_LOG) << "richtexteditor not setted, it's a bug";
}
}
......@@ -37,6 +37,7 @@ private:
void slotActivateGrammalecte(bool state);
void createAction(KActionCollection *ac);
void checkAgain();
void closeChecker();
GrammalecteResultWidget *mGrammarResultWidget = nullptr;
KToggleAction *mAction = nullptr;
};
......
......@@ -22,6 +22,7 @@
#include "grammarcommon_debug.h"
#include <KLocalizedString>
#include <KStandardAction>
#include <QMenu>
#include <QAction>
......@@ -130,6 +131,8 @@ void GrammarResultTextEdit::contextMenuEvent(QContextMenuEvent *event)
popup->addSeparator();
QAction *checkAgainAct = popup->addAction(QIcon::fromTheme(QStringLiteral("view-refresh")), i18n("Check Again"));
connect(checkAgainAct, &QAction::triggered, this, &GrammarResultTextEdit::checkAgain);
popup->addSeparator();
popup->addAction(KStandardAction::close(this, &GrammarResultTextEdit::closeChecker, this));
popup->exec(event->globalPos());
delete popup;
}
......
......@@ -43,6 +43,7 @@ protected:
Q_SIGNALS:
void replaceText(const MessageComposer::PluginGrammarAction &act);
void checkAgain();
void closeChecker();
private:
Q_DISABLE_COPY(GrammarResultTextEdit)
void slotReplaceWord(const MessageComposer::PluginGrammarAction &act, const QString &replacementWord);
......
......@@ -33,6 +33,7 @@ GrammarResultWidget::GrammarResultWidget(QWidget *parent)
mResult->setObjectName(QStringLiteral("grammarResult"));
connect(mResult, &GrammarResultTextEdit::replaceText, this, &GrammarResultWidget::replaceText);
connect(mResult, &GrammarResultTextEdit::checkAgain, this, &GrammarResultWidget::checkAgain);
connect(mResult, &GrammarResultTextEdit::closeChecker, this, &GrammarResultWidget::closeChecker);
mainLayout->addWidget(mResult);
}
......
......@@ -39,6 +39,7 @@ public:
Q_SIGNALS:
void replaceText(const MessageComposer::PluginGrammarAction &act);
void checkAgain();
void closeChecker();
protected:
GrammarResultTextEdit *mResult = nullptr;
private:
......
......@@ -39,6 +39,7 @@ LanguageToolInterface::LanguageToolInterface(KActionCollection *ac, QWidget *par
mGrammarResultWidget = new LanguageToolResultWidget(this);
connect(mGrammarResultWidget, &LanguageToolResultWidget::replaceText, this, &LanguageToolInterface::slotReplaceText);
connect(mGrammarResultWidget, &LanguageToolResultWidget::checkAgain, this, &LanguageToolInterface::checkAgain);
connect(mGrammarResultWidget, &LanguageToolResultWidget::closeChecker, this, &LanguageToolInterface::closeChecker);
layout->addWidget(mGrammarResultWidget);
createAction(ac);
......@@ -62,6 +63,12 @@ void LanguageToolInterface::slotReplaceText(const MessageComposer::PluginGrammar
}
}
void LanguageToolInterface::closeChecker()
{
mGrammarResultWidget->hide();
Q_EMIT activateView(nullptr);
}
void LanguageToolInterface::slotActivateGrammalecte(bool state)
{
if (state) {
......@@ -72,8 +79,7 @@ void LanguageToolInterface::slotActivateGrammalecte(bool state)
mGrammarResultWidget->show();
Q_EMIT activateView(this);
} else {
mGrammarResultWidget->hide();
Q_EMIT activateView(nullptr);
closeChecker();
}
}
......
......@@ -36,6 +36,7 @@ private:
void slotReplaceText(const MessageComposer::PluginGrammarAction &act);
void slotActivateGrammalecte(bool state);
void createAction(KActionCollection *ac);
void closeChecker();
bool checkAgain();
LanguageToolResultWidget *mGrammarResultWidget = nullptr;
KToggleAction *mAction = 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