Skip to content

Commit

Permalink
tdf#100195 Enable Keyboard Navigation in Template Manager and Start C…
Browse files Browse the repository at this point in the history
…enter

Change-Id: Ic5447a4af091a4e3dcab4d909fc6bfb9e559defb
Reviewed-on: https://gerrit.libreoffice.org/25848
Reviewed-by: Samuel Mehrbrodt <[email protected]>
Tested-by: Samuel Mehrbrodt <[email protected]>
  • Loading branch information
akkisna authored and smehrbrodt committed Jun 3, 2016
1 parent a4740c8 commit 9b7bf60
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/sfx2/templateabstractview.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public:
virtual void dispose() override;

// Fill view with new item list
void insertItems (const std::vector<TemplateItemProperties> &rTemplates);
void insertItems (const std::vector<TemplateItemProperties> &rTemplates, bool isRegionSelected = true);

// Fill view with template folders thumbnails
virtual void Populate () { }
Expand Down
14 changes: 12 additions & 2 deletions sfx2/source/control/templateabstractview.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,21 @@ void TemplateAbstractView::dispose()
ThumbnailView::dispose();
}

void TemplateAbstractView::insertItems(const std::vector<TemplateItemProperties> &rTemplates)
void TemplateAbstractView::insertItems(const std::vector<TemplateItemProperties> &rTemplates, bool isRegionSelected)
{
mItemList.clear();

std::vector<ThumbnailViewItem*> aItems(rTemplates.size());
for (size_t i = 0, n = rTemplates.size(); i < n; ++i )
{
const TemplateItemProperties *pCur = &rTemplates[i];

TemplateViewItem *pChild = new TemplateViewItem(*this, pCur->nId);
TemplateViewItem *pChild;
if(isRegionSelected)
pChild = new TemplateViewItem(*this, pCur->nId);
else
pChild = new TemplateViewItem(*this, i+1);

pChild->mnDocId = pCur->nDocId;
pChild->mnRegionId = pCur->nRegionId;
pChild->maTitle = pCur->aName;
Expand Down Expand Up @@ -140,8 +147,11 @@ void TemplateAbstractView::updateThumbnailDimensions(long itemMaxSize)

void TemplateAbstractView::MouseButtonDown( const MouseEvent& rMEvt )
{
GrabFocus();

if (rMEvt.IsRight())
{
deselectItems();
size_t nPos = ImplGetItem(rMEvt.GetPosPixel());
Point aPosition (rMEvt.GetPosPixel());
maPosition = aPosition;
Expand Down
4 changes: 2 additions & 2 deletions sfx2/source/control/templatelocalview.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void TemplateLocalView::showAllTemplates()
mnCurRegionId = 0;
maCurRegionName.clear();

insertItems(maAllTemplates);
insertItems(maAllTemplates, false);
maOpenRegionHdl.Call(nullptr);
}

Expand Down Expand Up @@ -575,7 +575,7 @@ bool TemplateLocalView::moveTemplates(const std::set<const ThumbnailViewItem*, s
if (pPropIter->nDocId == pViewItem->mnDocId)
{
pPropIter = pSrc->maTemplates.erase(pPropIter);
aItemIds.push_back(pViewItem->mnId);
aItemIds.push_back(pViewItem->mnDocId + 1);//mnid
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions sfx2/source/control/templatesearchview.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ VCL_BUILDER_FACTORY(TemplateSearchView)

void TemplateSearchView::MouseButtonDown( const MouseEvent& rMEvt )
{
GrabFocus();
if (rMEvt.IsRight())
{
deselectItems();
size_t nPos = ImplGetItem(rMEvt.GetPosPixel());
Point aPosition (rMEvt.GetPosPixel());
maPosition = aPosition;
Expand Down
21 changes: 17 additions & 4 deletions sfx2/source/dialog/backingwindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -392,24 +392,37 @@ bool BackingWindow::PreNotify( NotifyEvent& rNEvt )
{
if( rKeyCode.IsShift() ) // Shift + F6
{
if( mpAllRecentThumbnails->HasFocus() )
if( mpAllRecentThumbnails->HasFocus() || mpLocalView->HasFocus())
{
mpOpenButton->GrabFocus();
return true;
}
}
else if ( rKeyCode.IsMod1() ) // Ctrl + F6
{
mpAllRecentThumbnails->GrabFocus();
return true;
if(mpAllRecentThumbnails->IsVisible())
{
mpAllRecentThumbnails->GrabFocus();
return true;
}
else if(mpLocalView->IsVisible())
{
mpLocalView->GrabFocus();
return true;
}
}
else // F6
{
if( mpAllButtonsBox->HasChildPathFocus() )
if(mpAllRecentThumbnails->IsVisible())
{
mpAllRecentThumbnails->GrabFocus();
return true;
}
else if(mpLocalView->IsVisible())
{
mpLocalView->GrabFocus();
return true;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions sfx2/source/doc/templatedlg.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, DeleteTemplateHdl, ThumbnailViewItem*, pI
TemplateViewItem *pViewItem = static_cast<TemplateViewItem*>(pItem);
sal_uInt16 nRegionItemId = mpLocalView->getRegionId(pViewItem->mnRegionId);

if (!mpLocalView->removeTemplate((pViewItem)->mnId,nRegionItemId))
if (!mpLocalView->removeTemplate((pViewItem)->mnDocId + 1, nRegionItemId))//mnId w.r.t. region is mnDocId + 1;
{
aDeletedTemplate = (pItem)->maTitle;
}
Expand Down Expand Up @@ -1113,7 +1113,7 @@ void SfxTemplateManagerDlg::OnTemplateExport()

OUString aPath = aPathObj.GetMainURL( INetURLObject::NO_DECODE );

if (!mpLocalView->exportTo(pItem->mnId,
if (!mpLocalView->exportTo(pItem->mnDocId + 1, //mnId w.r.t. region = mDocId + 1
mpLocalView->getRegionId(pItem->mnRegionId), //pItem->mnRegionId does not store actual region Id
aPath))
{
Expand Down

0 comments on commit 9b7bf60

Please sign in to comment.