vcl/inc/qt5/QtBuilder.hxx          |    1 +
 vcl/inc/qt5/QtInstanceItemView.hxx |    2 ++
 vcl/qt5/QtBuilder.cxx              |    9 +++++++++
 vcl/qt5/QtInstanceItemView.cxx     |    6 ++++++
 4 files changed, 18 insertions(+)

New commits:
commit cc847ffd7ed1b8aa2c8884ed0d1a047d912a2b23
Author:     Michael Weghorn <[email protected]>
AuthorDate: Sat Dec 20 19:45:54 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Sat Dec 20 22:32:12 2025 +0100

    tdf#130857 tdf#168594 qt weld: Support activate-on-single-click
    
    Both, GtkTreeView and GtkIconView have an
    "activate-on-single-click" property
    that specifies whether the "item-activated" signal
    will be emitted after a single click. [1] [2]
    
    For the Qt implementation, in case that property
    is set to true, connect to the
    QAbstractItemView::clicked signal that
    "is emitted when a mouse button is left-clicked" [3]
    and trigger the QAbstractItemView::activated [4]
    signal that is handled in both, QtInstanceTreeView
    and QtInstanceIconView to call the corresponding
    weld::TreeView::signal_row_activated and
    QtInstanceIconView::signal_item_activated.
    
    In a quick test with a local change (s. below) to set
    that property for Writer's "Insert" -> "Fontwork..."
    dialog, single-clicking an item in that dialog now results
    in it getting inserted into the document with the qt6
    VCL plugin and SAL_VCL_QT_USE_WELDED_WIDGETS=1 .
    
    Local test change to set the property for the dialog:
    
        diff --git a/svx/uiconfig/ui/fontworkgallerydialog.ui 
b/svx/uiconfig/ui/fontworkgallerydialog.ui
        index 65a749ab4a23..c7d649360694 100644
        --- a/svx/uiconfig/ui/fontworkgallerydialog.ui
        +++ b/svx/uiconfig/ui/fontworkgallerydialog.ui
        @@ -121,6 +121,7 @@
                             <property name="model">liststore1</property>
                             <property name="pixbuf-column">0</property>
                             <property name="tooltip-column">2</property>
        +                    <property 
name="activate-on-single-click">True</property>
                             <child internal-child="accessible">
                               <object class="AtkObject" 
id="ctlFavoriteswin-atkobject">
                                 <property 
name="AtkObject::accessible-description" translatable="yes" 
context="fontworkgallerydialog|extended_tip|ctlFavoriteWin">Select a Fontwork 
style and click OK to insert the Fontwork into your document. Double-click or 
Ctrl (Command) + double-click the Fontwork in your document to enter text edit 
mode and change the text.</property>
    
    [1] 
https://docs.gtk.org/gtk3/property.TreeView.activate-on-single-click.html
    [2] 
https://docs.gtk.org/gtk3/property.IconView.activate-on-single-click.html
    [3] https://doc.qt.io/qt-6/qabstractitemview.html#clicked
    [4] https://doc.qt.io/qt-6/qabstractitemview.html#activated
    
    Change-Id: I556cdbb4e17b3b9a864953cff39d1c477fb18098
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196034
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/inc/qt5/QtBuilder.hxx b/vcl/inc/qt5/QtBuilder.hxx
index 0c70f2feb9c0..aa8337469875 100644
--- a/vcl/inc/qt5/QtBuilder.hxx
+++ b/vcl/inc/qt5/QtBuilder.hxx
@@ -95,6 +95,7 @@ private:
                                   QWidget* pParentWidget);
     static void setDialogProperties(QDialog& rDialog, stringmap& rProps);
     static void setEntryProperties(QLineEdit& rLineEdit, stringmap& rProps);
+    static void setItemViewProperties(QAbstractItemView& rIconView, stringmap& 
rProps);
     static void setLabelProperties(QLabel& rLabel, stringmap& rProps);
     static void setMessageDialogProperties(QMessageBox& rMessageBox, 
stringmap& rProps);
     static void setMenuActionGroup(QMenu* pMenu, QAction* pAction, const 
OUString& rRadioGroupId);
diff --git a/vcl/inc/qt5/QtInstanceItemView.hxx 
b/vcl/inc/qt5/QtInstanceItemView.hxx
index 5c0580b89b7f..81317a64486b 100644
--- a/vcl/inc/qt5/QtInstanceItemView.hxx
+++ b/vcl/inc/qt5/QtInstanceItemView.hxx
@@ -66,6 +66,8 @@ public:
 
     virtual void selected_foreach(const std::function<bool(weld::TreeIter&)>& 
func) override;
 
+    static void enableActivateOnSingleClick(QAbstractItemView& rItemView);
+
 protected:
     QModelIndex modelIndex(int nRow, int nCol = 0,
                            const QModelIndex& rParentIndex = QModelIndex()) 
const;
diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx
index 5dbd3ad62400..098cd9af2701 100644
--- a/vcl/qt5/QtBuilder.cxx
+++ b/vcl/qt5/QtBuilder.cxx
@@ -270,6 +270,7 @@ QObject* QtBuilder::makeObject(QObject* pParent, 
std::u16string_view sName, std:
         pListView->setModel(new QStandardItemModel(pListView));
         pListView->setViewMode(QListView::IconMode);
         pListView->setMovement(QListView::Static);
+        setItemViewProperties(*pListView, rMap);
         pObject = pListView;
     }
     else if (sName == u"GtkImage")
@@ -425,6 +426,7 @@ QObject* QtBuilder::makeObject(QObject* pParent, 
std::u16string_view sName, std:
         pTreeView->setModel(pProxyModel);
         pTreeView->setHeaderHidden(!extractHeadersVisible(rMap));
         pTreeView->setRootIsDecorated(extractShowExpanders(rMap));
+        setItemViewProperties(*pTreeView, rMap);
         pObject = pTreeView;
     }
     else if (sName == u"GtkTreeViewColumn")
@@ -975,6 +977,13 @@ void QtBuilder::setEntryProperties(QLineEdit& rLineEdit, 
stringmap& rProps)
         rLineEdit.setEchoMode(QLineEdit::Password);
 }
 
+void QtBuilder::setItemViewProperties(QAbstractItemView& rIconView, stringmap& 
rProps)
+{
+    auto aIt = rProps.find(u"activate-on-single-click"_ustr);
+    if (aIt != rProps.end() && toBool(aIt->second))
+        QtInstanceItemView::enableActivateOnSingleClick(rIconView);
+}
+
 void QtBuilder::setLabelProperties(QLabel& rLabel, stringmap& rProps)
 {
     for (auto const & [ rKey, rValue ] : rProps)
diff --git a/vcl/qt5/QtInstanceItemView.cxx b/vcl/qt5/QtInstanceItemView.cxx
index 38da98a76812..ac611b7ec116 100644
--- a/vcl/qt5/QtInstanceItemView.cxx
+++ b/vcl/qt5/QtInstanceItemView.cxx
@@ -255,4 +255,10 @@ QItemSelectionModel& 
QtInstanceItemView::getSelectionModel() const
     return *pSelectionModel;
 }
 
+void QtInstanceItemView::enableActivateOnSingleClick(QAbstractItemView& 
rItemView)
+{
+    QObject::connect(&rItemView, &QAbstractItemView::clicked, &rItemView,
+                     &QAbstractItemView::activated);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */

Reply via email to