Related tdf#166733 - Show Welcome dialog on the very first start only

Product updates should trigger the WhatsNew flavor of the welcome
dialog and only new installations the Welcome mode.

Change-Id: I6071ec748d735b92dd0169772dcbddceffad4760
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185976
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2025-05-29 07:49:29 +02:00
committed by Heiko Tietze
parent 17e8dbead4
commit aadde53647
4 changed files with 43 additions and 42 deletions
+4
View File
@@ -19,4 +19,8 @@ namespace utl
* current version of LibreOffice has been upgraded to a newer one.
*/
bool UNOTOOLS_DLLPUBLIC isProductVersionUpgraded();
/** This method is called to detect if the program is started the
* very first time after a clean installation or a profile reset.
*/
bool UNOTOOLS_DLLPUBLIC isProductVersionNew();
}
@@ -307,13 +307,11 @@
</info>
<value>true</value>
</prop>
<prop oor:name="WhatsNewDialog" oor:type="xs:boolean">
<prop oor:name="WhatsNewDialog" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Set to false to not show the WhatsNew dialog but the infobar.
Initial nil value is evaluated at the first start to show the
welcome dialog, and set to true in order to show the Whatsnew
information as a dialog rather than the simple infobar in case of false.</desc>
<desc>Set to false to not show the WhatsNew dialog but the infobar.</desc>
</info>
<value>true</value>
</prop>
</group>
<group oor:name="Office">
+29 -37
View File
@@ -1648,49 +1648,41 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
bool bIsWhatsNewShown = false; //suppress tipoftheday if whatsnew was shown
static const bool bRunningUnitTest = o3tl::IsRunningUnitTest() || o3tl::IsRunningUITest();
std::optional<bool> bShowWelcome = officecfg::Setup::Product::WhatsNewDialog::get(); // nil at first start = welcome dialog
if (!bShowWelcome.has_value() && !IsInModalMode() && !bRunningUnitTest)
{
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
ScopedVclPtr<SfxAbstractTabDialog> pDlg(
pFact->CreateWelcomeDialog(GetWindow().GetFrameWeld(), true));
pDlg->Execute();
std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
officecfg::Setup::Product::WhatsNewDialog::set(true, batch); // true after first start = whatsnew dialog
batch->commit();
bIsWhatsNewShown = true;
}
//what's new dialog
static bool wantsWhatsNew = utl::isProductVersionUpgraded() && !IsInModalMode() && bShowWelcome.has_value();
static bool wantsWhatsNew = officecfg::Setup::Product::WhatsNew::get()
&& !IsInModalMode() && !bRunningUnitTest
&& utl::isProductVersionUpgraded(); //sets isProductVersionNew
if (wantsWhatsNew)
{
wantsWhatsNew = false;
if (officecfg::Setup::Product::WhatsNew::get())
if (utl::isProductVersionNew()) //welcome dialog
{
if (bShowWelcome)
{
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
ScopedVclPtr<SfxAbstractTabDialog> pDlg(
pFact->CreateWelcomeDialog(GetWindow().GetFrameWeld(), false));
pDlg->Execute();
}
else
{
OUString sText(SfxResId(STR_WHATSNEW_TEXT));
VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar(u"whatsnew"_ustr, u""_ustr, sText.replaceAll("\n",""), InfobarType::INFO);
if (pInfoBar)
{
weld::Button& rWhatsNewButton = pInfoBar->addButton();
rWhatsNewButton.set_label(SfxResId(STR_WHATSNEW_BUTTON));
rWhatsNewButton.connect_clicked(LINK(this, SfxViewFrame, WhatsNewHandler));
}
}
bIsInfobarShown = true;
bIsWhatsNewShown = true;
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
ScopedVclPtr<SfxAbstractTabDialog> pDlg(
pFact->CreateWelcomeDialog(GetWindow().GetFrameWeld(), true));
pDlg->Execute();
}
else if (officecfg::Setup::Product::WhatsNewDialog::get()) //whatsnew dialog
{
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
ScopedVclPtr<SfxAbstractTabDialog> pDlg(
pFact->CreateWelcomeDialog(GetWindow().GetFrameWeld(), false));
pDlg->Execute();
}
else //whatsnew infobar
{
OUString sText(SfxResId(STR_WHATSNEW_TEXT));
VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar(u"whatsnew"_ustr, u""_ustr, sText.replaceAll("\n",""), InfobarType::INFO);
if (pInfoBar)
{
weld::Button& rWhatsNewButton = pInfoBar->addButton();
rWhatsNewButton.set_label(SfxResId(STR_WHATSNEW_BUTTON));
rWhatsNewButton.connect_clicked(LINK(this, SfxViewFrame, WhatsNewHandler));
}
}
bIsInfobarShown = true;
bIsWhatsNewShown = true;
}
// show tip-of-the-day dialog if it due, but not if there is the impress modal template dialog
+7
View File
@@ -21,9 +21,16 @@
namespace utl
{
bool isProductVersionNew()
{
static const bool bIsNew = !officecfg::Setup::Product::ooSetupLastVersion::get().has_value();
return bIsNew;
}
bool isProductVersionUpgraded()
{
static const bool bUpgraded = []() {
(void)isProductVersionNew(); //set variable above
OUString sSetupVersion = utl::ConfigManager::getProductVersion();
sal_Int32 iCurrent = o3tl::toInt32(o3tl::getToken(sSetupVersion, 0, '.')) * 10
+ o3tl::toInt32(o3tl::getToken(sSetupVersion, 1, '.'));