sfx2/source/appl/sfxhelp.cxx | 71 +++++++++++++++++++++++++++++------ sfx2/source/inc/helpids.h | 2 + sfx2/uiconfig/ui/helpmanual.ui | 82 +++++++++++++++++++++++++++++------------ 3 files changed, 119 insertions(+), 36 deletions(-)
New commits: commit c48952eb6b6f65affcda75ee74c292008be9c455 Author: Rafael Lima <rafael.palma.l...@gmail.com> AuthorDate: Fri Aug 4 04:35:42 2023 +0200 Commit: Rafael Lima <rafael.palma.l...@gmail.com> CommitDate: Fri Dec 15 18:17:32 2023 +0100 tdf#142926 Add button to Download page in Help dialog box Change-Id: Ie22dda17949d583a388d45e5aad3728b91637bff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155298 Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org> Tested-by: Jenkins Reviewed-by: Rafael Lima <rafael.palma.l...@gmail.com> diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index b596a4e33efa..c67f1485497f 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -19,6 +19,7 @@ #include <config_folders.h> #include <sfx2/sfxhelp.hxx> +#include <helpids.h> #include <string_view> #include <algorithm> @@ -1011,22 +1012,33 @@ namespace { class HelpManualMessage : public weld::MessageDialogController { private: + std::unique_ptr<weld::LinkButton> m_xDownloadInfo; std::unique_ptr<weld::CheckButton> m_xHideOfflineHelpCB; + DECL_LINK(DownloadClickHdl, weld::LinkButton&, bool); public: HelpManualMessage(weld::Widget* pParent) - : MessageDialogController(pParent, "sfx/ui/helpmanual.ui", "onlinehelpmanual", "hidedialog") + : MessageDialogController(pParent, "sfx/ui/helpmanual.ui", "onlinehelpmanual", "box") + , m_xDownloadInfo(m_xBuilder->weld_link_button("downloadinfo")) , m_xHideOfflineHelpCB(m_xBuilder->weld_check_button("hidedialog")) { LanguageType aLangType = Application::GetSettings().GetUILanguageTag().getLanguageType(); OUString sLocaleString = SvtLanguageTable::GetLanguageString(aLangType); OUString sPrimText = get_primary_text(); set_primary_text(sPrimText.replaceAll("$UILOCALE", sLocaleString)); + + m_xDownloadInfo->connect_activate_link(LINK(this, HelpManualMessage, DownloadClickHdl)); } bool GetOfflineHelpPopUp() const { return !m_xHideOfflineHelpCB->get_active(); } }; +IMPL_LINK(HelpManualMessage, DownloadClickHdl, weld::LinkButton&, /* rButton */, bool) +{ + m_xDialog->response(RET_YES); + return true; +} + } bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow) @@ -1138,6 +1150,7 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow) if ( !impl_hasHelpInstalled() ) { bool bShowOfflineHelpPopUp = officecfg::Office::Common::Help::BuiltInHelpNotInstalledPopUp::get(); + short retOnlineHelpBox = RET_CLOSE; TopLevelWindowLocker aBusy; @@ -1145,18 +1158,31 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow) { aBusy.incBusy(pWeldWindow); HelpManualMessage aQueryBox(pWeldWindow); - short OnlineHelpBox = aQueryBox.run(); - bShowOfflineHelpPopUp = OnlineHelpBox != RET_OK; + retOnlineHelpBox = aQueryBox.run(); auto xChanges = comphelper::ConfigurationChanges::create(); officecfg::Office::Common::Help::BuiltInHelpNotInstalledPopUp::set(aQueryBox.GetOfflineHelpPopUp(), xChanges); xChanges->commit(); aBusy.decBusy(); } - if(!bShowOfflineHelpPopUp) + + // Checks whether the user clicked "Read Help Online" (RET_OK) or "Information on downloading offline help" (RET_YES) + if(retOnlineHelpBox == RET_OK || retOnlineHelpBox == RET_YES) { - if ( impl_showOnlineHelp(aHelpURL, pWeldWindow) ) - return true; + bool bTopicExists; + + if (retOnlineHelpBox == RET_OK) + { + bTopicExists = impl_showOnlineHelp(aHelpURL, pWeldWindow); + } else + { + // Opens the help page that explains how to install offline help + OUString aOfflineHelpURL(CreateHelpURL_Impl(HID_HELPMANUAL_OFFLINE, "shared")); + impl_showOnlineHelp(aOfflineHelpURL, pWeldWindow); + bTopicExists = true; + } + + if (!bTopicExists) { aBusy.incBusy(pWeldWindow); NoHelpErrorBox aErrBox(pWeldWindow); @@ -1164,6 +1190,10 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow) aBusy.decBusy(); return false; } + else + { + return true; + } } else { @@ -1307,6 +1337,7 @@ bool SfxHelp::Start_Impl(const OUString& rURL, weld::Widget* pWidget, const OUSt if ( !impl_hasHelpInstalled() ) { bool bShowOfflineHelpPopUp = officecfg::Office::Common::Help::BuiltInHelpNotInstalledPopUp::get(); + short retOnlineHelpBox = RET_CLOSE; TopLevelWindowLocker aBusy; @@ -1314,18 +1345,31 @@ bool SfxHelp::Start_Impl(const OUString& rURL, weld::Widget* pWidget, const OUSt { aBusy.incBusy(pWidget); HelpManualMessage aQueryBox(pWidget); - short OnlineHelpBox = aQueryBox.run(); - bShowOfflineHelpPopUp = OnlineHelpBox != RET_OK; + retOnlineHelpBox = aQueryBox.run(); auto xChanges = comphelper::ConfigurationChanges::create(); officecfg::Office::Common::Help::BuiltInHelpNotInstalledPopUp::set(aQueryBox.GetOfflineHelpPopUp(), xChanges); xChanges->commit(); aBusy.decBusy(); } - if(!bShowOfflineHelpPopUp) + + // Checks whether the user clicked "Read Help Online" (RET_OK) or "Information on downloading offline help" (RET_YES) + if(retOnlineHelpBox == RET_OK || retOnlineHelpBox == RET_YES) { - if ( impl_showOnlineHelp(aHelpURL, pWidget) ) - return true; + bool bTopicExists; + + if (retOnlineHelpBox == RET_OK) + { + bTopicExists = impl_showOnlineHelp(aHelpURL, pWidget); + } else + { + // Opens the help page that explains how to install offline help + OUString aOfflineHelpURL(CreateHelpURL_Impl(HID_HELPMANUAL_OFFLINE, "shared")); + impl_showOnlineHelp(aOfflineHelpURL, pWidget); + bTopicExists = true; + } + + if (!bTopicExists) { aBusy.incBusy(pWidget); NoHelpErrorBox aErrBox(pWidget); @@ -1333,12 +1377,15 @@ bool SfxHelp::Start_Impl(const OUString& rURL, weld::Widget* pWidget, const OUSt aBusy.decBusy(); return false; } + else + { + return true; + } } else { return false; } - } } diff --git a/sfx2/source/inc/helpids.h b/sfx2/source/inc/helpids.h index 1d5ff141c4a1..33d165828368 100644 --- a/sfx2/source/inc/helpids.h +++ b/sfx2/source/inc/helpids.h @@ -52,6 +52,8 @@ inline constexpr OUString HID_QUERY_LOAD_TEMPLATE = u"SFX2_HID_QUERY_LOAD_TEMPLA inline constexpr OUString HID_SIDEBAR_WINDOW = u"SFX2_HID_SIDEBAR_WINDOW"_ustr; +inline constexpr OUString HID_HELPMANUAL_OFFLINE = u"SFX2_HID_HELPMANUAL_OFFLINE"_ustr; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/uiconfig/ui/helpmanual.ui b/sfx2/uiconfig/ui/helpmanual.ui index 0da32ebb4a99..8b3c53fb349f 100644 --- a/sfx2/uiconfig/ui/helpmanual.ui +++ b/sfx2/uiconfig/ui/helpmanual.ui @@ -1,30 +1,31 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.1 --> +<!-- Generated with glade 3.40.0 --> <interface domain="sfx"> <requires lib="gtk+" version="3.20"/> <object class="GtkMessageDialog" id="onlinehelpmanual"> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="title" translatable="yes" context="helpmanual|onlinehelpmanual">%PRODUCTNAME Help Not Installed</property> <property name="resizable">False</property> <property name="modal">True</property> - <property name="type_hint">dialog</property> - <property name="skip_taskbar_hint">True</property> + <property name="type-hint">dialog</property> + <property name="skip-taskbar-hint">True</property> <property name="text" translatable="yes" context="helpmanual|onlinehelpmanual">The %PRODUCTNAME built-in help for current UI language ($UILOCALE) is not installed on your computer.</property> - <property name="secondary_text" translatable="yes" context="helpmanual|onlinehelpmanual">You may either install it from our website or your system’s repositories, or read an online version.</property> + <property name="secondary-text" translatable="yes" context="helpmanual|onlinehelpmanual">You may either install it from our website or your system’s repositories, or read an online version.</property> <child internal-child="vbox"> <object class="GtkBox" id="internal_box"> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="orientation">vertical</property> <child internal-child="action_area"> <object class="GtkButtonBox" id="btnbox"> - <property name="can_focus">False</property> + <property name="can-focus">False</property> + <property name="layout-style">end</property> <child> <object class="GtkButton" id="website"> <property name="label" translatable="yes" context="helpmanual|website">Read Help Online</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="use-underline">True</property> </object> <packing> <property name="expand">True</property> @@ -33,47 +34,80 @@ </packing> </child> <child> - <object class="GtkButton" id="cancel"> - <property name="label" translatable="yes" context="stock">_Cancel</property> + <object class="GtkButton" id="close"> + <property name="label" translatable="yes" context="stock">_Close</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="receives_default">True</property> + <property name="can-focus">True</property> + <property name="can-default">True</property> + <property name="has-default">True</property> + <property name="receives-default">True</property> <property name="use-underline">True</property> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> </object> <packing> <property name="expand">False</property> <property name="fill">False</property> + <property name="padding">5</property> + <property name="pack-type">end</property> <property name="position">0</property> </packing> </child> <child> - <object class="GtkCheckButton" id="hidedialog"> - <property name="label" translatable="yes" context="helpmanual|hidedialog">Do not show this dialog again</property> + <object class="GtkBox" id="box"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="draw_indicator">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkLinkButton" id="downloadinfo"> + <property name="label" translatable="yes" context="helpmanual|builtin">Learn more about installing the built-in help</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="focus-on-click">False</property> + <property name="receives-default">True</property> + <property name="relief">none</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="hidedialog"> + <property name="label" translatable="yes" context="helpmanual|hidedialog">Do not show this dialog again</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="xalign">0</property> + <property name="draw-indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">2</property> + <property name="padding">6</property> + <property name="position">6</property> </packing> </child> </object> </child> <action-widgets> <action-widget response="-5">website</action-widget> - <action-widget response="-6">cancel</action-widget> + <action-widget response="-7">close</action-widget> </action-widgets> </object> </interface>