summaryrefslogtreecommitdiff
path: root/cui/source/options/optlanguagetool.cxx
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/source/options/optlanguagetool.cxx
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/source/options/optlanguagetool.cxx')
-rw-r--r--cui/source/options/optlanguagetool.cxx25
1 files changed, 23 insertions, 2 deletions
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;