summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorRafael Lima <rafael.palma.lima@gmail.com>2022-11-03 14:52:13 +0200
committerRafael Lima <rafael.palma.lima@gmail.com>2022-11-09 16:06:12 +0100
commit2c8a760a18501acaa6e4ff2a2dee76b0bad275f1 (patch)
treefd2a21d7fcecadd4e6d0db6c74271f634fc78f19 /cui
parent95cb9a01bfacf7d9f03194b0710ca3c249bb62fb (diff)
tdf#150494 LanguageTool: Add placeholder text with default value info
With this patch, the Language Tool dialog works as follows: - The first time the tool is enabled, a default URL is entered as text - If the URL is left empty, a placeholder text is shown saying that leaving this entry empty will cause the default URL to be used - If another URL is defined by the user, than this is the one used Change-Id: Id31fca0e44091aff3c77a9be8b639a20437b1b7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142197 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'cui')
-rw-r--r--cui/inc/strings.hrc2
-rw-r--r--cui/source/options/optlanguagetool.cxx25
-rw-r--r--cui/source/options/optlanguagetool.hxx3
3 files changed, 28 insertions, 2 deletions
diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc
index cea0b183e33a..b4b232b9ac5d 100644
--- a/cui/inc/strings.hrc
+++ b/cui/inc/strings.hrc
@@ -403,4 +403,6 @@
#define RID_CUISTR_ZIPFAIL NC_("RID_CUISTR_ZIPFAIL", "Creation of ZIP file failed.")
#define RID_CUISTR_SAVED NC_("RID_CUISTR_SAVED", "The results have been successfully saved in the file 'GraphicTestResults.zip'!")
+#define RID_LANGUAGETOOL_LEAVE_EMPTY NC_("RID_LANGUAGETOOL_LEAVE_EMPTY", "Leave this field empty to use the free version")
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/options/optlanguagetool.cxx b/cui/source/options/optlanguagetool.cxx
index 38807bc337d3..309ff2a09b52 100644
--- a/cui/source/options/optlanguagetool.cxx
+++ b/cui/source/options/optlanguagetool.cxx
@@ -20,6 +20,8 @@
#include "optlanguagetool.hxx"
#include <svtools/languagetoolcfg.hxx>
#include <sal/log.hxx>
+#include <dialmgr.hxx>
+#include <strings.hrc>
OptLanguageToolTabPage::OptLanguageToolTabPage(weld::Container* pPage,
weld::DialogController* pController,
@@ -34,6 +36,11 @@ OptLanguageToolTabPage::OptLanguageToolTabPage(weld::Container* pPage,
m_xActivateBox->connect_toggled(LINK(this, OptLanguageToolTabPage, CheckHdl));
SvxLanguageToolOptions& rLanguageOpts = SvxLanguageToolOptions::Get();
EnableControls(rLanguageOpts.getEnabled());
+
+ // tdf#150494 Set default values as placeholder text
+ m_xBaseURLED->set_placeholder_text(CuiResId(RID_LANGUAGETOOL_LEAVE_EMPTY));
+ m_xUsernameED->set_placeholder_text(CuiResId(RID_LANGUAGETOOL_LEAVE_EMPTY));
+ m_xApiKeyED->set_placeholder_text(CuiResId(RID_LANGUAGETOOL_LEAVE_EMPTY));
}
OptLanguageToolTabPage::~OptLanguageToolTabPage() {}
@@ -54,7 +61,14 @@ IMPL_LINK_NOARG(OptLanguageToolTabPage, CheckHdl, weld::Toggleable&, void)
void OptLanguageToolTabPage::Reset(const SfxItemSet*)
{
SvxLanguageToolOptions& rLanguageOpts = SvxLanguageToolOptions::Get();
- m_xBaseURLED->set_text(rLanguageOpts.getBaseURL());
+
+ // tdf#150494 If no URL has been set, use the default URL
+ OUString aBaseURL = rLanguageOpts.getBaseURL();
+ if (aBaseURL.isEmpty())
+ m_xBaseURLED->set_text(LANGUAGETOOL_DEFAULT_URL);
+ else
+ m_xBaseURLED->set_text(rLanguageOpts.getBaseURL());
+
m_xUsernameED->set_text(rLanguageOpts.getUsername());
m_xApiKeyED->set_text(rLanguageOpts.getApiKey());
}
@@ -62,7 +76,14 @@ void OptLanguageToolTabPage::Reset(const SfxItemSet*)
bool OptLanguageToolTabPage::FillItemSet(SfxItemSet*)
{
SvxLanguageToolOptions& rLanguageOpts = SvxLanguageToolOptions::Get();
- rLanguageOpts.setBaseURL(m_xBaseURLED->get_text());
+
+ // tdf#150494 If no URL has been set, then save the default URL
+ OUString aBaseURL = m_xBaseURLED->get_text();
+ if (aBaseURL.isEmpty())
+ rLanguageOpts.setBaseURL(LANGUAGETOOL_DEFAULT_URL);
+ else
+ rLanguageOpts.setBaseURL(aBaseURL);
+
rLanguageOpts.setUsername(m_xUsernameED->get_text());
rLanguageOpts.setApiKey(m_xApiKeyED->get_text());
return false;
diff --git a/cui/source/options/optlanguagetool.hxx b/cui/source/options/optlanguagetool.hxx
index 46a60ecbe103..8ee83ed4e367 100644
--- a/cui/source/options/optlanguagetool.hxx
+++ b/cui/source/options/optlanguagetool.hxx
@@ -18,6 +18,9 @@
*/
#pragma once
#include <sfx2/tabdlg.hxx>
+#include <rtl/ustring.hxx>
+
+inline constexpr OUStringLiteral LANGUAGETOOL_DEFAULT_URL = u"https://api.languagetool.org/v2";
class OptLanguageToolTabPage : public SfxTabPage
{