diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-04-14 10:16:48 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-04-14 10:27:09 +0100 |
commit | 6f20cb94640224c47efa0a9de8ee757260ba3771 (patch) | |
tree | 25e9b4a55349ccb12b1974a4d423c005adcc8d61 /sfx2 | |
parent | 3e535baddc534fbb183d763b3a70f457117ceb83 (diff) |
convert style context menu to .ui
Change-Id: Ie72a1ecb91ddbbf2230ff2a56e361af98898d730
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/UIConfig_sfx.mk | 1 | ||||
-rw-r--r-- | sfx2/source/dialog/dialog.hrc | 8 | ||||
-rw-r--r-- | sfx2/source/dialog/dialog.src | 34 | ||||
-rw-r--r-- | sfx2/source/dialog/templdlg.cxx | 43 | ||||
-rw-r--r-- | sfx2/source/inc/helpid.hrc | 3 | ||||
-rw-r--r-- | sfx2/source/inc/templdgi.hxx | 3 | ||||
-rw-r--r-- | sfx2/uiconfig/ui/stylecontextmenu.ui | 49 |
7 files changed, 76 insertions, 65 deletions
diff --git a/sfx2/UIConfig_sfx.mk b/sfx2/UIConfig_sfx.mk index ecb8c62b9e55..c976d89369cd 100644 --- a/sfx2/UIConfig_sfx.mk +++ b/sfx2/UIConfig_sfx.mk @@ -49,6 +49,7 @@ $(eval $(call gb_UIConfig_add_uifiles,sfx,\ sfx2/uiconfig/ui/securityinfopage \ sfx2/uiconfig/ui/singletabdialog \ sfx2/uiconfig/ui/startcenter \ + sfx2/uiconfig/ui/stylecontextmenu \ sfx2/uiconfig/ui/templatedlg \ sfx2/uiconfig/ui/saveastemplatedlg \ sfx2/uiconfig/ui/templatecategorydlg \ diff --git a/sfx2/source/dialog/dialog.hrc b/sfx2/source/dialog/dialog.hrc index 4c93cbfdedf1..fc3e67ea53ab 100644 --- a/sfx2/source/dialog/dialog.hrc +++ b/sfx2/source/dialog/dialog.hrc @@ -24,12 +24,6 @@ // defines --------------------------------------------------------------- -#define ID_NEW 1 -#define ID_EDIT 2 -#define ID_DELETE 3 -#define ID_HIDE 4 -#define ID_SHOW 5 - #define RC_DIALOG_BEGIN RID_SFX_DIALOG_START #define STR_RESET ( RC_DIALOG_BEGIN + 0) @@ -42,8 +36,6 @@ #define STR_DELETE_STYLE ( RC_DIALOG_BEGIN + 19) #define STR_DELETE_STYLE_USED ( RC_DIALOG_BEGIN + 20) -#define MN_CONTEXT_TEMPLDLG ( RC_DIALOG_BEGIN + 46) - #define STR_VIEWVERSIONCOMMENT ( RC_DIALOG_BEGIN + 71 ) #define STR_NO_NAME_SET ( RC_DIALOG_BEGIN + 72 ) diff --git a/sfx2/source/dialog/dialog.src b/sfx2/source/dialog/dialog.src index 42cedfa0aee5..27600db38fde 100644 --- a/sfx2/source/dialog/dialog.src +++ b/sfx2/source/dialog/dialog.src @@ -50,40 +50,6 @@ String STR_DELETE_STYLE { Text [ en-US ] = "Styles in use: " ; }; -Menu MN_CONTEXT_TEMPLDLG -{ - ItemList = - { - MenuItem - { - Identifier = ID_NEW ; - Text [ en-US ] = "New..." ; - HelpId = HID_STYLIST_NEW ; - }; - MenuItem - { - Identifier = ID_EDIT ; - Text [ en-US ] = "Modify..." ; - HelpId = HID_STYLIST_EDIT ; - }; - MenuItem - { - Identifier = ID_HIDE ; - Text [ en-US ] = "Hide" ; - }; - MenuItem - { - Identifier = ID_SHOW ; - Text [ en-US ] = "Show" ; - }; - MenuItem - { - Identifier = ID_DELETE ; - Text [ en-US ] = "Delete..." ; - HelpId = HID_STYLIST_DELETE ; - }; - }; -}; String SID_NAVIGATOR { diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 3547bc006271..af4ee87f3c6f 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -169,8 +169,6 @@ void StyleLBoxString::Paint( #define SFX_TEMPLDLG_MIDVSPACE 3 #define SFX_TEMPLDLG_FILTERHEIGHT 100 -static sal_uInt16 nLastItemId = USHRT_MAX; - // filter box has maximum 14 entries visible #define MAX_FILTER_ENTRIES 14 @@ -2088,7 +2086,7 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, FmtSelectHdl, SvTreeListBox *, pListBox IMPL_LINK( SfxCommonTemplateDialog_Impl, MenuSelectHdl, Menu*, pMenu, bool ) { - nLastItemId = pMenu->GetCurItemId(); + sLastItemIdent = pMenu->GetCurItemIdent(); Application::PostUserEvent( LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectAsyncHdl ) ); return true; @@ -2096,13 +2094,16 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, MenuSelectHdl, Menu*, pMenu, bool ) IMPL_LINK_NOARG( SfxCommonTemplateDialog_Impl, MenuSelectAsyncHdl, void*, void ) { - switch(nLastItemId) { - case ID_NEW: NewHdl(); break; - case ID_EDIT: EditHdl(); break; - case ID_DELETE: DeleteHdl(); break; - case ID_HIDE: HideHdl(); break; - case ID_SHOW: ShowHdl(); break; - } + if (sLastItemIdent == "new") + NewHdl(); + else if (sLastItemIdent == "edit") + EditHdl(); + else if (sLastItemIdent == "delete") + DeleteHdl(); + else if (sLastItemIdent == "hide") + HideHdl(); + else if (sLastItemIdent == "show") + ShowHdl(); } SfxStyleFamily SfxCommonTemplateDialog_Impl::GetActualFamily() const @@ -2133,22 +2134,24 @@ VclPtr<PopupMenu> SfxCommonTemplateDialog_Impl::CreateContextMenu() pBindings->Update( SID_STYLE_NEW ); bBindingUpdate = false; } - VclPtr<PopupMenu> pMenu = VclPtr<PopupMenu>::Create( SfxResId( MN_CONTEXT_TEMPLDLG ) ); - pMenu->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectHdl ) ); - pMenu->EnableItem( ID_EDIT, bCanEdit ); - pMenu->EnableItem( ID_DELETE, bCanDel ); - pMenu->EnableItem( ID_NEW, bCanNew ); - pMenu->EnableItem( ID_HIDE, bCanHide ); - pMenu->EnableItem( ID_SHOW, bCanShow ); + mxMenu.disposeAndClear(); + mxBuilder.reset(new VclBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "sfx/ui/stylecontextmenu.ui", "")); + mxMenu.set(mxBuilder->get_menu("menu")); + mxMenu->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectHdl ) ); + mxMenu->EnableItem(mxMenu->GetItemId("edit"), bCanEdit); + mxMenu->EnableItem(mxMenu->GetItemId("delete"), bCanDel); + mxMenu->EnableItem(mxMenu->GetItemId("new"), bCanNew); + mxMenu->EnableItem(mxMenu->GetItemId("hide"), bCanHide); + mxMenu->EnableItem(mxMenu->GetItemId("show"), bCanShow); const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl(); if (pItem && pItem->GetFamily() == SfxStyleFamily::Table) //tdf#101648, no ui for this yet { - pMenu->EnableItem(ID_EDIT, false); - pMenu->EnableItem(ID_NEW, false); + mxMenu->EnableItem(mxMenu->GetItemId("edit"), false); + mxMenu->EnableItem(mxMenu->GetItemId("new"), false); } - return pMenu; + return mxMenu; } static OUString lcl_GetLabel(uno::Any& rAny) diff --git a/sfx2/source/inc/helpid.hrc b/sfx2/source/inc/helpid.hrc index 70f21bf2ee70..f580d851ebde 100644 --- a/sfx2/source/inc/helpid.hrc +++ b/sfx2/source/inc/helpid.hrc @@ -30,9 +30,6 @@ #define HID_TABDLG_RESET_BTN "SFX2_HID_TABDLG_RESET_BTN" #define HID_TABDLG_STANDARD_BTN "SFX2_HID_TABDLG_STANDARD_BTN" #define HID_TEMPLDLG_TOOLBOX_LEFT "SFX2_HID_TEMPLDLG_TOOLBOX_LEFT" -#define HID_STYLIST_NEW "SFX2_HID_STYLIST_NEW" -#define HID_STYLIST_EDIT "SFX2_HID_STYLIST_EDIT" -#define HID_STYLIST_DELETE "SFX2_HID_STYLIST_DELETE" #define HID_HELP_WINDOW "SFX2_HID_HELP_WINDOW" #define HID_HELP_TOOLBOX "SFX2_HID_HELP_TOOLBOX" #define HID_HELP_TOOLBOXITEM_INDEX "SFX2_HID_HELP_TOOLBOXITEM_INDEX" diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx index 3af5440d0b3c..90c0e6ba82ea 100644 --- a/sfx2/source/inc/templdgi.hxx +++ b/sfx2/source/inc/templdgi.hxx @@ -172,6 +172,9 @@ protected: SfxTemplateControllerItem* pBoundItems[COUNT_BOUND_FUNC]; VclPtr<vcl::Window> pWindow; + std::unique_ptr<VclBuilder> mxBuilder; + VclPtr<PopupMenu> mxMenu; + OString sLastItemIdent; SfxModule* pModule; Idle* pIdle; diff --git a/sfx2/uiconfig/ui/stylecontextmenu.ui b/sfx2/uiconfig/ui/stylecontextmenu.ui new file mode 100644 index 000000000000..da524cf902b4 --- /dev/null +++ b/sfx2/uiconfig/ui/stylecontextmenu.ui @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.0 --> +<interface> + <requires lib="gtk+" version="3.10"/> + <object class="GtkMenu" id="menu"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkMenuItem" id="new"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">New...</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="edit"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Modify...</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="hide"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Hide</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="show"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Show</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="delete"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Delete...</property> + <property name="use_underline">True</property> + </object> + </child> + </object> +</interface> |