vcl/inc/qt5/QtInstanceDialog.hxx | 2 +- vcl/qt5/QtBuilder.cxx | 2 +- vcl/qt5/QtInstanceDialog.cxx | 32 ++++++++++++++++++++++++++++---- 3 files changed, 30 insertions(+), 6 deletions(-)
New commits: commit 5c114216707d5bbc52ac361c802a696f64f8016c Author: Michael Weghorn <[email protected]> AuthorDate: Fri Oct 4 14:49:12 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Sat Oct 5 09:39:02 2024 +0200 tdf#130857 qt weld: Show help when help button clicked Add special handling for the "Help" button in QtInstanceDialog::handleButtonClick: Don't close the dialog with the corresponding response code, but instead request help, by calling Help::Start with the widget's help ID and QtInstanceWidget as parameters. Together with the previous commit Change-Id: I274886d8045b31ccbc92f586e2ead20ff7407d15 Author: Michael Weghorn <[email protected]> Date: Fri Oct 4 14:41:29 2024 +0200 tdf#130857 qt weld: Handle help ID that implemented setting/getting the help ID for a QtInstanceWidget, this makes the "Axes" (online) help page show up when pressing the "Help" button in the "Insert Axes..." dialog when using the qt6 VCL plugin, which is using a native QDialog by default since Change-Id: I15901f83192ba33ddc5c5eb779be680f26cb6b55 Author: Michael Weghorn <[email protected]> Date: Fri Oct 4 10:53:28 2024 +0200 tdf#130857 qt weld: Declare support for chart "Insert Axes" dialog (See that commit's commit message for how to trigger the dialog.) See also Dialog::ResponseHdl for the VCL variant, which also has a corresponding special handling for the button with response code RET_HELP. Change-Id: I81e682822defec7a1e58d5a1b3b3eadc3f0040c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174482 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/inc/qt5/QtInstanceDialog.hxx b/vcl/inc/qt5/QtInstanceDialog.hxx index aa0027ac75a6..0de7a1858008 100644 --- a/vcl/inc/qt5/QtInstanceDialog.hxx +++ b/vcl/inc/qt5/QtInstanceDialog.hxx @@ -57,7 +57,7 @@ public: virtual weld::Container* weld_content_area() override; - static void handleButtonClick(QDialog& rDialog, const QAbstractButton& rButton); + static void handleButtonClick(QDialog& rDialog, QAbstractButton& rButton); /** * Name of the property to set on a QPushButton that holds the diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx index ad402df02043..da4bb8ec5974 100644 --- a/vcl/qt5/QtBuilder.cxx +++ b/vcl/qt5/QtBuilder.cxx @@ -221,7 +221,7 @@ void QtBuilder::tweakInsertedChild(QObject* pParent, QObject* pCurrentChild, std // connect button click handler const QList<QAbstractButton*> aButtons = pButtonBox->buttons(); - for (const QAbstractButton* pButton : aButtons) + for (QAbstractButton* pButton : aButtons) { assert(pButton); QObject::connect(pButton, &QAbstractButton::clicked, pDialog, diff --git a/vcl/qt5/QtInstanceDialog.cxx b/vcl/qt5/QtInstanceDialog.cxx index 99e90f3548fb..39346fcfddbc 100644 --- a/vcl/qt5/QtInstanceDialog.cxx +++ b/vcl/qt5/QtInstanceDialog.cxx @@ -10,6 +10,8 @@ #include <QtInstanceDialog.hxx> #include <QtInstanceDialog.moc> +#include <vcl/help.hxx> + const char* const QtInstanceDialog::PROPERTY_VCL_RESPONSE_CODE = "response-code"; QtInstanceDialog::QtInstanceDialog(QDialog* pDialog) @@ -157,15 +159,37 @@ void QtInstanceDialog::dialogFinished(int nResult) xRunAsyncDialog.reset(); } -void QtInstanceDialog::handleButtonClick(QDialog& rDialog, const QAbstractButton& rButton) +void QtInstanceDialog::handleButtonClick(QDialog& rDialog, QAbstractButton& rButton) { + SolarMutexGuard g; + QtInstance& rQtInstance = GetQtInstance(); + if (!rQtInstance.IsMainThread()) + { + rQtInstance.RunInMainThread([&] { handleButtonClick(rDialog, rButton); }); + return; + } + QVariant aResponseProperty = rButton.property(QtInstanceDialog::PROPERTY_VCL_RESPONSE_CODE); - if (aResponseProperty.isValid()) + if (!aResponseProperty.isValid()) + return; + + assert(aResponseProperty.canConvert<int>()); + const int nResponseCode = aResponseProperty.toInt(); + + // close dialog with button's response code unless it's the "Help" button + if (nResponseCode != RET_HELP) { - assert(aResponseProperty.canConvert<int>()); - const int nResponseCode = aResponseProperty.toInt(); rDialog.done(nResponseCode); + return; } + + // handle "Help" button + Help* pHelp = Application::GetHelp(); + if (!pHelp) + return; + + QtInstanceWidget aButtonWidget(&rButton); + pHelp->Start(aButtonWidget.get_help_id(), &aButtonWidget); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
