summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-08-18 14:03:47 +0100
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2021-08-19 14:52:56 +0200
commiteb9898da5e553bea997238dd988fa281aaf21b90 (patch)
tree8a89c64e2992b0daa2a74581aad2ed510caba127
parente08fba90f9b593b1a0a7af44bae1d7da0404d3f1 (diff)
tdf#143353 defer tip of the day until impress template dialog is gone
wait until that dialog is dismissed before showing the tip dialog Change-Id: Id0e7e28f09c5a9727e10eda55e468adb56bfda70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120677 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r--include/sfx2/app.hxx6
-rw-r--r--sd/source/ui/app/sdmod1.cxx9
-rw-r--r--sfx2/source/view/viewfrm.cxx62
3 files changed, 57 insertions, 20 deletions
diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx
index b4770f409f24..f9f74d388ddb 100644
--- a/include/sfx2/app.hxx
+++ b/include/sfx2/app.hxx
@@ -218,6 +218,12 @@ public:
/** loads the application logo as used in the impress slideshow pause screen */
static BitmapEx GetApplicationLogo(tools::Long nWidth);
+ /** if true then dialog/infobar notifications like the tip of the day or
+ version change infobar should be suppressed */
+ static bool IsHeadlessOrUITest();
+
+ static bool IsTipOfTheDayDue();
+
/** this Theme contains Images so must be deleted before DeInitVCL */
sfx2::sidebar::Theme & GetSidebarTheme();
};
diff --git a/sd/source/ui/app/sdmod1.cxx b/sd/source/ui/app/sdmod1.cxx
index 01d36ee93155..c275d79dc5d1 100644
--- a/sd/source/ui/app/sdmod1.cxx
+++ b/sd/source/ui/app/sdmod1.cxx
@@ -489,6 +489,15 @@ SfxFrame* SdModule::ExecuteNewDocument( SfxRequest const & rReq )
//pFrame is loaded with the desired template
if (!aTemplDlg.getTemplatePath().isEmpty())
pFrame = CreateFromTemplate(aTemplDlg.getTemplatePath(), xTargetFrame, false);
+
+ // show tip-of-the-day dialog if it was deferred because SfxTemplateSelectionDlg
+ // was open
+ if (pFrame && SfxApplication::IsTipOfTheDayDue() && !SfxApplication::IsHeadlessOrUITest())
+ {
+ // tdf#127946 pass in argument for dialog parent
+ SfxUnoFrameItem aDocFrame(SID_FILLFRAME, pFrame->GetFrameInterface());
+ GetDispatcher()->ExecuteList(SID_TIPOFTHEDAY, SfxCallMode::SLOT, {}, { &aDocFrame });
+ }
}
}
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index be8ea298b978..cb5761301379 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -1325,6 +1325,37 @@ css::uno::Reference<css::frame::XLayoutManager> getLayoutManager(const SfxFrame&
}
}
+bool SfxApplication::IsHeadlessOrUITest()
+{
+ if (Application::IsHeadlessModeEnabled())
+ return true;
+
+ bool bIsUITest = false; //uitest.uicheck fails when the dialog is open
+ for (sal_uInt16 i = 0, nCount = Application::GetCommandLineParamCount(); i < nCount; ++i)
+ {
+ if (Application::GetCommandLineParam(i) == "--nologo")
+ {
+ bIsUITest = true;
+ break;
+ }
+ }
+ return bIsUITest;
+}
+
+bool SfxApplication::IsTipOfTheDayDue()
+{
+ const bool bShowTipOfTheDay = officecfg::Office::Common::Misc::ShowTipOfTheDay::get();
+ if (!bShowTipOfTheDay)
+ return false;
+
+ const auto t0 = std::chrono::system_clock::now().time_since_epoch();
+
+ // show tip-of-the-day dialog ?
+ const sal_Int32 nLastTipOfTheDay = officecfg::Office::Common::Misc::LastTipOfTheDayShown::get();
+ const sal_Int32 nDay = std::chrono::duration_cast<std::chrono::hours>(t0).count()/24; // days since 1970-01-01
+ return nDay - nLastTipOfTheDay > 0; //only once per day
+}
+
void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
{
if(m_pImpl->bIsDowning)
@@ -1357,14 +1388,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
rBind.Invalidate( SID_RELOAD );
rBind.Invalidate( SID_EDITDOC );
- const auto t0 = std::chrono::system_clock::now().time_since_epoch();
-
- 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;
- }
+ bool bIsHeadlessOrUITest = SfxApplication::IsHeadlessOrUITest(); //uitest.uicheck fails when the dialog is open
//what's new infobar
OUString sSetupVersion = utl::ConfigManager::getProductVersion();
@@ -1372,7 +1396,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
OUString sLastVersion
= officecfg::Setup::Product::ooSetupLastVersion::get().value_or("0.0");
sal_Int32 iLast = sLastVersion.getToken(0,'.').toInt32() * 10 + sLastVersion.getToken(1,'.').toInt32();
- if ((iCurrent > iLast) && !Application::IsHeadlessModeEnabled() && !bIsUITest)
+ if ((iCurrent > iLast) && !bIsHeadlessOrUITest)
{
VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar("whatsnew", "", SfxResId(STR_WHATSNEW_TEXT), InfobarType::INFO);
if (pInfoBar)
@@ -1387,19 +1411,17 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
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<std::chrono::hours>(t0).count()/24; // days since 1970-01-01
- if (nDay-nLastTipOfTheDay > 0) { //only once per day
- // tdf#127946 pass in argument for dialog parent
- SfxUnoFrameItem aDocFrame(SID_FILLFRAME, GetFrame().GetFrameInterface());
- GetDispatcher()->ExecuteList(SID_TIPOFTHEDAY, SfxCallMode::SLOT, {}, { &aDocFrame });
- }
- } //bShowTipOfTheDay
+ // show tip-of-the-day dialog if it due, but not if there is the impress modal template dialog
+ // open where SdModule::ExecuteNewDocument will launch it instead when that dialog is dismissed
+ if (SfxApplication::IsTipOfTheDayDue() && !bIsHeadlessOrUITest && !IsInModalMode())
+ {
+ // tdf#127946 pass in argument for dialog parent
+ SfxUnoFrameItem aDocFrame(SID_FILLFRAME, GetFrame().GetFrameInterface());
+ GetDispatcher()->ExecuteList(SID_TIPOFTHEDAY, SfxCallMode::SLOT, {}, { &aDocFrame });
+ }
// inform about the community involvement
+ const auto t0 = std::chrono::system_clock::now().time_since_epoch();
const sal_Int64 nLastGetInvolvedShown = officecfg::Setup::Product::LastTimeGetInvolvedShown::get();
const sal_Int64 nNow = std::chrono::duration_cast<std::chrono::seconds>(t0).count();
const sal_Int64 nPeriodSec(60 * 60 * 24 * 180); // 180 days in seconds