From 5187d3ae495a07373a12fd5980c9269bc8ce3f8f Mon Sep 17 00:00:00 2001 From: heiko tietze Date: Mon, 13 May 2019 10:59:18 +0200 Subject: Resolves: tdf#69042 - Add a "What's New" infobar Shows an infobar with a link to the respective wiki page Adds a button to the About dialog Replaces If6eb1542d2ad310226f76850f480f2f99070b803 Change-Id: I1eeb504994a6364feb90cfa447029875e0ec1969 Reviewed-on: https://gerrit.libreoffice.org/72218 Tested-by: Jenkins Reviewed-by: Heiko Tietze Tested-by: Heiko Tietze --- cui/source/dialogs/about.cxx | 9 ++++ cui/source/inc/about.hxx | 1 + cui/uiconfig/ui/aboutdialog.ui | 22 ++++++++-- include/sfx2/sfxsids.hrc | 2 + include/sfx2/strings.hrc | 6 ++- include/sfx2/viewfrm.hxx | 3 +- include/unotools/configmgr.hxx | 2 + .../registry/data/org/openoffice/Office/Common.xcu | 3 ++ .../schema/org/openoffice/Office/Common.xcs | 5 +++ officecfg/registry/schema/org/openoffice/Setup.xcs | 7 ++++ sfx2/sdi/appslots.sdi | 4 ++ sfx2/sdi/sfx.sdi | 14 +++++++ sfx2/source/appl/appserv.cxx | 9 ++++ sfx2/source/view/viewfrm.cxx | 48 ++++++++++++++++++---- test/user-template/registry/modifications.xcd | 3 ++ unotools/source/config/configmgr.cxx | 6 +++ 16 files changed, 129 insertions(+), 15 deletions(-) diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx index 0943c163b42e..7d5266682144 100644 --- a/cui/source/dialogs/about.cxx +++ b/cui/source/dialogs/about.cxx @@ -76,6 +76,7 @@ AboutDialog::AboutDialog(vcl::Window* pParent) m_aCopyrightTextStr = m_pCopyrightText->GetText(); get(m_pWebsiteButton, "website"); get(m_pCreditsButton, "credits"); + get(m_pReleaseNotesButton, "btnReleaseNotes"); m_aCreditsLinkStr = get("link")->GetText(); m_sBuildStr = get("buildid")->GetText(); m_aVendorTextStr = get("vendor")->GetText(); @@ -100,6 +101,7 @@ AboutDialog::AboutDialog(vcl::Window* pParent) // Connect all handlers m_pCreditsButton->SetClickHdl( LINK( this, AboutDialog, HandleClick ) ); m_pWebsiteButton->SetClickHdl( LINK( this, AboutDialog, HandleClick ) ); + m_pReleaseNotesButton->SetClickHdl( LINK( this, AboutDialog, HandleClick ) ); get("close")->GrabFocus(); } @@ -119,6 +121,7 @@ void AboutDialog::dispose() m_pCreditsButton.clear(); m_pWebsiteButton.clear(); m_pBuildIdLink.clear(); + m_pReleaseNotesButton.clear(); SfxModalDialog::dispose(); } @@ -134,6 +137,12 @@ IMPL_LINK( AboutDialog, HandleClick, Button*, pButton, void ) sURL = officecfg::Office::Common::Help::StartCenter::InfoURL::get(); localizeWebserviceURI(sURL); } + else if (pButton == m_pReleaseNotesButton) + { + sURL = officecfg::Office::Common::Menus::ReleaseNotesURL::get() + + "?LOvers=" + utl::ConfigManager::getProductVersion() + + "&LOlocale=" + LanguageTag(utl::ConfigManager::getUILocale()).getLanguage(); + } // If the URL is empty, don't do anything if ( sURL.isEmpty() ) diff --git a/cui/source/inc/about.hxx b/cui/source/inc/about.hxx index 9885cdec7d47..d191343f941a 100644 --- a/cui/source/inc/about.hxx +++ b/cui/source/inc/about.hxx @@ -43,6 +43,7 @@ private: VclPtr m_pLogoReplacement; VclPtr m_pCreditsButton; VclPtr m_pWebsiteButton; + VclPtr m_pReleaseNotesButton; OUString m_aVersionTextStr; OUString m_aVendorTextStr; diff --git a/cui/uiconfig/ui/aboutdialog.ui b/cui/uiconfig/ui/aboutdialog.ui index 552fd1570185..2fc67d43913b 100644 --- a/cui/uiconfig/ui/aboutdialog.ui +++ b/cui/uiconfig/ui/aboutdialog.ui @@ -20,6 +20,21 @@ False end + + + _Release Notes + True + True + True + True + + + False + True + 0 + True + + Cre_dits @@ -31,7 +46,7 @@ False True - 0 + 1 True @@ -46,7 +61,7 @@ False True - 1 + 2 True @@ -63,7 +78,7 @@ False True - 2 + 3 @@ -311,6 +326,7 @@ + btnReleaseNotes credits website close diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index 7c0508b75415..ca2349b0196c 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -94,6 +94,8 @@ class SvxSearchItem; #define SID_DOCUMENTATION (SID_SFX_START + 423) #define SID_DONATION (SID_SFX_START + 424) #define SID_GETINVOLVED (SID_SFX_START + 425) +#define SID_WHATSNEW (SID_SFX_START + 426) + #define SID_SHOW_LICENSE (SID_SFX_START + 1683) #define SID_SHOW_CREDITS (SID_SFX_START + 1711) diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc index ca5f86f7d738..bb6606a7c620 100644 --- a/include/sfx2/strings.hrc +++ b/include/sfx2/strings.hrc @@ -246,8 +246,10 @@ #define STR_NONCHECKEDOUT_DOCUMENT NC_("STR_NONCHECKEDOUT_DOCUMENT", "This document is not checked out on the server.") #define STR_GET_INVOLVED_TEXT NC_("STR_GET_INVOLVED_TEXT", "Help us make %PRODUCTNAME even better!") #define STR_GET_INVOLVED_BUTTON NC_("STR_GET_INVOLVED_BUTTON", "Get involved") -#define STR_GET_DONATE_TEXT NC_("STR_GET_DONATE_TEXT", "Your donations support our worldwide community.") -#define STR_GET_DONATE_BUTTON NC_("STR_GET_DONATE_BUTTON", "Donate") +#define STR_DONATE_TEXT NC_("STR_DONATE_TEXT", "Your donations support our worldwide community.") +#define STR_DONATE_BUTTON NC_("STR_DONATE_BUTTON", "Donate") +#define STR_WHATSNEW_TEXT NC_("STR_WHATSNEW", "You are running version %PRODUCTVERSION of %PRODUCTNAME for the first time. Do you want to learn what's new?") +#define STR_WHATSNEW_BUTTON NC_("STR_WHATSNEW_BUTTON", "Release Notes") #define STR_READONLY_DOCUMENT NC_("STR_READONLY_DOCUMENT", "This document is open in read-only mode.") #define STR_READONLY_PDF NC_("STR_READONLY_PDF", "This PDF is open in read-only mode to allow signing the existing file.") #define STR_CLASSIFIED_DOCUMENT NC_("STR_CLASSIFIED_DOCUMENT", "The classification label of this document is %1.") diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx index de7bcaafafaf..502f1fe4480d 100644 --- a/include/sfx2/viewfrm.hxx +++ b/include/sfx2/viewfrm.hxx @@ -57,7 +57,8 @@ protected: virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; DECL_LINK(GetInvolvedHandler, Button*, void); - DECL_LINK(GetDonateHandler, Button*, void); + DECL_LINK(DonationHandler, Button*, void); + DECL_LINK(WhatsNewHandler, Button*, void); DECL_LINK(SwitchReadOnlyHandler, Button*, void); DECL_LINK(SignDocumentHandler, Button*, void); SAL_DLLPRIVATE void KillDispatcher_Impl(); diff --git a/include/unotools/configmgr.hxx b/include/unotools/configmgr.hxx index e79629834db4..e5b9f9c2f358 100644 --- a/include/unotools/configmgr.hxx +++ b/include/unotools/configmgr.hxx @@ -53,6 +53,8 @@ public: static OUString getProductVersion(); + static OUString getLastProductVersion(); + static OUString getVendor(); static void storeConfigItems(); diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu b/officecfg/registry/data/org/openoffice/Office/Common.xcu index 3e3223a14562..5f99ddc036bd 100644 --- a/officecfg/registry/data/org/openoffice/Office/Common.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu @@ -394,6 +394,9 @@ https://hub.libreoffice.org/donation/ + + https://hub.libreoffice.org/ReleaseNotes/ + diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index cbee0983ea4b..6d54c8159706 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -2075,6 +2075,11 @@ Specifies the URL used with the UNO command Donation (SID_DONATION). + + + Specifies the URL used with the UNO command WhatsNew (SID_WHATSNEW). + + diff --git a/officecfg/registry/schema/org/openoffice/Setup.xcs b/officecfg/registry/schema/org/openoffice/Setup.xcs index 1525b24a908b..34bca3e15c5e 100644 --- a/officecfg/registry/schema/org/openoffice/Setup.xcs +++ b/officecfg/registry/schema/org/openoffice/Setup.xcs @@ -260,6 +260,13 @@ + + + Specifies the version number of the previously used product for + whats-new comparison. + + + Specifies the complete (major.minor.micro) version number of the diff --git a/sfx2/sdi/appslots.sdi b/sfx2/sdi/appslots.sdi index e46e29741243..c1444d478a68 100644 --- a/sfx2/sdi/appslots.sdi +++ b/sfx2/sdi/appslots.sdi @@ -136,6 +136,10 @@ interface Application [ ExecMethod = MiscExec_Impl ; ] + SID_WHATSNEW + [ + ExecMethod = MiscExec_Impl ; + ] SID_SHOW_LICENSE [ ExecMethod = MiscExec_Impl ; diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 1794527ef78d..d3e1157d96e2 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -4945,7 +4945,21 @@ SfxVoidItem GetInvolved SID_GETINVOLVED MenuConfig = TRUE, GroupId = SfxGroupId::Application; ] +SfxVoidItem WhatsNew SID_WHATSNEW +() +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + AccelConfig = TRUE, + MenuConfig = TRUE, + GroupId = SfxGroupId::Application; +] SfxVoidItem ShowLicense SID_SHOW_LICENSE () [ diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 8de0d32cbf21..c5f09027700c 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -585,6 +585,15 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) sfx2::openUriExternally(sURL, false); break; } + case SID_WHATSNEW: + { + // Open release notes depending on version and locale + OUString sURL(officecfg::Office::Common::Menus::ReleaseNotesURL::get() + //https://hub.libreoffice.org/ReleaseNotes/ + "?LOvers=" + utl::ConfigManager::getProductVersion() + + "&LOlocale=" + LanguageTag(utl::ConfigManager::getUILocale()).getLanguage() ); + sfx2::openUriExternally(sURL, false); + break; + } case SID_SHOW_LICENSE: { LicenseDialog aDialog(rReq.GetFrameWeld()); diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 897bd9f5b180..18d71c170ea9 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1221,14 +1221,39 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) const auto t0 = std::chrono::system_clock::now().time_since_epoch(); - // show tip-of-the-day dialog - const bool bShowTipOfTheDay = officecfg::Office::Common::Misc::ShowTipOfTheDay::get(); bool bIsUITest = false; //uitest.uicheck fails when the dialog is open for( sal_uInt16 i = 0; i < Application::GetCommandLineParamCount(); i++ ) { if( Application::GetCommandLineParam(i) == "--nologo" ) bIsUITest = true; } + + //what's new infobar + if (!officecfg::Setup::Product::ooSetupLastVersion::isReadOnly()) //don't show/update when readonly + { + OUString sSetupVersion = utl::ConfigManager::getProductVersion(); + sal_Int32 iCurrent = sSetupVersion.getToken(0,'.').toInt32() * 10 + sSetupVersion.getToken(1,'.').toInt32(); + OUString sLastVersion = utl::ConfigManager::getLastProductVersion(); + if (sLastVersion.isEmpty()) sLastVersion="0.0"; + sal_Int32 iLast = sLastVersion.getToken(0,'.').toInt32() * 10 + sLastVersion.getToken(1,'.').toInt32(); + if ((iCurrent > iLast) && !Application::IsHeadlessModeEnabled() && !bIsUITest) + { + VclPtr pInfoBar = AppendInfoBar("whatsnew", SfxResId(STR_WHATSNEW_TEXT), InfoBarType::Info); + VclPtrInstance xWhatsNewButton(&GetWindow()); + xWhatsNewButton->SetText(SfxResId(STR_WHATSNEW_BUTTON)); + xWhatsNewButton->SetSizePixel(xWhatsNewButton->GetOptimalSize()); + xWhatsNewButton->SetClickHdl(LINK(this, SfxViewFrame, WhatsNewHandler)); + pInfoBar->addButton(xWhatsNewButton); + + //update lastversion + std::shared_ptr batch(comphelper::ConfigurationChanges::create()); + officecfg::Setup::Product::ooSetupLastVersion::set(sSetupVersion, batch); + batch->commit(); + } + } + + // show tip-of-the-day dialog + const bool bShowTipOfTheDay = officecfg::Office::Common::Misc::ShowTipOfTheDay::get(); if (bShowTipOfTheDay && !Application::IsHeadlessModeEnabled() && !bIsUITest) { const sal_Int32 nLastTipOfTheDay = officecfg::Office::Common::Misc::LastTipOfTheDayShown::get(); const sal_Int32 nDay = std::chrono::duration_cast(t0).count()/24; // days since 1970-01-01 @@ -1279,13 +1304,13 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { bUpdateLastTimeDonateShown = true; - VclPtr pInfoBar = AppendInfoBar("getdonate", SfxResId(STR_GET_DONATE_TEXT), InfoBarType::Info); + VclPtr pInfoBar = AppendInfoBar("donate", SfxResId(STR_DONATE_TEXT), InfoBarType::Info); - VclPtrInstance xGetDonateButton(&GetWindow()); - xGetDonateButton->SetText(SfxResId(STR_GET_DONATE_BUTTON)); - xGetDonateButton->SetSizePixel(xGetDonateButton->GetOptimalSize()); - xGetDonateButton->SetClickHdl(LINK(this, SfxViewFrame, GetDonateHandler)); - pInfoBar->addButton(xGetDonateButton); + VclPtrInstance xDonateButton(&GetWindow()); + xDonateButton->SetText(SfxResId(STR_DONATE_BUTTON)); + xDonateButton->SetSizePixel(xDonateButton->GetOptimalSize()); + xDonateButton->SetClickHdl(LINK(this, SfxViewFrame, DonationHandler)); + pInfoBar->addButton(xDonateButton); } if (bUpdateLastTimeDonateShown @@ -1419,12 +1444,17 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } } +IMPL_LINK_NOARG(SfxViewFrame, WhatsNewHandler, Button*, void) +{ + GetDispatcher()->Execute(SID_WHATSNEW); +} + IMPL_LINK_NOARG(SfxViewFrame, GetInvolvedHandler, Button*, void) { GetDispatcher()->Execute(SID_GETINVOLVED); } -IMPL_LINK_NOARG(SfxViewFrame, GetDonateHandler, Button*, void) +IMPL_LINK_NOARG(SfxViewFrame, DonationHandler, Button*, void) { GetDispatcher()->Execute(SID_DONATION); } diff --git a/test/user-template/registry/modifications.xcd b/test/user-template/registry/modifications.xcd index d8483c6f33ed..20895dbaf80a 100644 --- a/test/user-template/registry/modifications.xcd +++ b/test/user-template/registry/modifications.xcd @@ -22,6 +22,9 @@ false + + "32767" + diff --git a/unotools/source/config/configmgr.cxx b/unotools/source/config/configmgr.cxx index 05b1e5874643..859fd1c50498 100644 --- a/unotools/source/config/configmgr.cxx +++ b/unotools/source/config/configmgr.cxx @@ -135,6 +135,12 @@ OUString utl::ConfigManager::getProductVersion() { "Product/ooSetupVersion"); } +OUString utl::ConfigManager::getLastProductVersion() { + return getConfigurationString( + "/org.openoffice.Setup", + "Product/ooSetupLastVersion"); +} + OUString utl::ConfigManager::getVendor() { return getConfigurationString( "/org.openoffice.Setup", -- cgit