diff options
author | Jan Holesovsky <kendy@collabora.com> | 2018-06-13 16:25:47 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-06-15 23:12:39 +0200 |
commit | 5e58b203e03fbcf6ca1399954bc01871474c973e (patch) | |
tree | 1c068e232dc01028533b4489c11e2413230d4968 /sfx2 | |
parent | 0484c8f68cc870a507ce716edfe4ee3407f3e701 (diff) |
Implement infobar encouraging the community involvement.
Change-Id: I06128ed7d28d17fa9a395878efaef4b890f5dbe0
Reviewed-on: https://gerrit.libreoffice.org/55760
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
(cherry picked from commit c3fa7a82b7657b00f30394df59e2ffc610350686)
Reviewed-on: https://gerrit.libreoffice.org/55880
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 16634c0dd5e2..4c37fa546543 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -30,6 +30,7 @@ #include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> #include <officecfg/Office/Common.hxx> +#include <officecfg/Setup.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/splitwin.hxx> #include <unotools/moduleoptions.hxx> @@ -106,6 +107,7 @@ using ::com::sun::star::container::XIndexContainer; #include <sfx2/objface.hxx> #include <openflag.hxx> #include <objshimp.hxx> +#include <openuriexternally.hxx> #include <sfx2/viewsh.hxx> #include <sfx2/objsh.hxx> #include <sfx2/bindings.hxx> @@ -1214,6 +1216,35 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) rBind.Invalidate( SID_RELOAD ); rBind.Invalidate( SID_EDITDOC ); + // inform about the community involvement + const sal_Int64 nLastShown = 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 * 30); // 30 days in seconds + bool bUpdateLastTimeGetInvolvedShown = false; + + if (nLastShown == 0) + bUpdateLastTimeGetInvolvedShown = true; + else if (nPeriodSec < nNow && nLastShown < nNow - nPeriodSec) + { + bUpdateLastTimeGetInvolvedShown = true; + + VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar("getinvolved", SfxResId(STR_GET_INVOLVED_TEXT), InfoBarType::Info); + + VclPtrInstance<PushButton> xGetInvolvedButton(&GetWindow()); + xGetInvolvedButton->SetText(SfxResId(STR_GET_INVOLVED_BUTTON)); + xGetInvolvedButton->SetSizePixel(xGetInvolvedButton->GetOptimalSize()); + xGetInvolvedButton->SetClickHdl(LINK(this, SfxViewFrame, GetInvolvedHandler)); + pInfoBar->addButton(xGetInvolvedButton); + } + + if (bUpdateLastTimeGetInvolvedShown) + { + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); + officecfg::Setup::Product::LastTimeGetInvolvedShown::set(nNow, batch); + batch->commit(); + } + + // read-only infobar if necessary const SfxViewShell *pVSh; const SfxShell *pFSh; if ( m_xObjSh->IsReadOnly() && @@ -1336,6 +1367,17 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } } +IMPL_LINK_NOARG(SfxViewFrame, GetInvolvedHandler, Button*, void) +{ + try + { + sfx2::openUriExternally("https://tdf.io/joinus", false); + } + catch (const Exception&) + { + } +} + IMPL_LINK(SfxViewFrame, SwitchReadOnlyHandler, Button*, pButton, void) { if (m_xObjSh.is() && IsSignPDF(m_xObjSh)) |