Kaydet (Commit) 916b3e30 authored tarafından Akshay Deep's avatar Akshay Deep Kaydeden (comit) Samuel Mehrbrodt

Reset Default in Context Menu for default templates

Change-Id: Ifedb4f5b4dada0e9e0ac40ffcaed4c2821df501d
Reviewed-on: https://gerrit.libreoffice.org/25995Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
üst 397ad4d4
...@@ -124,6 +124,7 @@ protected: ...@@ -124,6 +124,7 @@ protected:
virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override; virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override;
public:
static bool IsDefaultTemplate(const OUString& rPath); static bool IsDefaultTemplate(const OUString& rPath);
protected: protected:
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
void showRegion (const OUString &rName); void showRegion (const OUString &rName);
void createContextMenu(); void createContextMenu(const bool bIsDefault );
DECL_LINK_TYPED(ContextMenuSelectHdl, Menu*, bool); DECL_LINK_TYPED(ContextMenuSelectHdl, Menu*, bool);
......
...@@ -26,6 +26,8 @@ public: ...@@ -26,6 +26,8 @@ public:
void showDefaultIcon(bool bVal) { mbIsDefaultTemplate = bVal; } void showDefaultIcon(bool bVal) { mbIsDefaultTemplate = bVal; }
bool IsDefaultTemplate() const { return mbIsDefaultTemplate; }
Rectangle getDefaultIconArea() const; Rectangle getDefaultIconArea() const;
virtual void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor, virtual void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor,
......
...@@ -178,12 +178,17 @@ TemplateContainerItem* TemplateLocalView::getRegion(OUString const & rName) ...@@ -178,12 +178,17 @@ TemplateContainerItem* TemplateLocalView::getRegion(OUString const & rName)
return nullptr; return nullptr;
} }
void TemplateLocalView::createContextMenu() void TemplateLocalView::createContextMenu(const bool bIsDefault)
{ {
std::unique_ptr<PopupMenu> pItemMenu(new PopupMenu); std::unique_ptr<PopupMenu> pItemMenu(new PopupMenu);
pItemMenu->InsertItem(MNI_OPEN,SfxResId(STR_OPEN).toString()); pItemMenu->InsertItem(MNI_OPEN,SfxResId(STR_OPEN).toString());
pItemMenu->InsertItem(MNI_EDIT,SfxResId(STR_EDIT_TEMPLATE).toString()); pItemMenu->InsertItem(MNI_EDIT,SfxResId(STR_EDIT_TEMPLATE).toString());
pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_DEFAULT_TEMPLATE).toString());
if(!bIsDefault)
pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_DEFAULT_TEMPLATE).toString());
else
pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_RESET_DEFAULT).toString());
pItemMenu->InsertSeparator(); pItemMenu->InsertSeparator();
pItemMenu->InsertItem(MNI_DELETE,SfxResId(STR_DELETE).toString()); pItemMenu->InsertItem(MNI_DELETE,SfxResId(STR_DELETE).toString());
pItemMenu->InsertItem(MNI_RENAME,SfxResId(STR_RENAME).toString()); pItemMenu->InsertItem(MNI_RENAME,SfxResId(STR_RENAME).toString());
......
...@@ -53,12 +53,17 @@ void TemplateSearchView::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -53,12 +53,17 @@ void TemplateSearchView::MouseButtonDown( const MouseEvent& rMEvt )
ThumbnailView::MouseButtonDown(rMEvt); ThumbnailView::MouseButtonDown(rMEvt);
} }
void TemplateSearchView::createContextMenu() void TemplateSearchView::createContextMenu( const bool bIsDefault)
{ {
std::unique_ptr<PopupMenu> pItemMenu(new PopupMenu); std::unique_ptr<PopupMenu> pItemMenu(new PopupMenu);
pItemMenu->InsertItem(MNI_OPEN,SfxResId(STR_OPEN).toString()); pItemMenu->InsertItem(MNI_OPEN,SfxResId(STR_OPEN).toString());
pItemMenu->InsertItem(MNI_EDIT,SfxResId(STR_EDIT_TEMPLATE).toString()); pItemMenu->InsertItem(MNI_EDIT,SfxResId(STR_EDIT_TEMPLATE).toString());
pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_DEFAULT_TEMPLATE).toString());
if(!bIsDefault)
pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_DEFAULT_TEMPLATE).toString());
else
pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_RESET_DEFAULT).toString());
pItemMenu->InsertSeparator(); pItemMenu->InsertSeparator();
pItemMenu->InsertItem(MNI_DELETE,SfxResId(STR_DELETE).toString()); pItemMenu->InsertItem(MNI_DELETE,SfxResId(STR_DELETE).toString());
maSelectedItem->setSelection(true); maSelectedItem->setSelection(true);
...@@ -141,6 +146,9 @@ void TemplateSearchView::AppendItem(sal_uInt16 nAssocItemId, sal_uInt16 nRegionI ...@@ -141,6 +146,9 @@ void TemplateSearchView::AppendItem(sal_uInt16 nAssocItemId, sal_uInt16 nRegionI
pItem->setHelpText(rSubtitle); pItem->setHelpText(rSubtitle);
pItem->setPath(rPath); pItem->setPath(rPath);
if(TemplateAbstractView::IsDefaultTemplate(rPath))
pItem->showDefaultIcon(true);
ThumbnailView::AppendItem(pItem); ThumbnailView::AppendItem(pItem);
CalculateItemPositions(); CalculateItemPositions();
......
...@@ -124,6 +124,7 @@ ...@@ -124,6 +124,7 @@
#define STR_ERROR_SAVEAS (RID_SFX_DOC_START+105) #define STR_ERROR_SAVEAS (RID_SFX_DOC_START+105)
#define STR_CATEGORY_RENAME (RID_SFX_DOC_START+109) #define STR_CATEGORY_RENAME (RID_SFX_DOC_START+109)
#define STR_TEMPLATE_SELECTION (RID_SFX_DOC_START+120) #define STR_TEMPLATE_SELECTION (RID_SFX_DOC_START+120)
#define STR_RESET_DEFAULT (RID_SFX_DOC_START+122)
// please update to the last id // please update to the last id
#define ACT_SFX_DOC_END IMG_ACTION_REFRESH #define ACT_SFX_DOC_END IMG_ACTION_REFRESH
......
...@@ -60,6 +60,10 @@ String STR_DEFAULT_TEMPLATE ...@@ -60,6 +60,10 @@ String STR_DEFAULT_TEMPLATE
{ {
Text [ en-US ] = "Set As Default" ; Text [ en-US ] = "Set As Default" ;
}; };
String STR_RESET_DEFAULT
{
Text [ en-US ] = "Reset Default" ;
};
String STR_DELETE String STR_DELETE
{ {
Text [ en-US ] = "Delete" ; Text [ en-US ] = "Delete" ;
......
...@@ -752,9 +752,9 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, RightClickHdl, ThumbnailViewItem*, pItem, ...@@ -752,9 +752,9 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, RightClickHdl, ThumbnailViewItem*, pItem,
if(mpCurView == mpLocalView) if(mpCurView == mpLocalView)
{ {
if(mpSearchView->IsVisible()) if(mpSearchView->IsVisible())
mpSearchView->createContextMenu(); mpSearchView->createContextMenu(pViewItem->IsDefaultTemplate());
else else
mpLocalView->createContextMenu(); mpLocalView->createContextMenu(pViewItem->IsDefaultTemplate());
} }
} }
} }
...@@ -854,19 +854,30 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, DeleteTemplateHdl, ThumbnailViewItem*, pI ...@@ -854,19 +854,30 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, DeleteTemplateHdl, ThumbnailViewItem*, pI
IMPL_LINK_TYPED(SfxTemplateManagerDlg, DefaultTemplateHdl, ThumbnailViewItem*, pItem, void) IMPL_LINK_TYPED(SfxTemplateManagerDlg, DefaultTemplateHdl, ThumbnailViewItem*, pItem, void)
{ {
TemplateViewItem *pViewItem = static_cast<TemplateViewItem*>(pItem); TemplateViewItem *pViewItem = static_cast<TemplateViewItem*>(pItem);
OUString aServiceName; OUString aServiceName;
if (lcl_getServiceName(pViewItem->getPath(),aServiceName))
{
OUString sPrevDefault = SfxObjectFactory::GetStandardTemplate( aServiceName );
if(!sPrevDefault.isEmpty())
mpLocalView->RemoveDefaultTemplateIcon(sPrevDefault);
SfxObjectFactory::SetStandardTemplate(aServiceName,pViewItem->getPath()); if(!pViewItem->IsDefaultTemplate())
pViewItem->showDefaultIcon(true); {
if (lcl_getServiceName(pViewItem->getPath(),aServiceName))
{
OUString sPrevDefault = SfxObjectFactory::GetStandardTemplate( aServiceName );
if(!sPrevDefault.isEmpty())
mpLocalView->RemoveDefaultTemplateIcon(sPrevDefault);
createDefaultTemplateMenu(); SfxObjectFactory::SetStandardTemplate(aServiceName,pViewItem->getPath());
pViewItem->showDefaultIcon(true);
}
}
else
{
if(lcl_getServiceName(pViewItem->getPath(),aServiceName))
{
SfxObjectFactory::SetStandardTemplate( aServiceName, OUString() );
pViewItem->showDefaultIcon(false);
}
} }
createDefaultTemplateMenu();
} }
IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, SearchUpdateHdl, Edit&, void) IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, SearchUpdateHdl, Edit&, void)
......
...@@ -33,7 +33,7 @@ public: ...@@ -33,7 +33,7 @@ public:
void setDefaultTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink); void setDefaultTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink);
void createContextMenu(); void createContextMenu(const bool bIsDefault);
void AppendItem(sal_uInt16 nAssocItemId, sal_uInt16 nRegionId, sal_uInt16 nIdx, void AppendItem(sal_uInt16 nAssocItemId, sal_uInt16 nRegionId, sal_uInt16 nIdx,
const OUString &rTitle, const OUString &rSubtitle, const OUString &rTitle, const OUString &rSubtitle,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment