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@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
This commit is contained in:
Szymon Kłos
2016-07-22 11:50:57 +02:00
committed by Samuel Mehrbrodt
parent b920fa5e90
commit d7da58ae36
3 changed files with 22 additions and 2 deletions

View File

@@ -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;
};

View File

@@ -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>

View File

@@ -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 (pPage->HasContext(eContext) && eContext != vcl::EnumContext::Context::Context_Any)
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;
}
}