diff options
author | Diadlo <polsha3@gmail.com> | 2018-05-23 09:39:41 +0300 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-06-06 12:54:58 +0200 |
commit | 92026741ed7e83119f1de51528480c5a937c0e88 (patch) | |
tree | b47751c81013684e3f8cc5f2fe665950ec9fc74a | |
parent | a5bae14bc3ae4fd1d0bd3bf72c5a6151d1ccf762 (diff) |
tdf#37336 Added Apply button in options dialog
Change-Id: Ibdcad8101fbd4a0344fb82d3e5d03774d1b125dc
Reviewed-on: https://gerrit.libreoffice.org/54980
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r-- | cui/source/inc/treeopt.hxx | 4 | ||||
-rw-r--r-- | cui/source/options/treeopt.cxx | 65 | ||||
-rw-r--r-- | cui/uiconfig/ui/optionsdialog.ui | 17 |
3 files changed, 64 insertions, 22 deletions
diff --git a/cui/source/inc/treeopt.hxx b/cui/source/inc/treeopt.hxx index 032e432bfc05..1def2d942eb4 100644 --- a/cui/source/inc/treeopt.hxx +++ b/cui/source/inc/treeopt.hxx @@ -122,6 +122,7 @@ class OfaTreeOptionsDialog final: public SfxModalDialog { private: VclPtr<OKButton> pOkPB; + VclPtr<PushButton> pApplyPB; VclPtr<PushButton> pBackPB; VclPtr<SvTreeListBox> pTreeLB; @@ -161,9 +162,12 @@ private: static VectorOfNodes LoadNodes( Module* pModule, const OUString& rExtensionId ); void InsertNodes( const VectorOfNodes& rNodeList ); + void ApplyOptions( bool deactivate ); + DECL_STATIC_LINK(OfaTreeOptionsDialog, ExpandedHdl_Impl, SvTreeListBox*, void ); DECL_LINK(ShowPageHdl_Impl, SvTreeListBox*, void); DECL_LINK(BackHdl_Impl, Button*, void); + DECL_LINK(ApplyHdl_Impl, Button*, void); DECL_LINK(OKHdl_Impl, Button*, void); void SelectHdl_Impl(); diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index 7a177f2733ad..1a1b0671fa1c 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -490,6 +490,7 @@ struct OptionsGroupInfo void OfaTreeOptionsDialog::InitWidgets() { get(pOkPB, "ok"); + get(pApplyPB, "apply"); get(pBackPB, "revert"); get(pTreeLB, "pages"); get(pTabBox, "box"); @@ -601,6 +602,7 @@ void OfaTreeOptionsDialog::dispose() deleteGroupNames(); m_pParent.clear(); pOkPB.clear(); + pApplyPB.clear(); pBackPB.clear(); pTreeLB.clear(); pTabBox.clear(); @@ -660,6 +662,46 @@ IMPL_LINK_NOARG(OfaTreeOptionsDialog, BackHdl_Impl, Button*, void) } } +void OfaTreeOptionsDialog::ApplyOptions(bool deactivate) +{ + SvTreeListEntry* pEntry = pTreeLB->First(); + while ( pEntry ) + { + if ( pTreeLB->GetParent( pEntry ) ) + { + OptionsPageInfo* pPageInfo = static_cast<OptionsPageInfo *>(pEntry->GetUserData()); + if ( pPageInfo->m_pPage && !pPageInfo->m_pPage->HasExchangeSupport() ) + { + OptionsGroupInfo* pGroupInfo = + static_cast<OptionsGroupInfo*>(pTreeLB->GetParent(pEntry)->GetUserData()); + pPageInfo->m_pPage->FillItemSet(pGroupInfo->m_pOutItemSet.get()); + } + + if ( pPageInfo->m_pExtPage ) + { + if ( deactivate ) + { + pPageInfo->m_pExtPage->DeactivatePage(); + } + pPageInfo->m_pExtPage->SavePage(); + } + } + pEntry = pTreeLB->Next(pEntry); + } +} + +IMPL_LINK_NOARG(OfaTreeOptionsDialog, ApplyHdl_Impl, Button*, void) +{ + ApplyOptions(/*deactivate =*/false); + + if ( bNeedsRestart ) + { + SolarMutexGuard aGuard; + ::svtools::executeRestartDialog(comphelper::getProcessComponentContext(), + m_pParent->GetFrameWeld(), eRestartReason); + } +} + IMPL_LINK_NOARG(OfaTreeOptionsDialog, OKHdl_Impl, Button*, void) { pTreeLB->EndSelection(); @@ -685,27 +727,7 @@ IMPL_LINK_NOARG(OfaTreeOptionsDialog, OKHdl_Impl, Button*, void) } } - SvTreeListEntry* pEntry = pTreeLB->First(); - while ( pEntry ) - { - if ( pTreeLB->GetParent( pEntry ) ) - { - OptionsPageInfo* pPageInfo = static_cast<OptionsPageInfo *>(pEntry->GetUserData()); - if ( pPageInfo->m_pPage && !pPageInfo->m_pPage->HasExchangeSupport() ) - { - OptionsGroupInfo* pGroupInfo = - static_cast<OptionsGroupInfo*>(pTreeLB->GetParent(pEntry)->GetUserData()); - pPageInfo->m_pPage->FillItemSet(pGroupInfo->m_pOutItemSet.get()); - } - - if ( pPageInfo->m_pExtPage ) - { - pPageInfo->m_pExtPage->DeactivatePage(); - pPageInfo->m_pExtPage->SavePage(); - } - } - pEntry = pTreeLB->Next(pEntry); - } + ApplyOptions(/*deactivate =*/ true); EndDialog(RET_OK); if ( bNeedsRestart ) @@ -787,6 +809,7 @@ void OfaTreeOptionsDialog::InitTreeAndHandler() pTreeLB->SetExpandedHdl( LINK( this, OfaTreeOptionsDialog, ExpandedHdl_Impl ) ); pTreeLB->SetSelectHdl( LINK( this, OfaTreeOptionsDialog, ShowPageHdl_Impl ) ); pBackPB->SetClickHdl( LINK( this, OfaTreeOptionsDialog, BackHdl_Impl ) ); + pApplyPB->SetClickHdl( LINK( this, OfaTreeOptionsDialog, ApplyHdl_Impl ) ); pOkPB->SetClickHdl( LINK( this, OfaTreeOptionsDialog, OKHdl_Impl ) ); } diff --git a/cui/uiconfig/ui/optionsdialog.ui b/cui/uiconfig/ui/optionsdialog.ui index ab57141d278d..fe2890ca8249 100644 --- a/cui/uiconfig/ui/optionsdialog.ui +++ b/cui/uiconfig/ui/optionsdialog.ui @@ -116,6 +116,21 @@ </packing> </child> <child> + <object class="GtkButton" id="apply"> + <property name="label">gtk-apply</property> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + <child> <object class="GtkButton" id="revert"> <property name="label">gtk-revert-to-saved</property> <property name="use_action_appearance">False</property> @@ -127,7 +142,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">3</property> + <property name="position">4</property> </packing> </child> </object> |