Kaydet (Commit) c3fa7a82 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

Implement infobar encouraging the community involvement.

Change-Id: I06128ed7d28d17fa9a395878efaef4b890f5dbe0
Reviewed-on: https://gerrit.libreoffice.org/55760
Tested-by: Jenkins
Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst 29dd763d
......@@ -243,6 +243,8 @@
#define STR_QUERY_OPENASTEMPLATE_OPEN_BTN NC_("STR_QUERY_OPENASTEMPLATE_OPEN_BTN", "~Open")
#define STR_REPAIREDDOCUMENT NC_("STR_REPAIREDDOCUMENT", " (repaired document)")
#define STR_NONCHECKEDOUT_DOCUMENT NC_("STR_NONCHECKEDOUT_DOCUMENT", "This document is not checked out on the server.")
#define STR_GET_INVOLVED_TEXT NC_("STR_GET_INVOLVED_TEXT", "Help us make %PRODUCTNAME even better!")
#define STR_GET_INVOLVED_BUTTON NC_("STR_GET_INVOLVED_BUTTON", "Get involved")
#define STR_READONLY_DOCUMENT NC_("STR_READONLY_DOCUMENT", "This document is open in read-only mode.")
#define STR_READONLY_PDF NC_("STR_READONLY_PDF", "This PDF is open in read-only mode to allow signing the existing file.")
#define STR_CLASSIFIED_DOCUMENT NC_("STR_CLASSIFIED_DOCUMENT", "The classification label of this document is %1.")
......
......@@ -76,7 +76,8 @@ private:
protected:
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
DECL_LINK( SwitchReadOnlyHandler, Button*, void );
DECL_LINK(GetInvolvedHandler, Button*, void);
DECL_LINK(SwitchReadOnlyHandler, Button*, void);
DECL_LINK(SignDocumentHandler, Button*, void);
SAL_DLLPRIVATE void KillDispatcher_Impl();
......
......@@ -289,6 +289,12 @@
<!-- JB: Empty default inserted into empty property node. Remove if NIL
was intended -->
</prop>
<prop oor:name="LastTimeGetInvolvedShown" oor:type="xs:long" oor:nillable="false">
<info>
<desc>The last time when the Get Involved infobar was shown.</desc>
</info>
<value>0</value>
</prop>
</group>
<group oor:name="Office">
<!--The default must be written by the setup.-->
......
......@@ -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>
......@@ -105,6 +106,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>
......@@ -1213,6 +1215,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() &&
......@@ -1335,6 +1366,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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment