[Libreoffice-commits] core.git: include/vcl sd/uiconfig vcl/source

Szymon Kłos eszkadev at gmail.com
Fri Jul 22 15:35:58 UTC 2016


 include/vcl/tabctrl.hxx                |    1 +
 sd/uiconfig/simpress/ui/notebookbar.ui |    4 ++++
 vcl/source/control/tabctrl.cxx         |   17 ++++++++++++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit d7da58ae362b661c03fc754e4e8f4a89798b0127
Author: Szymon Kłos <eszkadev at gmail.com>
Date:   Fri Jul 22 11:50:57 2016 +0200

    GSoC notebookbar: better default page handling
    
    + selected default tab page in the Impress
    + the default tab page is set when context isn't supported
    + switching between unsupported contexts is not causing
      switch to default tab to avoid closing of tab which was
      recently used by user
    
    Change-Id: Ieeda8a79e6c67708551351f9bb49d8b006c0e74f
    Reviewed-on: https://gerrit.libreoffice.org/27432
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx
index 14974e7..5b26c83 100644
--- a/include/vcl/tabctrl.hxx
+++ b/include/vcl/tabctrl.hxx
@@ -213,6 +213,7 @@ protected:
     virtual void ImplPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
 
 private:
+    bool bLastContextWasSupported;
     vcl::EnumContext::Context eLastContext;
     Link<NotebookBar*,void> m_aIconClickHdl;
 };
diff --git a/sd/uiconfig/simpress/ui/notebookbar.ui b/sd/uiconfig/simpress/ui/notebookbar.ui
index dd6c0ea..bd081e6 100644
--- a/sd/uiconfig/simpress/ui/notebookbar.ui
+++ b/sd/uiconfig/simpress/ui/notebookbar.ui
@@ -1476,6 +1476,10 @@
                 <property name="can_focus">False</property>
                 <property name="label" translatable="yes">Home</property>
                 <property name="use_underline">True</property>
+                <style>
+                  <class name="context-default"/>
+                  <class name="context-any"/>
+                </style>
               </object>
               <packing>
                 <property name="position">1</property>
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 93b3b20..9441dea 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -2205,7 +2205,8 @@ VCL_BUILDER_FACTORY(NotebookbarTabControl);
 
 NotebookbarTabControl::NotebookbarTabControl(vcl::Window* pParent, WinBits nStyle)
     : TabControl(pParent, nStyle)
-    , eLastContext( vcl::EnumContext::Context::Context_Any )
+    , bLastContextWasSupported(true)
+    , eLastContext(vcl::EnumContext::Context::Context_Any)
 {
     LanguageTag aLocale( Application::GetSettings().GetUILanguageTag());
     ResMgr* pResMgr = ResMgr::SearchCreateResMgr( "vcl", aLocale );
@@ -2222,6 +2223,8 @@ void NotebookbarTabControl::SetContext( vcl::EnumContext::Context eContext )
 {
     if (eLastContext != eContext)
     {
+        bool bHandled = false;
+
         for (int nChild = 0; nChild < GetChildCount(); ++nChild)
         {
             TabPage* pPage = static_cast<TabPage*>(GetChild(nChild));
@@ -2231,10 +2234,22 @@ void NotebookbarTabControl::SetContext( vcl::EnumContext::Context eContext )
             else
                 EnablePage(nChild + 2, false);
 
+            if (!bHandled && bLastContextWasSupported
+                && pPage->HasContext(vcl::EnumContext::Context::Context_Default))
+            {
+                SetCurPageId(nChild + 2);
+            }
+
             if (pPage->HasContext(eContext) && eContext != vcl::EnumContext::Context::Context_Any)
+            {
                 SetCurPageId(nChild + 2);
+                bHandled = true;
+                bLastContextWasSupported = true;
+            }
         }
 
+        if (!bHandled)
+            bLastContextWasSupported = false;
         eLastContext = eContext;
     }
 }


More information about the Libreoffice-commits mailing list