diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-01-29 14:51:56 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-02-05 10:36:39 +0100 |
commit | 650b1718b25f3446c1e1ff487534ae18156d9c0a (patch) | |
tree | c520862618a70f9cdc78470239034a815621caf8 /svx | |
parent | 47448aaff96536fa76588ee6de4164109df5d420 (diff) |
devtools: change "Current Selection" tree item to a toggle button
It is a bit awkward that the selection is a tree item so this
changes it to be a toogle button, which when enabled, shows the
object in the right-hand side object inspector and disables the
left-hand side DOM object tree view in this case.
Change-Id: I4ebd03a39c72109f0545206354aa7dbe85e9649a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110119
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/devtools/DevelopmentToolDockingWindow.cxx | 31 | ||||
-rw-r--r-- | svx/source/devtools/DocumentModelTreeHandler.cxx | 24 | ||||
-rw-r--r-- | svx/uiconfig/ui/developmenttool.ui | 18 |
3 files changed, 41 insertions, 32 deletions
diff --git a/svx/source/devtools/DevelopmentToolDockingWindow.cxx b/svx/source/devtools/DevelopmentToolDockingWindow.cxx index 407900704a3b..c6adf1f5f0a5 100644 --- a/svx/source/devtools/DevelopmentToolDockingWindow.cxx +++ b/svx/source/devtools/DevelopmentToolDockingWindow.cxx @@ -94,11 +94,13 @@ DevelopmentToolDockingWindow::DevelopmentToolDockingWindow(SfxBindings* pInputBi , mpClassNameLabel(m_xBuilder->weld_label("class_name_value_id")) , mpClassListBox(m_xBuilder->weld_tree_view("class_listbox_id")) , mpLeftSideTreeView(m_xBuilder->weld_tree_view("leftside_treeview_id")) + , mpSelectionToggle(m_xBuilder->weld_toggle_button("selection_toggle")) , maDocumentModelTreeHandler( mpLeftSideTreeView, pInputBindings->GetDispatcher()->GetFrame()->GetObjectShell()->GetBaseModel()) { mpLeftSideTreeView->connect_changed(LINK(this, DevelopmentToolDockingWindow, LeftSideSelected)); + mpSelectionToggle->connect_toggled(LINK(this, DevelopmentToolDockingWindow, SelectionToggled)); auto* pViewFrame = pInputBindings->GetDispatcher()->GetFrame(); @@ -120,24 +122,48 @@ DevelopmentToolDockingWindow::DevelopmentToolDockingWindow(SfxBindings* pInputBi IMPL_LINK(DevelopmentToolDockingWindow, LeftSideSelected, weld::TreeView&, rView, void) { + if (mpSelectionToggle->get_state() == TRISTATE_TRUE) + return; + OUString sID = rView.get_selected_id(); auto xObject = DocumentModelTreeHandler::getObjectByID(sID); if (xObject.is()) introspect(xObject); } +IMPL_LINK_NOARG(DevelopmentToolDockingWindow, SelectionToggled, weld::ToggleButton&, void) +{ + updateSelection(); +} + DevelopmentToolDockingWindow::~DevelopmentToolDockingWindow() { disposeOnce(); } void DevelopmentToolDockingWindow::dispose() { mpClassNameLabel.reset(); mpClassListBox.reset(); + mpSelectionToggle.reset(); maDocumentModelTreeHandler.dispose(); mpLeftSideTreeView.reset(); SfxDockingWindow::dispose(); } +void DevelopmentToolDockingWindow::updateSelection() +{ + TriState eTriState = mpSelectionToggle->get_state(); + if (eTriState == TRISTATE_TRUE) + { + introspect(mxCurrentSelection); + mpLeftSideTreeView->set_sensitive(false); + } + else + { + mpLeftSideTreeView->set_sensitive(true); + LeftSideSelected(*mpLeftSideTreeView); + } +} + void DevelopmentToolDockingWindow::ToggleFloatingMode() { SfxDockingWindow::ToggleFloatingMode(); @@ -151,9 +177,8 @@ void DevelopmentToolDockingWindow::ToggleFloatingMode() void DevelopmentToolDockingWindow::selectionChanged( uno::Reference<uno::XInterface> const& xInterface) { - maDocumentModelTreeHandler.setCurrentSelectedObject(xInterface); - // We need to update the introspection window - LeftSideSelected(*mpLeftSideTreeView); + mxCurrentSelection = xInterface; + updateSelection(); } void DevelopmentToolDockingWindow::introspect(uno::Reference<uno::XInterface> const& xInterface) diff --git a/svx/source/devtools/DocumentModelTreeHandler.cxx b/svx/source/devtools/DocumentModelTreeHandler.cxx index 4d36077a74e7..12237bd6af7a 100644 --- a/svx/source/devtools/DocumentModelTreeHandler.cxx +++ b/svx/source/devtools/DocumentModelTreeHandler.cxx @@ -122,15 +122,6 @@ public: } }; -class CurrentSelectionEntry : public DocumentModelTreeEntry -{ -public: - CurrentSelectionEntry(css::uno::Reference<css::uno::XInterface> const& xObject) - : DocumentModelTreeEntry(xObject) - { - } -}; - class ParagraphsEntry : public DocumentModelTreeEntry { public: @@ -633,8 +624,6 @@ void DocumentModelTreeHandler::inspectDocument() { uno::Reference<lang::XServiceInfo> xDocumentServiceInfo(mxDocument, uno::UNO_QUERY_THROW); - msCurrentSelectionID = lclAppend(mpDocumentModelTree, "Current Selection", - new CurrentSelectionEntry(mxDocument), false); lclAppend(mpDocumentModelTree, "Document", new DocumentRootEntry(mxDocument), false); if (xDocumentServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument")) @@ -669,17 +658,4 @@ void DocumentModelTreeHandler::inspectDocument() } } -void DocumentModelTreeHandler::setCurrentSelectedObject( - css::uno::Reference<css::uno::XInterface> xObject) -{ - if (msCurrentSelectionID.isEmpty()) - return; - - auto* pEntry = reinterpret_cast<DocumentModelTreeEntry*>(msCurrentSelectionID.toInt64()); - if (!pEntry) - return; - - pEntry->mxObject = xObject; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/uiconfig/ui/developmenttool.ui b/svx/uiconfig/ui/developmenttool.ui index 2b00a83f5142..8310d0fffae8 100644 --- a/svx/uiconfig/ui/developmenttool.ui +++ b/svx/uiconfig/ui/developmenttool.ui @@ -8,10 +8,6 @@ <column type="gchararray"/> <!-- column-name id --> <column type="gchararray"/> - <!-- column-name weight1 --> - <column type="gint"/> - <!-- column-name sensitive1 --> - <column type="gboolean"/> </columns> </object> <object class="GtkTreeStore" id="liststore1"> @@ -36,7 +32,7 @@ <property name="position">800</property> <property name="wide-handle">True</property> <child> - <!-- n-columns=1 n-rows=1 --> + <!-- n-columns=1 n-rows=2 --> <object class="GtkGrid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -82,6 +78,18 @@ </object> <packing> <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + <child> + <object class="GtkToggleButton" id="selection_toggle"> + <property name="label" translatable="yes" context="developmenttool|selection_toggle">Current Selection</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + </object> + <packing> + <property name="left-attach">0</property> <property name="top-attach">0</property> </packing> </child> |