[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - include/sfx2 officecfg/registry sfx2/source

Jan Holesovsky kendy at collabora.com
Fri Jun 15 21:13:04 UTC 2018


 include/sfx2/strings.hrc                           |    2 +
 include/sfx2/viewfrm.hxx                           |    3 +
 officecfg/registry/schema/org/openoffice/Setup.xcs |    6 +++
 sfx2/source/view/viewfrm.cxx                       |   42 +++++++++++++++++++++
 4 files changed, 52 insertions(+), 1 deletion(-)

New commits:
commit 5e58b203e03fbcf6ca1399954bc01871474c973e
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jun 13 16:25:47 2018 +0200

    Implement infobar encouraging the community involvement.
    
    Change-Id: I06128ed7d28d17fa9a395878efaef4b890f5dbe0
    Reviewed-on: https://gerrit.libreoffice.org/55760
    Tested-by: Jenkins
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    (cherry picked from commit c3fa7a82b7657b00f30394df59e2ffc610350686)
    Reviewed-on: https://gerrit.libreoffice.org/55880
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index 325cc509e2e7..6d871b648d4f 100644
--- a/include/sfx2/strings.hrc
+++ b/include/sfx2/strings.hrc
@@ -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.")
diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx
index ef3892b3e30d..3fafd9e1762d 100644
--- a/include/sfx2/viewfrm.hxx
+++ b/include/sfx2/viewfrm.hxx
@@ -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();
 
diff --git a/officecfg/registry/schema/org/openoffice/Setup.xcs b/officecfg/registry/schema/org/openoffice/Setup.xcs
index 31db1eca9af4..3adfefa2d1fd 100644
--- a/officecfg/registry/schema/org/openoffice/Setup.xcs
+++ b/officecfg/registry/schema/org/openoffice/Setup.xcs
@@ -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.-->
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))


More information about the Libreoffice-commits mailing list