From 2c8a760a18501acaa6e4ff2a2dee76b0bad275f1 Mon Sep 17 00:00:00 2001 From: Rafael Lima Date: Thu, 3 Nov 2022 14:52:13 +0200 Subject: 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 --- cui/source/options/optlanguagetool.cxx | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'cui/source/options/optlanguagetool.cxx') 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 #include +#include +#include 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; -- cgit