summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorHeiko Tietze <tietze.heiko@gmail.com>2024-02-28 10:30:48 +0100
committerAndras Timar <andras.timar@collabora.com>2024-03-07 13:54:19 +0100
commit53f0a6d50ae42b9a2df1ce4901084dda57237a28 (patch)
tree11fad969e05cf82d258f1cdaa30263f2ec6ec431 /sfx2
parent12182a4ea33f67db2547c3829ed2dbb01d0b5c12 (diff)
Resolves tdf#131550 - Suppress Donate/Involve infobar if another is visible
Change-Id: I013f0a1f0aa020f10d6beb21940959508eba4547 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164082 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org> (cherry picked from commit 607740654f2264e13469e4da1d020448217d7222) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164114 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/view/viewfrm.cxx117
1 files changed, 93 insertions, 24 deletions
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index e5252a4afa28..90a9cc05c301 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -1496,31 +1496,8 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
rBind.Invalidate( SID_RELOAD );
rBind.Invalidate( SID_EDITDOC );
-#if !ENABLE_WASM_STRIP_PINGUSER
- bool bIsHeadlessOrUITest = SfxApplication::IsHeadlessOrUITest(); //uitest.uicheck fails when the dialog is open
-
- //what's new infobar
- if (utl::isProductVersionUpgraded(true) && !bIsHeadlessOrUITest)
- {
- VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar("whatsnew", "", SfxResId(STR_WHATSNEW_TEXT), InfobarType::INFO);
- if (pInfoBar)
- {
- weld::Button& rWhatsNewButton = pInfoBar->addButton();
- rWhatsNewButton.set_label(SfxResId(STR_WHATSNEW_BUTTON));
- rWhatsNewButton.connect_clicked(LINK(this, SfxViewFrame, WhatsNewHandler));
- }
- }
-
- // 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 });
- }
+ bool bIsInfobarShown(false);
-#endif
if (officecfg::Office::Common::Passwords::HasMaster::get() &&
officecfg::Office::Common::Passwords::StorageVersion::get() == 0)
{
@@ -1528,6 +1505,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
VclPtr<SfxInfoBarWindow> pOldMasterPasswordInfoBar =
AppendInfoBar("oldmasterpassword", "",
SfxResId(STR_REFRESH_MASTER_PASSWORD), InfobarType::DANGER, false);
+ bIsInfobarShown = true;
if (pOldMasterPasswordInfoBar)
{
weld::Button& rButton = pOldMasterPasswordInfoBar->addButton();
@@ -1542,6 +1520,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
}
}
}
+
const bool bEmbedded = m_xObjSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED;
// read-only infobar if necessary
@@ -1553,10 +1532,14 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
(( pVSh = m_xObjSh->GetViewShell()) && (pFSh = pVSh->GetFormShell()) && pFSh->IsDesignMode())))
{
AppendReadOnlyInfobar();
+ bIsInfobarShown = true;
}
if (!bEmbedded && m_xObjSh->Get_Impl()->getCurrentMacroExecMode() == css::document::MacroExecMode::NEVER_EXECUTE)
+ {
AppendContainsMacrosInfobar();
+ bIsInfobarShown = true;
+ }
if (vcl::CommandInfoProvider::GetModuleIdentifier(GetFrame().GetFrameInterface()) == "com.sun.star.text.TextDocument")
sfx2::SfxNotebookBar::ReloadNotebookBar(u"modules/swriter/ui/");
@@ -1597,6 +1580,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
AppendInfoBar(aInfobarData.msId, aInfobarData.msPrimaryMessage,
aInfobarData.msSecondaryMessage, aInfobarData.maInfobarType,
aInfobarData.mbShowCloseButton);
+ bIsInfobarShown = true;
// tdf#148913 don't extend this condition to keep it thread-safe
if (pInfoBar)
@@ -1622,11 +1606,96 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
AppendInfoBar(aInfobarData.msId, aInfobarData.msPrimaryMessage,
aInfobarData.msSecondaryMessage, aInfobarData.maInfobarType,
aInfobarData.mbShowCloseButton);
+ bIsInfobarShown = true;
}
aPendingInfobars.pop_back();
}
+#if !ENABLE_WASM_STRIP_PINGUSER
+ bool bIsHeadlessOrUITest = SfxApplication::IsHeadlessOrUITest(); //uitest.uicheck fails when the dialog is open
+
+ //what's new infobar
+ if (!bIsInfobarShown && utl::isProductVersionUpgraded(true) && !bIsHeadlessOrUITest)
+ {
+ VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar("whatsnew", "", SfxResId(STR_WHATSNEW_TEXT), InfobarType::INFO);
+ bIsInfobarShown = true;
+ if (pInfoBar)
+ {
+ weld::Button& rWhatsNewButton = pInfoBar->addButton();
+ rWhatsNewButton.set_label(SfxResId(STR_WHATSNEW_BUTTON));
+ rWhatsNewButton.connect_clicked(LINK(this, SfxViewFrame, WhatsNewHandler));
+ }
+ }
+
+ // 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
+ bool bUpdateLastTimeGetInvolvedShown = false;
+
+ if (nLastGetInvolvedShown == 0)
+ bUpdateLastTimeGetInvolvedShown = true;
+ else if (!bIsInfobarShown && nPeriodSec < nNow && nLastGetInvolvedShown < (nNow + nPeriodSec/2) - nPeriodSec) // 90d alternating with donation
+ {
+ bUpdateLastTimeGetInvolvedShown = true;
+
+ VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar("getinvolved", "", SfxResId(STR_GET_INVOLVED_TEXT), InfobarType::INFO);
+ bIsInfobarShown = true;
+ if (pInfoBar)
+ {
+ weld::Button& rGetInvolvedButton = pInfoBar->addButton();
+ rGetInvolvedButton.set_label(SfxResId(STR_GET_INVOLVED_BUTTON));
+ rGetInvolvedButton.connect_clicked(LINK(this, SfxViewFrame, GetInvolvedHandler));
+ }
+ }
+
+ if (bUpdateLastTimeGetInvolvedShown
+ && !officecfg::Setup::Product::LastTimeGetInvolvedShown::isReadOnly())
+ {
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
+ officecfg::Setup::Product::LastTimeGetInvolvedShown::set(nNow, batch);
+ batch->commit();
+ }
+
+ // inform about donations
+ const sal_Int64 nLastDonateShown = officecfg::Setup::Product::LastTimeDonateShown::get();
+ bool bUpdateLastTimeDonateShown = false;
+
+ if (nLastDonateShown == 0)
+ bUpdateLastTimeDonateShown = true;
+ else if (!bIsInfobarShown && nPeriodSec < nNow && nLastDonateShown < nNow - nPeriodSec) // 90d alternating with getinvolved
+ {
+ bUpdateLastTimeDonateShown = true;
+
+ VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar("donate", "", SfxResId(STR_DONATE_TEXT), InfobarType::INFO);
+ if (pInfoBar)
+ {
+ weld::Button& rDonateButton = pInfoBar->addButton();
+ rDonateButton.set_label(SfxResId(STR_DONATE_BUTTON));
+ rDonateButton.connect_clicked(LINK(this, SfxViewFrame, DonationHandler));
+ }
+ }
+
+ if (bUpdateLastTimeDonateShown
+ && !officecfg::Setup::Product::LastTimeDonateShown::isReadOnly())
+ {
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
+ officecfg::Setup::Product::LastTimeDonateShown::set(nNow, batch);
+ batch->commit();
+ }
+#endif
+
break;
}
default: break;