summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAron Budea <aron.budea@collabora.com>2022-11-27 22:48:51 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-11-28 14:31:35 +0100
commitbfdaa3f59bcf87f341138202c047dd4b28acb28a (patch)
tree34fe758cc24f1dafa99c11ce5eb8ae88dd04a829
parentf97556dc0bdf9b4593fab78ef205972bf89b4af3 (diff)
DeepL: Only enable Translate menu if it's set up
Both the API URL and Authentication key have to be set. Plus: - align widgets in DeepL settings dialog, - rename .ui file to conform to other dialog names in Options. Change-Id: I8cfeaa64b05747b0113a6075b6fd241ca9ab3a70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143359 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--cui/UIConfig_cui.mk2
-rw-r--r--cui/source/options/optdeepl.cxx2
-rw-r--r--cui/uiconfig/ui/optdeeplpage.ui (renamed from cui/uiconfig/ui/deepltabpage.ui)9
-rw-r--r--sw/source/uibase/shells/textsh1.cxx10
4 files changed, 16 insertions, 7 deletions
diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk
index 4c0f9a7f2a75..6985163f6922 100644
--- a/cui/UIConfig_cui.mk
+++ b/cui/UIConfig_cui.mk
@@ -137,6 +137,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
cui/uiconfig/ui/optbasicidepage \
cui/uiconfig/ui/optctlpage \
cui/uiconfig/ui/optchartcolorspage \
+ cui/uiconfig/ui/optdeeplpage \
cui/uiconfig/ui/optemailpage \
cui/uiconfig/ui/optfltrpage \
cui/uiconfig/ui/optfltrembedpage \
@@ -144,7 +145,6 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
cui/uiconfig/ui/optgeneralpage \
cui/uiconfig/ui/opthtmlpage \
cui/uiconfig/ui/langtoolconfigpage \
- cui/uiconfig/ui/deepltabpage \
cui/uiconfig/ui/optionsdialog \
cui/uiconfig/ui/optjsearchpage \
cui/uiconfig/ui/optlanguagespage \
diff --git a/cui/source/options/optdeepl.cxx b/cui/source/options/optdeepl.cxx
index b219845f07c7..5343f72a59c9 100644
--- a/cui/source/options/optdeepl.cxx
+++ b/cui/source/options/optdeepl.cxx
@@ -22,7 +22,7 @@
OptDeeplTabPage::OptDeeplTabPage(weld::Container* pPage, weld::DialogController* pController,
const SfxItemSet& rSet)
- : SfxTabPage(pPage, pController, "cui/ui/deepltabpage.ui", "OptDeeplPage", &rSet)
+ : SfxTabPage(pPage, pController, "cui/ui/optdeeplpage.ui", "OptDeeplPage", &rSet)
, m_xAPIUrl(m_xBuilder->weld_entry("apiurl"))
, m_xAuthKey(m_xBuilder->weld_entry("authkey"))
{
diff --git a/cui/uiconfig/ui/deepltabpage.ui b/cui/uiconfig/ui/optdeeplpage.ui
index d6635b7ae990..6422be8bd611 100644
--- a/cui/uiconfig/ui/deepltabpage.ui
+++ b/cui/uiconfig/ui/optdeeplpage.ui
@@ -18,7 +18,7 @@
<property name="halign">start</property>
<property name="xpad">5</property>
<property name="ypad">5</property>
- <property name="label" translatable="yes" context="deepltabpage|label1">DeepL API Options</property>
+ <property name="label" translatable="yes" context="optdeeplpage|label1">DeepL API Options</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">grid1</property>
<attributes>
@@ -32,7 +32,7 @@
</child>
<child>
<object class="GtkLinkButton" id="privacy">
- <property name="label" translatable="yes" context="deepltabpage|privacy">Please read the privacy policy</property>
+ <property name="label" translatable="yes" context="optdeeplpage|privacy">Please read the privacy policy</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@@ -60,8 +60,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
- <property name="margin_start">5</property>
- <property name="label" translatable="yes" context="deepltabpage|privacy">API URL:</property>
+ <property name="label" translatable="yes" context="optdeeplpage|privacy">API URL:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">apiurl</property>
</object>
@@ -76,7 +75,7 @@
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_end">5</property>
- <property name="label" translatable="yes" context="deepltabpage|label3">Authentication key:</property>
+ <property name="label" translatable="yes" context="optdeeplpage|label3">Authentication key:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">authkey</property>
</object>
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index d17715a826aa..b38748039bc9 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1993,6 +1993,16 @@ void SwTextShell::GetState( SfxItemSet &rSet )
}
break;
+ case SID_FM_TRANSLATE:
+ {
+ const SvxDeeplOptions& rDeeplOptions = SvxDeeplOptions::Get();
+ if (rDeeplOptions.getAPIUrl().isEmpty() || rDeeplOptions.getAuthKey().isEmpty())
+ {
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
+
case SID_HYPERLINK_DIALOG:
if( GetView().GetDocShell()->IsReadOnly()
|| ( !GetView().GetViewFrame()->HasChildWindow(nWhich)