[Libreoffice-commits] core.git: include/svx svx/source svx/uiconfig

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 5 09:37:24 UTC 2021


 include/svx/devtools/DevelopmentToolDockingWindow.hxx |    5 ++
 include/svx/devtools/DocumentModelTreeHandler.hxx     |    3 -
 svx/source/devtools/DevelopmentToolDockingWindow.cxx  |   31 ++++++++++++++++--
 svx/source/devtools/DocumentModelTreeHandler.cxx      |   24 -------------
 svx/uiconfig/ui/developmenttool.ui                    |   18 +++++++---
 5 files changed, 46 insertions(+), 35 deletions(-)

New commits:
commit 650b1718b25f3446c1e1ff487534ae18156d9c0a
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Jan 29 14:51:56 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Fri Feb 5 10:36:39 2021 +0100

    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 at gmail.com>

diff --git a/include/svx/devtools/DevelopmentToolDockingWindow.hxx b/include/svx/devtools/DevelopmentToolDockingWindow.hxx
index 98a805a22716..5d917516c195 100644
--- a/include/svx/devtools/DevelopmentToolDockingWindow.hxx
+++ b/include/svx/devtools/DevelopmentToolDockingWindow.hxx
@@ -27,17 +27,20 @@ class SVX_DLLPUBLIC DevelopmentToolDockingWindow final : public SfxDockingWindow
 private:
     std::unique_ptr<weld::Label> mpClassNameLabel;
     std::unique_ptr<weld::TreeView> mpClassListBox;
-
     std::unique_ptr<weld::TreeView> mpLeftSideTreeView;
+    std::unique_ptr<weld::ToggleButton> mpSelectionToggle;
 
     css::uno::Reference<css::uno::XInterface> mxRoot;
+    css::uno::Reference<css::uno::XInterface> mxCurrentSelection;
     OUString msDocumentType;
 
     DocumentModelTreeHandler maDocumentModelTreeHandler;
 
     DECL_LINK(LeftSideSelected, weld::TreeView&, void);
+    DECL_LINK(SelectionToggled, weld::ToggleButton&, void);
 
     void inspectDocument();
+    void updateSelection();
 
 public:
     DevelopmentToolDockingWindow(SfxBindings* pBindings, SfxChildWindow* pChildWindow,
diff --git a/include/svx/devtools/DocumentModelTreeHandler.hxx b/include/svx/devtools/DocumentModelTreeHandler.hxx
index 731c733015e0..3b57ec1aca34 100644
--- a/include/svx/devtools/DocumentModelTreeHandler.hxx
+++ b/include/svx/devtools/DocumentModelTreeHandler.hxx
@@ -23,7 +23,6 @@ class DocumentModelTreeHandler
 private:
     std::unique_ptr<weld::TreeView>& mpDocumentModelTree;
     css::uno::Reference<css::uno::XInterface> mxDocument;
-    OUString msCurrentSelectionID;
 
     void clearChildren(weld::TreeIter const& rParent);
 
@@ -40,7 +39,7 @@ public:
     DECL_LINK(ExpandingHandler, const weld::TreeIter&, bool);
 
     void inspectDocument();
-    void setCurrentSelectedObject(css::uno::Reference<css::uno::XInterface> xObject);
+
     static css::uno::Reference<css::uno::XInterface> getObjectByID(OUString const& rID);
 
     void dispose();
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>
@@ -80,6 +76,18 @@
                   </object>
                 </child>
               </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>


More information about the Libreoffice-commits mailing list