cui/UIConfig_cui.mk                 |    2 +-
 cui/source/options/optdeepl.cxx     |    2 +-
 cui/uiconfig/ui/optdeeplpage.ui     |    9 ++++-----
 sw/source/uibase/shells/textsh1.cxx |   10 ++++++++++
 4 files changed, 16 insertions(+), 7 deletions(-)

New commits:
commit bfdaa3f59bcf87f341138202c047dd4b28acb28a
Author:     Aron Budea <aron.bu...@collabora.com>
AuthorDate: Sun Nov 27 22:48:51 2022 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Nov 28 14:31:35 2022 +0100

    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 <vmik...@collabora.com>

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
similarity index 92%
rename from cui/uiconfig/ui/deepltabpage.ui
rename to 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)

Reply via email to