[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - cui/source cui/uiconfig
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Nov 19 11:40:43 UTC 2019
cui/source/customize/SvxMenuConfigPage.cxx | 5 +--
cui/source/customize/SvxToolbarConfigPage.cxx | 6 ++--
cui/source/customize/cfg.cxx | 36 ++++++++++++++++++++++++++
cui/source/inc/SvxMenuConfigPage.hxx | 2 -
cui/source/inc/SvxToolbarConfigPage.hxx | 2 -
cui/source/inc/cfg.hxx | 18 +++++++++++++
cui/uiconfig/ui/menuassignpage.ui | 1
7 files changed, 61 insertions(+), 9 deletions(-)
New commits:
commit 485e9df9e3e5d444d455c280c30d72cbc1e49a69
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Nov 15 10:06:43 2019 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Nov 19 12:40:02 2019 +0100
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/82772
Tested-by: Jenkins
Tested-by: Xisco Faulí <xiscofauli at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 2f210e91619c..254120acf051 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -100,6 +100,7 @@ SvxMenuConfigPage::SvxMenuConfigPage(TabPageParent pParent, const SfxItemSet& rS
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());
@@ -111,8 +112,6 @@ SvxMenuConfigPage::SvxMenuConfigPage(TabPageParent pParent, const SfxItemSet& rS
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));
@@ -148,7 +147,7 @@ SvxMenuConfigPage::SvxMenuConfigPage(TabPageParent pParent, const SfxItemSet& rS
}
}
-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/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index 178a9c851ac3..ef54317e89fa 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -102,6 +102,8 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(TabPageParent pParent, const SfxItemS
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());
@@ -133,8 +135,6 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(TabPageParent pParent, const SfxItemS
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 );
@@ -188,7 +188,7 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(TabPageParent pParent, const SfxItemS
}
}
-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 dd245eeff73f..721b2b63d7b1 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -3175,4 +3175,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: */
diff --git a/cui/source/inc/SvxMenuConfigPage.hxx b/cui/source/inc/SvxMenuConfigPage.hxx
index 8dca571c2080..8ab022842829 100644
--- a/cui/source/inc/SvxMenuConfigPage.hxx
+++ b/cui/source/inc/SvxMenuConfigPage.hxx
@@ -58,7 +58,7 @@ private:
DECL_LINK( MenuEntriesSizeAllocHdl, const Size&, void );
- DECL_LINK( ListModifiedHdl, weld::TreeView&, void );
+ virtual void ListModified() override;
void Init() override;
void UpdateButtonStates() override;
diff --git a/cui/source/inc/SvxToolbarConfigPage.hxx b/cui/source/inc/SvxToolbarConfigPage.hxx
index 7c82bd8a61ea..9a5622ec62b2 100644
--- a/cui/source/inc/SvxToolbarConfigPage.hxx
+++ b/cui/source/inc/SvxToolbarConfigPage.hxx
@@ -56,7 +56,7 @@ private:
DECL_LINK( ModifyItemHdl, const OString&, void );
DECL_LINK( ResetToolbarHdl, weld::Button&, void );
- DECL_LINK( ListModifiedHdl, weld::TreeView&, void );
+ virtual void ListModified() override;
void UpdateButtonStates() override;
short QueryReset() override;
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index eba2c917c3d0..acf5e1b4734c 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -19,6 +19,7 @@
#ifndef INCLUDED_CUI_SOURCE_INC_CFG_HXX
#define INCLUDED_CUI_SOURCE_INC_CFG_HXX
+#include <vcl/transfer.hxx>
#include <vcl/weld.hxx>
#include <svtools/imgdef.hxx>
#include <svtools/miscopt.hxx>
@@ -335,6 +336,7 @@ public:
void remove(int nPos) { m_xControl->remove(nPos); }
int n_children() const { return m_xControl->n_children(); }
void set_text(int row, const OUString& rText, int col) { m_xControl->set_text(row, rText, col); }
+ OUString get_text(int row) { return m_xControl->get_text(row); }
void set_image(int row, const css::uno::Reference<css::graphic::XGraphic>& rImage, int col) { m_xControl->set_image(row, rImage, col); }
void set_dropdown(int row, int col) { m_xControl->set_image(row, *m_xDropDown, col); }
void set_id(int row, const OUString& rId) { m_xControl->set_id(row, rId); }
@@ -361,6 +363,19 @@ public:
void CreateDropDown();
};
+class SvxConfigPageFunctionDropTarget : public DropTargetHelper
+{
+private:
+ SvxConfigPage& m_rPage;
+ weld::TreeView& m_rTreeView;
+
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
+
+public:
+ SvxConfigPageFunctionDropTarget(SvxConfigPage&rPage, weld::TreeView& rTreeView);
+};
+
class SvxConfigPage : public SfxTabPage
{
private:
@@ -393,6 +408,7 @@ protected:
// Used to add and remove toolbars/menus
std::unique_ptr<weld::MenuButton> m_xGearBtn;
std::unique_ptr<SvxMenuEntriesListBox> m_xContentsListBox;
+ std::unique_ptr<SvxConfigPageFunctionDropTarget> m_xDropTargetHelper;
std::unique_ptr<weld::Button> m_xMoveUpButton;
std::unique_ptr<weld::Button> m_xMoveDownButton;
@@ -468,6 +484,8 @@ public:
virtual void DeleteSelectedContent() = 0;
virtual void DeleteSelectedTopLevel() = 0;
+ virtual void ListModified() {}
+
SvxConfigEntry* GetTopLevelSelection()
{
return reinterpret_cast<SvxConfigEntry*>(m_xTopLevelListBox->get_active_id().toInt64());
diff --git a/cui/uiconfig/ui/menuassignpage.ui b/cui/uiconfig/ui/menuassignpage.ui
index a0f0de90887c..fdb1b95cf98c 100644
--- a/cui/uiconfig/ui/menuassignpage.ui
+++ b/cui/uiconfig/ui/menuassignpage.ui
@@ -607,7 +607,6 @@
<property name="reorderable">True</property>
<property name="search_column">1</property>
<property name="show_expanders">False</property>
- <property name="enable_tree_lines">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="Macro Library List-selection2"/>
</child>
More information about the Libreoffice-commits
mailing list