summaryrefslogtreecommitdiff
path: root/cui/source/customize
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-11-15 10:06:43 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-11-15 16:51:25 +0100
commitfafd25e4b6c7ee7d6e47791bb37d3a242d7c4a16 (patch)
tree48a1e8e6c4ff2ad8dcc601958edbfd1b890eb251 /cui/source/customize
parentde6b9cd633e41f2a38f437143fb40c6e0a1d337d (diff)
Resolves: tdf#128802 manage dnd ourself
instead of relying on the built-in dnd which is allowing toplevel entries to be dropped on other ones to become children of another entry, which is not what we want here. Change-Id: I8c5528d9b26e994b7eda9d2972af0b3783187f3e Reviewed-on: https://gerrit.libreoffice.org/82770 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui/source/customize')
-rw-r--r--cui/source/customize/SvxMenuConfigPage.cxx5
-rw-r--r--cui/source/customize/SvxNotebookbarConfigPage.cxx2
-rw-r--r--cui/source/customize/SvxToolbarConfigPage.cxx6
-rw-r--r--cui/source/customize/cfg.cxx36
4 files changed, 43 insertions, 6 deletions
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index f560a25f1632..2b6ef9e52469 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -46,6 +46,7 @@ SvxMenuConfigPage::SvxMenuConfigPage(weld::Container* pPage, weld::DialogControl
m_xGearBtn->show();
m_xContentsListBox.reset(new SvxMenuEntriesListBox(m_xBuilder->weld_tree_view("menucontents"), this));
weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
+ m_xDropTargetHelper.reset(new SvxConfigPageFunctionDropTarget(*this, rTreeView));
rTreeView.connect_size_allocate(LINK(this, SvxMenuConfigPage, MenuEntriesSizeAllocHdl));
Size aSize(m_xFunctions->get_size_request());
rTreeView.set_size_request(aSize.Width(), aSize.Height());
@@ -57,8 +58,6 @@ SvxMenuConfigPage::SvxMenuConfigPage(weld::Container* pPage, weld::DialogControl
rTreeView.connect_changed(
LINK( this, SvxMenuConfigPage, SelectMenuEntry ) );
- rTreeView.connect_model_changed(LINK(this, SvxMenuConfigPage, ListModifiedHdl));
-
m_xGearBtn->connect_selected(LINK(this, SvxMenuConfigPage, GearHdl));
m_xCommandCategoryListBox->connect_changed(LINK(this, SvxMenuConfigPage, SelectCategory));
@@ -94,7 +93,7 @@ SvxMenuConfigPage::SvxMenuConfigPage(weld::Container* pPage, weld::DialogControl
}
}
-IMPL_LINK_NOARG(SvxMenuConfigPage, ListModifiedHdl, weld::TreeView&, void)
+void SvxMenuConfigPage::ListModified()
{
// regenerate with the current ordering within the list
SvxEntries* pEntries = GetTopLevelSelection()->GetEntries();
diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx b/cui/source/customize/SvxNotebookbarConfigPage.cxx
index 26cebe8cd583..af5bed877aef 100644
--- a/cui/source/customize/SvxNotebookbarConfigPage.cxx
+++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx
@@ -127,6 +127,8 @@ SvxNotebookbarConfigPage::SvxNotebookbarConfigPage(weld::Container* pPage,
m_xContentsListBox.reset(
new SvxNotebookbarEntriesListBox(m_xBuilder->weld_tree_view("toolcontents"), this));
+ m_xDropTargetHelper.reset(
+ new SvxConfigPageFunctionDropTarget(*this, m_xContentsListBox->get_widget()));
std::vector<int> aWidths;
weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
Size aSize(m_xFunctions->get_size_request());
diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index 36b3fd202d32..aee4abf651a6 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -51,6 +51,8 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(weld::Container* pPage, weld::DialogC
m_xContainer->set_help_id(HID_SVX_CONFIG_TOOLBAR);
m_xContentsListBox.reset(new SvxToolbarEntriesListBox(m_xBuilder->weld_tree_view("toolcontents"), this));
+ m_xDropTargetHelper.reset(new SvxConfigPageFunctionDropTarget(*this, m_xContentsListBox->get_widget()));
+
std::vector<int> aWidths;
weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
Size aSize(m_xFunctions->get_size_request());
@@ -82,8 +84,6 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(weld::Container* pPage, weld::DialogC
rTreeView.connect_changed(
LINK( this, SvxToolbarConfigPage, SelectToolbarEntry ) );
- rTreeView.connect_model_changed(LINK(this, SvxToolbarConfigPage, ListModifiedHdl));
-
m_xTopLevelListBox->set_help_id ( HID_SVX_TOPLEVELLISTBOX );
m_xSaveInListBox->set_help_id( HID_SVX_SAVE_IN );
m_xMoveUpButton->set_help_id( HID_SVX_UP_TOOLBAR_ITEM );
@@ -137,7 +137,7 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(weld::Container* pPage, weld::DialogC
}
}
-IMPL_LINK_NOARG(SvxToolbarConfigPage, ListModifiedHdl, weld::TreeView&, void)
+void SvxToolbarConfigPage::ListModified()
{
// regenerate with the current ordering within the list
SvxEntries* pEntries = GetTopLevelSelection()->GetEntries();
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 2879d17b58ec..0f0f6dc7b1f9 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -3163,4 +3163,40 @@ SvxIconChangeDialog::SvxIconChangeDialog(weld::Window *pWindow, const OUString&
m_xLineEditDescription->set_text(rMessage);
}
+SvxConfigPageFunctionDropTarget::SvxConfigPageFunctionDropTarget(SvxConfigPage&rPage, weld::TreeView& rTreeView)
+ : DropTargetHelper(rTreeView.get_drop_target())
+ , m_rPage(rPage)
+ , m_rTreeView(rTreeView)
+{
+}
+
+sal_Int8 SvxConfigPageFunctionDropTarget::AcceptDrop(const AcceptDropEvent& rEvt)
+{
+ // to enable the autoscroll when we're close to the edges
+ m_rTreeView.get_dest_row_at_pos(rEvt.maPosPixel, nullptr);
+ return DND_ACTION_MOVE;
+}
+
+sal_Int8 SvxConfigPageFunctionDropTarget::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ weld::TreeView* pSource = m_rTreeView.get_drag_source();
+ // only draging within the same widget allowed
+ if (!pSource || pSource != &m_rTreeView)
+ return DND_ACTION_NONE;
+
+ std::unique_ptr<weld::TreeIter> xSource(m_rTreeView.make_iterator());
+ if (!m_rTreeView.get_selected(xSource.get()))
+ return DND_ACTION_NONE;
+
+ std::unique_ptr<weld::TreeIter> xTarget(m_rTreeView.make_iterator());
+ int nTargetPos = -1;
+ if (m_rTreeView.get_dest_row_at_pos(rEvt.maPosPixel, xTarget.get()))
+ nTargetPos = m_rTreeView.get_iter_index_in_parent(*xTarget);
+ m_rTreeView.move_subtree(*xSource, nullptr, nTargetPos);
+
+ m_rPage.ListModified();
+
+ return DND_ACTION_NONE;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */