svx/source/dialog/docrecovery.cxx | 3 ++- vcl/inc/qt5/QtInstanceTreeView.hxx | 3 --- vcl/qt5/QtInstanceBuilder.cxx | 1 + vcl/qt5/QtInstanceTreeView.cxx | 29 ++++++++++++++--------------- 4 files changed, 17 insertions(+), 19 deletions(-)
New commits: commit d1c70b98269c8617b9ce6e1c2fb644c70e31d99d Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Jul 29 17:35:41 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Jul 30 14:29:40 2025 +0200 tdf#130857 qt weld: Support doc recovery dialog This means that native Qt widgets are used for that dialog now when using the qt5 or qt6 VCL plugin and starting LO with environment variable SAL_VCL_QT_USE_WELDED_WIDGETS=1 set. This dialog can be triggered as follows: * Add an assert to cause LO to "crash" when the "Go to page" dialog is opened --- a/svx/source/dialog/gotodlg.cxx +++ b/svx/source/dialog/gotodlg.cxx @@ -30,6 +30,7 @@ GotoPageDlg::GotoPageDlg(weld::Window* pParent, const OUString& title, const OUS , mxPageNumberLbl(m_xBuilder->weld_label(u"page_count"_ustr)) , mxPageLbl(m_xBuilder->weld_label(u"page_label"_ustr)) { + assert(false); set_title(title); mxPageLbl->set_label(label); * start LO Writer, save the doc * Press Ctrl+G to trigger the assert/crash * restart LO using SAL_USE_VCLPLUGIN=qt6 SAL_VCL_QT_USE_WELDED_WIDGETS=1 ./instdir/program/soffice.bin --writer Change-Id: I2b008234c53211785a3181145c63b603bfc93c67 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188535 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx index 20204fddd74f..54d645b73f9f 100644 --- a/vcl/qt5/QtInstanceBuilder.cxx +++ b/vcl/qt5/QtInstanceBuilder.cxx @@ -160,6 +160,7 @@ bool QtInstanceBuilder::IsUIFileSupported(const OUString& rUIFile, const weld::W u"svt/ui/printersetupdialog.ui"_ustr, u"svt/ui/restartdialog.ui"_ustr, u"svx/ui/compressgraphicdialog.ui"_ustr, + u"svx/ui/docrecoveryrecoverdialog.ui"_ustr, u"svx/ui/docrecoverysavedialog.ui"_ustr, u"svx/ui/fontworkgallerydialog.ui"_ustr, u"svx/ui/deletefooterdialog.ui"_ustr, commit a9e29c4968f3fe869b27c36d7017c5caacc23293 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Jul 29 17:35:03 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Jul 30 14:29:33 2025 +0200 tdf#130857 svx: Connect doc recovery toggle handler after toggling manually Connect the handler for the toggle signal for the treeview in the document recovery dialog only after manually setting the initial state for the entries using weld::TreeView::set_toggle. The self-triggered ones are uninteresting and would otherwise trigger a nullptr deref seen with the qt6 VCL plugin in a WIP branch declaring support to use native Qt widgets for that dialog with env variable SAL_VCL_QT_USE_WELDED_WIDGETS=1 set. (The GTK and VCL implementations currently filter out more signals, which the Qt implementation might also consider at some stage, but there's no reason to connect the handler earlier here.) Change-Id: I516ce785f231f9ce409bb3ca86370a785d25b576 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188534 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx index cd9e60de5e4a..e04f0e77edf4 100644 --- a/svx/source/dialog/docrecovery.cxx +++ b/svx/source/dialog/docrecovery.cxx @@ -703,7 +703,6 @@ RecoveryDialog::RecoveryDialog(weld::Window* pParent, RecoveryCore* pCore) aWidths.push_back(5 * nWidth / 100); m_xFileListLB->set_column_fixed_widths(aWidths); m_xFileListLB->enable_toggle_buttons(weld::ColumnToggleType::Check); - m_xFileListLB->connect_toggled( LINK(this, RecoveryDialog, ToggleRowHdl) ); m_xNextBtn->set_sensitive(true); m_xNextBtn->connect_clicked( LINK( this, RecoveryDialog, NextButtonHdl ) ); @@ -727,6 +726,8 @@ RecoveryDialog::RecoveryDialog(weld::Window* pParent, RecoveryCore* pCore) // mark first item if (m_xFileListLB->n_children()) m_xFileListLB->set_cursor(0); + + m_xFileListLB->connect_toggled(LINK(this, RecoveryDialog, ToggleRowHdl)); } RecoveryDialog::~RecoveryDialog() commit 246d52434e858b0984e8011cba25a030b4af69dd Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Jul 29 17:13:18 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Jul 30 14:29:26 2025 +0200 tdf#130857 qt weld: No longer use separate col for "expander toggle" Change the approach to handling the special "expander toggle" that is documented in the weld::TreeView API: // col index -1 sets the expander toggle, enable_toggle_buttons must have been called to create that column virtual void set_toggle(const TreeIter& rIter, TriState bOn, int col = -1) = 0; // col index -1 gets the expander toggle, enable_toggle_buttons must have been called to create that column virtual TriState get_toggle(const TreeIter& rIter, int col = -1) const = 0; Instead of using a separate column for it, instead always set the checked state for the existing column at index 0. This is similar to the approach for the "expander image" implemented in commit a838839e4d191c62a9396ee65af9a116a617160f Author: Michael Weghorn <m.wegh...@posteo.de> Date: Fri Jul 25 07:59:01 2025 +0200 tdf#130857 qt weld: Support setting TreeView "expander image" and (similar to what is described in the above-mentioned commit for the expander image) not using a separate column will allow having a column title for the "expander toggle" and the first "normal" column together, which is e.g. relevant for the document recovery dialog (UI file: svx/uiconfig/ui/docrecoveryrecoverdialog.ui), where both, the checkbox and the document name are supposed to be in a column titled "Recover Document" together. Support for that dialog will be declared in an upcoming commit. In line with the above-mentioned commit, using the column at index 0 implies that it's not possible to set another check state for the same column. Therefore, add a corresponding assert to detect any cases where QtInstanceTreeView::get_toggle or QtInstanceTreeView::set_toggle are called with index 0 if the special expander toggle is enabled. If any such cases exist, they will have to be addressed once they show up. (Depending on the use case, reworking the implementation of the specific dialog could be a potential option, e.g. introducing a separate column.) Change-Id: I65b1c94aec27985cbcc3a173a5f8bcb50e6aa167 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188533 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtInstanceTreeView.hxx b/vcl/inc/qt5/QtInstanceTreeView.hxx index f30343885e59..97041e875e2a 100644 --- a/vcl/inc/qt5/QtInstanceTreeView.hxx +++ b/vcl/inc/qt5/QtInstanceTreeView.hxx @@ -201,9 +201,6 @@ public: using QtInstanceWidget::get_sensitive; private: - // Returns column index as used in the weld::TreeView API - int externalColumnIndex(const QModelIndex& rIndex); - QModelIndex modelIndex(int nRow, int nCol = 0, const QModelIndex& rParentIndex = QModelIndex()) const; QModelIndex modelIndex(const weld::TreeIter& rIter, int nCol = 0) const; diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx index 0ce9f2ae403d..f440457e0c71 100644 --- a/vcl/qt5/QtInstanceTreeView.cxx +++ b/vcl/qt5/QtInstanceTreeView.cxx @@ -577,6 +577,9 @@ void QtInstanceTreeView::set_toggle(const weld::TreeIter& rIter, TriState eState { SolarMutexGuard g; + assert((nCol != 0 || !m_bExtraToggleButtonColumnEnabled) + && "Column 0 is already used by \"expander toggle\" using special index -1"); + GetQtInstance().RunInMainThread([&] { QModelIndex aIndex = nCol == -1 ? toggleButtonModelIndex(rIter) : modelIndex(rIter, nCol); itemFromIndex(aIndex)->setCheckState(toQtCheckState(eState)); @@ -587,6 +590,9 @@ TriState QtInstanceTreeView::get_toggle(const weld::TreeIter& rIter, int nCol) c { SolarMutexGuard g; + assert((nCol != 0 || !m_bExtraToggleButtonColumnEnabled) + && "Column 0 is already used by \"expander toggle\" using special index -1"); + TriState eState = TRISTATE_INDET; GetQtInstance().RunInMainThread([&] { QModelIndex aIndex = nCol == -1 ? toggleButtonModelIndex(rIter) : modelIndex(rIter, nCol); @@ -795,9 +801,8 @@ void QtInstanceTreeView::make_sorted() GetQtInstance().RunInMainThread([&] { m_pTreeView->setSortingEnabled(true); - // sort by first "normal" column - const int nSortColumn = m_bExtraToggleButtonColumnEnabled ? 1 : 0; - m_pModel->sort(nSortColumn); + // sort by first column + m_pModel->sort(0); }); } @@ -1006,14 +1011,6 @@ QAbstractItemView::SelectionMode QtInstanceTreeView::mapSelectionMode(SelectionM } } -int QtInstanceTreeView::externalColumnIndex(const QModelIndex& rIndex) -{ - if (m_bExtraToggleButtonColumnEnabled) - return rIndex.column() - 1; - - return rIndex.column(); -} - QModelIndex QtInstanceTreeView::modelIndex(int nRow, int nCol, const QModelIndex& rParentIndex) const { @@ -1022,9 +1019,6 @@ QModelIndex QtInstanceTreeView::modelIndex(int nRow, int nCol, QModelIndex QtInstanceTreeView::modelIndex(const weld::TreeIter& rIter, int nCol) const { - if (m_bExtraToggleButtonColumnEnabled) - nCol += 1; - QModelIndex aModelIndex = static_cast<const QtInstanceTreeIter&>(rIter).modelIndex(); return m_pModel->index(aModelIndex.row(), nCol, aModelIndex.parent()); } @@ -1099,7 +1093,12 @@ void QtInstanceTreeView::handleDataChanged(const QModelIndex& rTopLeft, assert(rTopLeft == rBottomRight && "Case of multiple changes not implemented yet"); (void)rBottomRight; - signal_toggled(iter_col(QtInstanceTreeIter(rTopLeft), externalColumnIndex(rTopLeft))); + int nColIndex = rTopLeft.column(); + if (m_bExtraToggleButtonColumnEnabled && nColIndex == 0) + // use special index of -1 for the "expander toggle" + nColIndex = -1; + + signal_toggled(iter_col(QtInstanceTreeIter(rTopLeft), nColIndex)); } void QtInstanceTreeView::handleSelectionChanged()