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

Don't show a qwarning when we have an empty text

parent 82445221
......@@ -44,17 +44,39 @@ static bool hasNotEmptyText(const QString &text)
bool LanguageToolResultJob::canStart() const
{
if (!mNetworkAccessManager || !hasNotEmptyText(mText) || mUrl.isEmpty() || mLanguage.isEmpty()) {
return false;
return (canStartError() == LanguageToolResultJob::JobError::NotError);
}
LanguageToolResultJob::JobError LanguageToolResultJob::canStartError() const
{
if (!mNetworkAccessManager) {
return LanguageToolResultJob::JobError::NetworkManagerNotDefined;
}
if (!hasNotEmptyText(mText)) {
return LanguageToolResultJob::JobError::EmptyText;
}
return true;
if (mUrl.isEmpty()) {
return LanguageToolResultJob::JobError::UrlNotDefined;
}
if (mLanguage.isEmpty()) {
return LanguageToolResultJob::JobError::LanguageNotDefined;
}
return LanguageToolResultJob::JobError::NotError;
}
void LanguageToolResultJob::start()
{
if (!canStart()) {
const LanguageToolResultJob::JobError errorType = canStartError();
switch (errorType) {
case LanguageToolResultJob::JobError::EmptyText:
return;
case LanguageToolResultJob::JobError::UrlNotDefined:
case LanguageToolResultJob::JobError::NetworkManagerNotDefined:
case LanguageToolResultJob::JobError::LanguageNotDefined:
qCWarning(LIBLANGUAGE_PLUGIN_LOG) << "Impossible to start language tool";
return;
case LanguageToolResultJob::JobError::NotError:
break;
}
QNetworkRequest request(QUrl::fromUserInput(mUrl));
addRequestAttribute(request);
......
......@@ -54,6 +54,15 @@ Q_SIGNALS:
private:
Q_DISABLE_COPY(LanguageToolResultJob)
enum class JobError {
NotError,
EmptyText,
UrlNotDefined,
NetworkManagerNotDefined,
LanguageNotDefined
};
LanguageToolResultJob::JobError canStartError() const;
void slotCheckGrammarFinished();
void addRequestAttribute(QNetworkRequest &request) const;
void slotFinish(QNetworkReply *reply);
......
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