diff options
author | heiko tietze <tietze.heiko@gmail.com> | 2018-11-23 14:00:00 +0100 |
---|---|---|
committer | Heiko Tietze <tietze.heiko@gmail.com> | 2018-12-04 10:59:49 +0100 |
commit | 7f38b5829c16f979268959272922e5ff86802da8 (patch) | |
tree | 5ce0dd5faa5bbd47191e239963d9a0a6d32757b4 /sfx2 | |
parent | 5f6b5c98dd1d46b09ad02111c2884a195c053223 (diff) |
Infobar showing donation alternating with getinvolved
Change-Id: Ia103201667c3469071f19450589bd22faf3ae80e
Reviewed-on: https://gerrit.libreoffice.org/63883
Reviewed-by: Heiko Tietze <tietze.heiko@gmail.com>
Tested-by: Heiko Tietze <tietze.heiko@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 8463b2366fbb..61cb945c738a 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1217,14 +1217,14 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) rBind.Invalidate( SID_EDITDOC ); // inform about the community involvement - const sal_Int64 nLastShown = officecfg::Setup::Product::LastTimeGetInvolvedShown::get(); + const sal_Int64 nLastGetInvolvedShown = officecfg::Setup::Product::LastTimeGetInvolvedShown::get(); const sal_Int64 nNow = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count(); const sal_Int64 nPeriodSec(60 * 60 * 24 * 180); // 180 days in seconds bool bUpdateLastTimeGetInvolvedShown = false; - if (nLastShown == 0) + if (nLastGetInvolvedShown == 0) bUpdateLastTimeGetInvolvedShown = true; - else if (nPeriodSec < nNow && nLastShown < nNow - nPeriodSec) + else if (nPeriodSec < nNow && nLastGetInvolvedShown < (nNow + nPeriodSec/2) - nPeriodSec) // 90d alternating with donation { bUpdateLastTimeGetInvolvedShown = true; @@ -1245,6 +1245,33 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) batch->commit(); } + // inform about donations + const sal_Int64 nLastDonateShown = officecfg::Setup::Product::LastTimeDonateShown::get(); + bool bUpdateLastTimeDonateShown = false; + + if (nLastDonateShown == 0) + bUpdateLastTimeDonateShown = true; + else if (nPeriodSec < nNow && nLastDonateShown < nNow - nPeriodSec) // 90d alternating with getinvolved + { + bUpdateLastTimeDonateShown = true; + + VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar("getdonate", SfxResId(STR_GET_DONATE_TEXT), InfoBarType::Info); + + VclPtrInstance<PushButton> xGetDonateButton(&GetWindow()); + xGetDonateButton->SetText(SfxResId(STR_GET_DONATE_BUTTON)); + xGetDonateButton->SetSizePixel(xGetDonateButton->GetOptimalSize()); + xGetDonateButton->SetClickHdl(LINK(this, SfxViewFrame, GetDonateHandler)); + pInfoBar->addButton(xGetDonateButton); + } + + 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(); + } + // read-only infobar if necessary const SfxViewShell *pVSh; const SfxShell *pFSh; @@ -1373,6 +1400,11 @@ IMPL_LINK_NOARG(SfxViewFrame, GetInvolvedHandler, Button*, void) GetDispatcher()->Execute(SID_GETINVOLVED); } +IMPL_LINK_NOARG(SfxViewFrame, GetDonateHandler, Button*, void) +{ + GetDispatcher()->Execute(SID_DONATION); +} + IMPL_LINK(SfxViewFrame, SwitchReadOnlyHandler, Button*, pButton, void) { if (m_xObjSh.is() && IsSignPDF(m_xObjSh)) |