vcl/qt5/QtBuilder.cxx | 26 ++++++++++++++++++++++++-- vcl/qt5/QtInstanceBuilder.cxx | 1 + 2 files changed, 25 insertions(+), 2 deletions(-)
New commits: commit c47029a8c5b7c376638aeb37c0e17bb0a3410a75 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Oct 4 10:59:54 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Oct 5 09:38:16 2024 +0200 tdf#130857 qt weld: Convert GTK to Qt accelerator/mnemonic When setting the checkbox text, don't pass the string as is, but convert to Qt's convention for the accelerator, using "&" instead of "_", using the existing helper function. This addresses the following issue mentioned in previous commit Change-Id: I15901f83192ba33ddc5c5eb779be680f26cb6b55 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Fri Oct 4 10:53:28 2024 +0200 tdf#130857 qt weld: Declare support for chart "Insert Axes" dialog > Mnemonic underlines for the checkboxes are currently > not the way they're meant to be, but that's a different > issue that will be addressed in a separate commit. Change-Id: I7b86adf396297de8de9b28fcb7e46c3428893c48 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174467 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx index 694e3fe1fa42..9c74d3f4fe96 100644 --- a/vcl/qt5/QtBuilder.cxx +++ b/vcl/qt5/QtBuilder.cxx @@ -301,7 +301,7 @@ void QtBuilder::setProperties(QObject* pObject, stringmap& rProps) if (rKey == u"active") pCheckBox->setChecked(toBool(rValue)); else if (rKey == u"label") - pCheckBox->setText(toQString(rValue)); + pCheckBox->setText(convertAccelerator(rValue)); } } else if (QDialog* pDialog = qobject_cast<QDialog*>(pObject)) commit 0a5354139af1a698eb372f839a8663a3f80d5fe3 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Oct 4 10:53:28 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Oct 5 09:38:08 2024 +0200 tdf#130857 qt weld: Declare support for chart "Insert Axes" dialog Add the .ui file for the "Insert Axes" chart dialog to the list of .ui files supported by QtInstanceBuilder. Now that Change-Id: Ie917a501466bad8821fc3e7f5049db7c1a56995f Author: Michael Weghorn <m.wegh...@posteo.de> Date: Fri Oct 4 10:38:32 2024 +0200 tdf#130857 qt weld: Create QGroupBox for "GtkFrame" added support for "GtkFrame", all widget types used by that dialog are handled by QtBuilder. This dialog can be seen as follows: * start Calc * "Insert" -> "Chart", confirm with "Finish" button * "Insert" -> "Axes" (while the chart is still selected) X and Y axes are shown/hidden as expected according to whether the corresponding checkboxes are ticked or unticked before closing the dialog using "OK". Mnemonic underlines for the checkboxes are currently not the way they're meant to be, but that's a different issue that will be addressed in a separate commit. Change-Id: I15901f83192ba33ddc5c5eb779be680f26cb6b55 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174466 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx index 84ba44341790..b4f608d49932 100644 --- a/vcl/qt5/QtInstanceBuilder.cxx +++ b/vcl/qt5/QtInstanceBuilder.cxx @@ -34,6 +34,7 @@ bool QtInstanceBuilder::IsUIFileSupported(const OUString& rUIFile) // what is relevant for that particular one, without having to implement the full // weld API at once. static std::unordered_set<OUString> aSupportedUIFiles = { + u"modules/schart/ui/insertaxisdlg.ui"_ustr, u"modules/swriter/ui/inforeadonlydialog.ui"_ustr, u"sfx/ui/licensedialog.ui"_ustr, u"sfx/ui/querysavedialog.ui"_ustr, commit e2e59d2da1aa4c9f8df62e5a072f0f2cd931781b Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Oct 4 10:38:32 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Oct 5 09:38:01 2024 +0200 tdf#130857 qt weld: Create QGroupBox for "GtkFrame" Handle "GtkFrame" objects from .ui files and create a QGroupBox [1] for them. While there's also a QFrame class in Qt, QGroupBox seems more suitable, as it allows setting a title, while QFrame doesn't. Add special handling for the label child of the "GtkFrame". Quoting from the GtkFrame doc [2]: > The GtkFrame implementation of the GtkBuildable interface supports > placing a child in the label position by specifying “label” as the > “type” attribute of a <child> element. A normal content child can be > specified without specifying a <child> type attribute. Example for a frame label in chart2/uiconfig/ui/insertaxisdlg.ui: <child type="label"> <object class="GtkLabel" id="label1"> <property name="visible">True</property> <property name="can-focus">False</property> <property name="hexpand">True</property> <property name="label" translatable="yes" context="insertaxisdlg|label1">Axes</property> <attributes> <attribute name="weight" value="bold"/> </attributes> </object> </child> In order to set the label's text as the text for the QGroupBox, identify that label child in QtBuilder::tweakInsertedChild, take over its text as the QGroupBox title, and mark the label for deletion, as it's no longer needed, since the QGroupBox handles its title itself from then on. [1] https://doc.qt.io/qt-6/qgroupbox.html [2] https://docs.gtk.org/gtk4/class.Frame.html Change-Id: Ie917a501466bad8821fc3e7f5049db7c1a56995f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174465 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx index 09d445e16740..694e3fe1fa42 100644 --- a/vcl/qt5/QtBuilder.cxx +++ b/vcl/qt5/QtBuilder.cxx @@ -17,6 +17,7 @@ #include <QtWidgets/QCheckBox> #include <QtWidgets/QDialog> #include <QtWidgets/QDialogButtonBox> +#include <QtWidgets/QGroupBox> #include <QtWidgets/QLabel> #include <QtWidgets/QLayout> #include <QtWidgets/QPushButton> @@ -143,6 +144,10 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, cons { pObject = new QDialog(pParentWidget); } + else if (sName == u"GtkFrame") + { + pObject = new QGroupBox(pParentWidget); + } else if (sName == u"GtkLabel") { pObject = new QLabel(pParentWidget); @@ -177,9 +182,26 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, cons return pObject; } -void QtBuilder::tweakInsertedChild(QObject*, QObject* pCurrentChild, std::string_view, +void QtBuilder::tweakInsertedChild(QObject* pParent, QObject* pCurrentChild, std::string_view sType, std::string_view) { + if (sType == "label") + { + if (QLabel* pLabel = qobject_cast<QLabel*>(pCurrentChild)) + { + if (QGroupBox* pGroupBox = qobject_cast<QGroupBox*>(pParent)) + { + // GtkFrame has a `child-type="label"` child for the GtkFrame label + // in the GtkBuilder .ui file, s. https://docs.gtk.org/gtk3/class.Frame.html + // For QGroupBox, the title can be set directly. Therefore, take over the + // title from the label and delete the separate label widget again + pGroupBox->setTitle(pLabel->text()); + pLabel->setParent(nullptr); + pLabel->deleteLater(); + } + } + } + if (QDialog* pDialog = qobject_cast<QDialog*>(pCurrentChild)) { // no action needed for QMessageBox, where the default button box is used