summaryrefslogtreecommitdiff
path: root/vcl/qt5/QtBuilder.cxx
AgeCommit message (Collapse)Author
2024-11-30tdf#130857 qt weld: Evaluate GtkTreeView:show-expanders propertyMichael Weghorn
Evaluate the GtkTreeView:show-expanders property [1] and set the QTreeView::rootIsDecorated propert accordingly [2]: > This property holds whether to show controls for expanding and > collapsing top-level items > > Items with children are typically shown with controls to expand and > collapse them, allowing their children to be shown or hidden. If this > property is false, these controls are not shown for top-level items. > This can be used to make a single level tree structure appear like a > simple list of items. With this in place, there are no more expanders shown for Calc's "Sheets" -> "Show Sheet" dialog for the native Qt version, just like with the gtk3 or gen versions. [1] https://docs.gtk.org/gtk3/property.TreeView.show-expanders.html [2] https://doc.qt.io/qt-6/qtreeview.html#rootIsDecorated-prop Change-Id: I11bcdd39695d230866abddf6d4b305dd6af52f59 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177548 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-30tdf#130857 qt weld: Evaluate tree view header visibilityMichael Weghorn
Take into account the "headers-visible" property for "GtkTreeView" in .ui files. With this in place, Calc's "Sheets" -> "Show Sheet" dialog no longer shows an unexpected "1" title above the list of hidden sheets. Change-Id: I054cca7e2b379782cf3548cb822ecdba0f5553d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177547 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-30tdf#130857 qt weld: Implement basic tree view logicMichael Weghorn
Implement a small subset of the QtInstanceTreeView methods - basically what is used by Calc's "Sheets" -> "Show Sheets" dialog for which support will be declared in an upcoming commit. In QtBuilder, ignore "GtkCellRendererText" and "GtkTreeSelection" objects, just as VclBuilder does. For now, also don't implement logic for handling "GtkTreeViewColumn" objects yet, but add a warning that this is still missing. Use QStandardItemModel for the tree view's model. For those methods where not all possible parameters are handled yet, add asserts that will trigger when called with currently still unsupported ones, so this can easily be identified when working on support for dialogs using more complex tree views in the future. QtInstanceTreeView::get_height_rows logic to return the required height to show n entries also still needs some thought, so the method simply warns and returns 0 for now, which means that the tree view might not be shown with the ideal initial height, but resizing the dialog is sufficient to work around that for now if needed. Change-Id: I13d9bd4a742c29a3dfc2c17b6c1a13f9fe40270e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177541 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-27tdf#130857 qt weld: Introduce custom QDoubleSpinBox subclassMichael Weghorn
Introduce a new QtDoubleSpinBox subclass for the stock QDoubleSpinBox and use it for the native Qt weld::SpinButton implementation. Initially, the new subclass doesn't add any additional functionality, but that will be added in future commits to provide functionality needed to implement more of the QtInstanceSpinButton methods. Change-Id: Icebbf6485172b065d6a6d2c1c8ef87be9d3d244e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177435 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-24tdf#130857 qt weld: Implement "GtkExpander" equivalentMichael Weghorn
Implement support for "GtkExpander" objects in .ui files. As Qt doesn't seem to have any equivalent, add a new QtExpander class that subclasses QWidget and has a button that can be used to toggle visibility of the widget that is the GtkExpander's [1] content child. For a visual appearance similar to GtkExpander, set an icon for the button ("go-down" and "go-next" from the icon theme, which are arrows like the ones shown on a GtkExpander, at least with the Breeze icon theme). In QtBuilder, implement handling for "GtkExpander" objects: * Create an instance of the new QtExpander class. * Identify the content child, which can be distinguished from the label child by the fact that the latter has a "label" child type set, see also previous commit Change-Id: I3e308a6642d72b55d0ccc597dac716b236c22d61 Author: Michael Weghorn <m.weghorn@posteo.de> Date: Sat Nov 23 20:54:47 2024 +0100 tdf#130857 Pass child type to WidgetBuilder::insertObject * Erase the "visible" property for the content child, as otherwise the content widget would be initially visible even if the expander is set to not be expanded. (QtExpander takes care of this, so ignore the property set in the .ui file.) * For the label child in GtkExpander, simply take over its text to QtExpander's button, then mark the label for deletion, as it's not needed otherwise. Support for the "Document in Use" dialog that has a GtkExpander and thuse makes use of this will be declared in a separate commit. [1] https://docs.gtk.org/gtk3/class.Expander.html Change-Id: Id2366834cb542eba613ea087e70f3a812d20fa89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177193 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-11-24tdf#130857 Pass child type to WidgetBuilder::insertObjectMichael Weghorn
In WidgetBuilder::handleChild, pass the child type not only to WidgetBuilder::tweakInsertedChild, but also to WidgetBuilder::handleObject (add a new param for that) and from there down into the virtual WidgetBuilder::insertObject, so it can be evaluated by subclasses when creating new widgets. While it is not used yet, an upcoming commit will make use of it in QtBuilder, in order to distinguish between the two "GtkExpander" children: the label and the actual content child. As described in the "GtkExpander as GtkBuildable" doc [1]: > The GtkExpander 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. [1] https://docs.gtk.org/gtk3/class.Expander.html Change-Id: I3e308a6642d72b55d0ccc597dac716b236c22d61 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177191 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-23tdf#130857 qt weld: Hide widget marked for deletionMichael Weghorn
Add a helper method QtBuilder::deleteObject that takes care of marking no longer needed objects for deletion and use it in the 3 places so far calling QObject::deleteLater themselves. If the object marked for deletion is a widget, hide it as well, as it could otherwise still be "in the way". This was seen wit the edit (QLineEdit) of the editable combobox in the "File" -> "Properties" dialog, "General" tab (in a WIP branch for adding support for that dialog), where the unnecessary edit was shown on top of the combobox, hiding the combobox content + dropdown button. Change-Id: Ie299b80824c94d40cfac9f7962c9bd4ba95b446d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177057 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-11-18qt: Update vim headers/trailersMichael Weghorn
Following commit 4f08a15f3be9b39d0f1e83e6cffa47b62c183b69 Author: lovatico21 <lorenzo04lovato@gmail.com> Date: Wed Nov 13 18:12:58 2024 +0100 updated vim footers in vcl/qt6/*.cxx , update vim header/trailers to those in current `TEMPLATE.SOURCECODE.HEADER` for other qt5/qt6 headers and sources as well (i.e. for directories `vcl/inc/qt5`, `vcl/inc/qt6` and `vcl/qt5/`). Change-Id: If9fea8f4ce955396f064dbd9fd706e76d947bce1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176705 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-16Fix typoAndrea Gelmini
Change-Id: Iffd36495c9a1424ad02756dbc9bde6ae55df86c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176662 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Jenkins
2024-11-11tdf#130857 VclBuilder: Complete moving XML parsing to base classesMichael Weghorn
Move VclBuilder::handleMenuObject to the WidgetBuilder template base class, and add a new purely virtual WidgetBuilder::insertMenuObject that the existing VclBuilder equivalent now overrides. This moves the remaining XML parsing logic from VclBuilder to one of the base classes (WidgetBuilder, BuilderBase), following the approach outlined in commit f61ecf25636d401f862c4de226c04237e1fb2f69 Author: OmkarAcharekar <omkaracharekar12@gmail.com> Date: Fri Sep 20 13:33:01 2024 +0200 tdf#130857 refactor VclBuilder: Extract template base class Update the source code comments accordingly. For QtBuilder, initially add a dummy implementation that simply triggers an assert, but can be adjusted in the future to create native Qt menus. Change-Id: I3147cac28c7273cd4c4ea7344a083cd66af8337f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176362 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-11tdf#130857 Add WidgetBuilder::createMenu, use to abstract from VCL-specificsMichael Weghorn
Add a new purely virtual WidgetBuilder::createMenu and use that in VclBuilder::handleMenu instead of directly calling VclPtr<PopupMenu>::Create there. This is in preparation of moving VclBuilder::handleMenu to WidgetBuilder as well, to make it reusable for other child classes, in particular QtBuilder. Change-Id: Icf3f937ea8e876c8393185e41a95e0f66458ce11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176360 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-11-11tdf#130857 tdf#142608 qt weld: Implement QtInstanceNotebook logicMichael Weghorn
Implement all of the QtInstanceNotebook methods, see also GtkInstanceNotebook and SalInstanceNotebook for the gtk3 and VCL implementations for comparison. Unlike weld::Notebook, QTabWidget doesn't have the concept of IDs for tabs in addition to indices. Introduce a PROPERTY_TAB_PAGE_ID property that gets set on the widget of the corresponding tabs and holds the tab identifier in order to support that. Implement QtBuilder::applyTabChildProperties to set the tab label and ID property by using the newly introduced QtInstanceNotebook::setTabIdAndLabel, so only QtInstanceNotebook needs to handle that property. The weld::Container* returned by QtInstanceNotebook::get_page is owned by QtInstanceNotebook, so keep create one on demand and keep a mapping between tab pages and the corresponding weld::Container. In QtInstanceNotebook::insert_page, create a new widget and set a QVBoxLayout for now. That could be changed to use a different QLayout class in the future if that turns out to be more useful. In QtBuilder::makeObject, as the tab pages are children of the "GtkNotebook" in the .ui file, they are initially created as child widgets of the QTabWidget. However, they need to be set via QTabWidget::setTab instead, so add special handling for that case towards the end and unset the parent relationship and call that method. Change-Id: I52e11ecf053a48940b88b7e6d1e6f9ba8778d9bb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176353 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-10tdf#130857 qt weld: Add QtInstanceNotebook skeletonMichael Weghorn
Add a new QtInstanceNotebook class that is the weld::Notebook implementation using a native Qt widget. It uses a QTabWidget. Initially, all methods trigger an assert; the actual logic still needs to be implemented in future commits. Let QtBuilder handle "GtkNotebook" objects by creating a QTabWidget and let QtInstanceBuilder::weld_notebook return an instance of the new class. Change-Id: I5a0671a1ba98bea3e0659e4f280706179bfb4d47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176322 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-10tdf#130857 VclBuilder: Split XML parsing + applying tab child propsMichael Weghorn
Split the existing VclBuilder::handleTabChild into two methods and make the logic not specific to vcl::Window available to other subclasses as well, to make it available for reuse by QtBuilder in the future. In order to do that, move the existing XML parsing logic from the beginning of VclBuilder::handleTabChild to the base class into WidgetBuilder::handleTabChild. Add a new purely virtual method `applyTabChildProperties` to WidgetBuilder and move the corresponding logic for vcl::Window to the new VclBuilder override of this method. Call that method at the end of WidgetBuilder::handleTabChild. For QtBuilder, just add a dummy implementation that triggers an assert initially, which matches what would have happened right at the beginning of the previous WidgetBuilder::handleTabChild implementation without this commit in place. Change-Id: Ie5664bd341182fa51035b547accf9393d65a0702 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176320 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-10tdf#130857 VclBuilder: Abstract tab control check from VCL detailsMichael Weghorn
In VclBuilder::handleTabChild, move casting the vcl::Window to TabControl further down to avoid vcl::Window specific code in the XML parsing logic. Introduce a new purely virtual helper method WidgetBuilder::isHorizontalTabControl, implement for VclBuilder and QtBuilder and use that in the XML parsing logic instead of directly checking whether the parent is a TabControl widget. This gets rid of one detail specific to the VCL implementation in the XML parsing part and is in preparation of further refactoring of VclBuilder::handleTabChild for reuse with QtBuilder. Change-Id: I05c637f81bce4a5cdd443960a1ad096c347df560 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176319 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-09tdf#130857 qt weld: Add QtInstanceTreeView skeletonMichael Weghorn
Add a new QtInstanceTreeView class that is the weld::TreeView implementation using a native Qt widget. It uses a QTreeView. Initially, all methods trigger an assert; the actual logic still needs to be implemented in future commits. Let QtBuilder handle "GtkTreeView" objects by creating a QTreeView. Let QtInstanceBuilder::weld_treeview return an instance of the new class. Change-Id: Ia3e694dbef9033fe45a6d2bdbe09fc021cd47c58 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176307 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-09tdf#130857 qt weld: Extract setting label propsMichael Weghorn
Move logic to set "GtkLabel" properties on a QLabel to a new helper method QtBuilder::setLabelProperties and call it right after creating the QLabel for a "GtkLabel", and only for that case. This also prevents potentially overwriting the text of a QtHyperlinkLabel widget created for a "GtkLinkButton" object in a .ui file, as that class also derives from QLabel, but has specialized handling for setting the label text to be a hyperlink. Change-Id: I8bfcc31a503a1c9deec32bcd584e1a86c3dfff19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176296 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-11-08tdf#130857 qt weld: Add initial SpinButton supportMichael Weghorn
Add new class QtInstanceSpinButton that is the weld::SpinButton implementation using native widgets. Initially, implement the actual logic of only some methods, and let the others trigger an assert for now. (These can be implemented once needed to support more dialogs.) Initially, assume that the value is an integer (which is the case for the "Table" -> "Insert" -> "Rows" dialog in Writer, for which support will be declared in an upcoming commit). However, already use a QDoubleSpinBox that supports floating point values instead of QSpinBox (that can only handle integer values) to prepare for extending the implementation accordingly later. In QtBuilder, handle "GtkSpinButton" objects, create a QDoubleSpinBox for them and evaluate the "digits" and "adjustment" properties to set the corresponding values for the QDoubleSpinBox. Let QtInstanceBuilder::weld_spin_button return an instance of the newly added class. Change-Id: I0808589a3e6bece749c0ae4541f2419410ea99bb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176248 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-07tdf#130857 qt weld: Add QtInstanceDrawingArea basicsMichael Weghorn
Add a new QtInstanceDrawingArea class as the weld::DrawingArea implementation using native Qt widgets. Initially only add the "basic structure" (most of the actual functionality of drawing will be added separately): * Add the QtInstanceDrawingArea class with most methods currently still unimplemented and triggering an assert when they get called. * Add a `ScopedVclPtrInstance<VirtualDevice> m_xDevice` member and return that in `QtInstanceDrawingArea::get_ref_device`, as the gtk3 implementation (GtkInstanceDrawingArea) does. * Let QtBuilder::makeObject create a QLabel for a "GtkDrawingArea" object for now. That label will hold a pixmap (which should be sufficient for simple cases at least). * Let QtInstanceBuilder::weld_drawing_area return an instance of the new class. Change-Id: I5d509ccd9f5a7a826a166958af4a92ff01cc0225 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176171 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-11-07tdf#130857 qt weld: Support "GtkSeparator"Michael Weghorn
Handle "GtkSeparator" objects in .ui files: Create a QFrame and, depending on the orientation set a shape of either QFrame::HLine ("QFrame draws a horizontal line that frames nothing (useful as separator)") or QFrame::VLine ("QFrame draws a vertical line that frames nothing (useful as separator)") [1]. This will be used e.g. in the "Help" -> "Show Tip of the Day" dialog. [1] https://doc.qt.io/qt-6/qframe.html#Shape-enum Change-Id: I41e69dd211cbb69cb7b23cc54640cd1fad655efc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176165 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-11-05tdf#130857 qt weld: Add extra QWidget parents for layoutsMichael Weghorn
For "GtkBox" and "GtkGrid" objects in .ui files, don't just create the corresponding QLayout objects, but create an extra QWidget object and set the layout for that widget, i.e. use that QWidget as the parent. While this generally wouldn't be needed to properly layout/handle things in Qt, having an associated QWidget for the "GtkBox" and "GtkGrid" children is needed in order to be able to create a corresponding weld::Container (QtInstanceContainer) for these, which derives from weld::Widget. QLayout itself doesn't have the methods required to implement weld::Widget, e.g. can't be hidden or shown. Therefore, create a QWidget for these in addition, except for special cases like the top-level layout in a dialog or the dialog's button box. For QGroupBox (created for "GtkFrame" objects), this now means that the direct child is no more necessarily a layout. Just setting a QWidget as a child wouldn't suffice for proper layouting. Therefore, explicitly create a layout for parent widgets that don't have a layout set yet. Adjust QtBuilder::applyPackingProperties accordingly as well. Now, there's no more use case to call QtBuilder::applyGridPackingProperties with a QLayout for the current child. Get the corresponding QWidget parent (if there is one) before calling the method instead, and switch the param from QObject* to QWidget* to simplify the method. Having an extra widget might have the side-effect that extra spacing/margins might be used. If that turns out to be a problem, these can presumably explicitly be reduced (e.g. set to 0 for the relevant objects) as needed later. At least the 19 dialogs currently listed as supported in QtInstanceBuilder::IsUIFileSupported still look OK to me in a quick test with this commit in place. Actually making use of the newly added widgets to implement more of the QtInstanceContainer logic will be done in separate commits. Change-Id: I3d3600ddfc7883239177aafed57629c107cbdf5d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176033 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-01tdf#130857 qt weld: Actually set link button URI as URIMichael Weghorn
Fix copy paste error: Take the value for the "uri" property whose existence was just checked, not the "label" one again as a few lines above. Change-Id: I1bf1251c14ba9dbda2b2f4ea73d35b612f4d0bb0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175888 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-10-30tdf#130857 qt weld: Add a QtInstanceProgressBarMichael Weghorn
Add a new QtInstanceProgressBar class that is the weld::ProgressBar implementation using a native Qt widget. The widget used is a QProgressBar. This will be used e.g. by the print progress dialog, for which support will be declared in an upcoming commit. Change-Id: Ic4b162014cd3a09801096cebd38dbdc923f5dbfa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175816 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-30tdf#130857 qt weld: Support hiding plain text in entryMichael Weghorn
Evaluate the "visibility" GtkEntry property [1] [2] and set the QLineEdit's echoMode [3] to QLineEdit::Password if the visibility is set to false, so that replacement characters are shown instead of the actual text as expected. This is used e.g. in password dialogs, e.g. in Writer: "File" -> "Properties" -> "Security", press "Protect..." button. (But this dialog is not using native Qt widgets yet, more needs to be implemented first.) [1] https://docs.gtk.org/gtk3/property.Entry.visibility.html [2] https://docs.gtk.org/gtk3/method.Entry.set_visibility.html [3] https://doc.qt.io/qt-6/qlineedit.html#echoMode-prop Change-Id: I218e4721bbc21f3d6a3553647e92c1ea7cdc4a0f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175806 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-30tdf#130857 qt weld: Add a QtInstanceLevelBarMichael Weghorn
Add a new QtInstanceLevelBar class that is the weld::LevelBar implementation using a native Qt widget. The widget used is a QProgressBar. This is used e.g. in password dialogs where the level bar is used as an indicator for the password strength, e.g. in Writer: "File" -> "Properties" -> "Security", press "Protect..." button. (But this is not using native Qt widgets yet, more needs to be implemented first.) Change-Id: I4400b8d1a03e8978bc96152166dec87f8134f48f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175805 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-10-29tdf#130857 qt weld: Set widget tooltip defined in .ui fileMichael Weghorn
If a tooltip is defined for a widget in a .ui file, set that tooltip using QWidget::setToolTip. This e.g. makes the tooltip for the copy button in the "Help" -> "About" dialog shown as "Copy all version information in English" when hovering over the button with the mouse. Change-Id: Ida22b3fb8b3626474d4377aac6c51d9f7c7ba2ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175775 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-29tdf#130857 qt weld: Set button image set in .ui fileMichael Weghorn
Implement logic to set the image for a button, as specified via the "image" property for the "GtkButton" object in the .ui file. Similar to how VclBuilder::makeObject does it, extract an icon name and load an image using that one for "GtkImage" obejcts. Add another static `toQPixmap` variant that takes an Image parameter and use that one for conversion. For buttons, if the "image" property is set, get the corresponding QLabel object, get the pixmap from that one and set an icon in the button from that. With this in place, when opening the "Help" -> "About LibreOfficeDev" dialog in a WIP branch adding "cui/ui/aboutdialog.ui" to the list of .ui files in QtInstanceBuilder::IsUIFileSupported, the button to copy the version information now shows the corresponding icon when using the qt6 VCL plugin. Change-Id: If87866d7ab935cbc4162fb513074eefda22c981a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175761 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-28tdf#130857 qt weld: Don't expect packing props on implicit gridMichael Weghorn
When the "left-attach" or "top-attach" packing properties are not set in QtBuilder::applyGridPackingProperties, just skip processing, but don't trigger an assert. While these packing properties should be set for every child of a "GtkGrid" object in .ui files, there's also the special case of QMessageBox, which uses a QGridLayout for its layout whereas the .ui file for a "GtkMessageDialog" uses a "GtkBox" instead. (See the special handling for "GtkBox" in QtBuilder::makeObject, where the QMessageBox's existing layout is used instead of setting another one.) Therefore, gracefully handle the case where the properties are not set. Without this, the "Save Document?" dialog triggered the assert since commit 3e28b4f0c97d011cf4222941f019ce05fe6b0313 Author: Michael Weghorn <m.weghorn@posteo.de> Date: Fri Oct 25 21:21:25 2024 +0200 tdf#130857 qt weld: Simplify QtBuilder::applyGridPackingProperties Change-Id: I03bc9799c142563ffbf0fa3eadb58bc63e6e23f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175722 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-26tdf#130857 qt weld: Evaluate + set grid item row/col spanMichael Weghorn
When processing packing properties for grid items, also take the "width" and "height" properties into account, which specify the column span and row span, respectively. Pass these as params as well when re-adding the item to the grid, not just the row/col index. With this in place, when opening the "Help" -> "About LibreOfficeDev" dialog in a WIP branch adding "cui/ui/aboutdialog.ui" to the list of .ui files in QtInstanceBuilder::IsUIFileSupported, the "imAbout" image on the left hand side of the dialog is now no longer restricted to the top left cell in the grid, but uses more space as expected. Change-Id: Ia2edb147d7576d863d597c01d4d310e8798a9ecc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175668 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-26tdf#130857 qt weld: Set actual positions for layouts inside gridMichael Weghorn
Extend QtBuilder::applyGridPackingProperties to not only handle widgets (QWidget), but also layouts (QLayout), so that the proper position inside the grid is also set for these. This will be used e.g. by the "Help" -> "About LibreOfficeDev" dialog. (When adding "cui/ui/aboutdialog.ui" to the list of .ui files in QtInstanceBuilder::IsUIFileSupported, those UI elements that show up are now in the correct positions, but other things unrelated to this particular commit are still missing.) Change-Id: Ic7c342e0307526f29e1fa149acd25a27373069ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175662 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-26tdf#130857 qt weld: Simplify QtBuilder::applyGridPackingPropertiesMichael Weghorn
No longer try to retrieve the current row and column of the widget in the QGridLayout and apply the "top-attach" and "left-attach" properties to set the new row and column separately. Instead, assume (and assert), that both, the new row and column properties are set, get them and then set the position using both of them at the same time. If any of the properties is missing, that most likely needs to be fixed in the .ui file. As a side note, something similar to the previous algorithm to determine the grid position might be useful to implement QtInstanceWidget::get_grid_left_attach etc. at some point. Change-Id: I22e34275e3974f42ca3ee43fa6cb66624e917443 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175661 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-26tdf#130857 qt weld: Add child layouts to gridMichael Weghorn
If a QLayout object is created as the child of a QGridLayout object (e.g. a "GtkBox" as the direct child of a "GtkGrid" in a .ui file), add that layout to the QGridLayout - initially in a new row, but rearranging that will be done as part of processing the "packing" properties of the children once that is implemented for layouts as well. (See QtBuilder::applyPackingProperties and QtBuilder::applyGridPackingProperties where this is currently only implemented for QWidget children). This will be needed e.g. for the "Help" -> "About LibreOfficeDev" dialog. Change-Id: I292134b26efa0dfe5c8fe0684dc02dece338d579 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175659 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-26tdf#130857 qt weld: Add a QtInstanceLinkButtonMichael Weghorn
Add a new QtInstanceLinkButton class that is the weld::LinkButton implementing using a native Qt widget. QLabel can be used to display a hyperlink, as it supports the HTML syntax for the text, so using , QLabel myLabel; myLabel.setText(QLatin1String("<a href=\"https://www.libreoffice.org">LibreOffice Website</a>")); can be used to let the QLabel handle a hyperlink. To make it simple to set this as needed for a QLabel, implement a new QLabel subclass called QtHyperlinkLabel that provides convenient getters and setters to set the displayed text and the link target, and takes care of setting the QLabel text based on that as needed. Implement QtInstanceLinkButton using an instance of that class as the widget and create an instance of that class in QtBuilder when encountering a "GtkLinkButton" object while processing a .ui file and evaluate the "label" and "uri" properties. Change-Id: I71d28b6e5e3cbd110ec5b3d1232d55e9d2bb8a1b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175656 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-10-26tdf#130857 qt weld: Add QtInstanceImage skeletonMichael Weghorn
Add a new class QtInstanceImage as a weld::Image implementation using native Qt widgets. It uses a QLabel that holds the Image, which can be set using QLabel::setPixmap [1]. This commit adds the new class, lets QtInstanceBuilder::weld_image return an instance of the new class, and extends QtBuilder to create a QLabel when it encounters a "GtkImage" object. The logic to actually set the image when either processing the .ui file or when one of the weld::Image::set_from_icon_name or one of the weld::Image::set_image variants gets called still needs to be implemented in subsequent commits for the label to actually display an image. [1] https://doc.qt.io/qt-6/qlabel.html#pixmap-prop Change-Id: I3aa526b89487a5301dabd108723d7b68ca85ea66 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175655 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-10-25tdf#130857 qt weld: Add QtInstanceRadioButtonMichael Weghorn
Implement initial support for native radio buttons using QRadioButton: * Let QtBuilder create a QRadioButton widget when it encounters a "GtkRadioButton" object. * Let QtBuilder::setProperties also handle the QRadioButton case. Both, QRadioButton and QCheckBox derive from QAbstractButton, so reuse the existing logic for QCheckBox to set label and checked status. * Add new class QtInstanceRadioButton as a weld::RadioButton implementation that uses a QRadioButton widget. * Let QtInstanceBuilder::weld_radio_button return an instance of the new class. For now, ignore the GtkRadioButton "group" property [1] that is used to group radio buttons. QRadioButton's are automatically grouped when they have the same parent widget, which is sufficient for the case of the "Alignment" dialog in Math for which support will be declared in an upcoming commit. For more complex scenarios, the use of QButtonGroup [2] could be implemented in the future to explicitly group radio buttons, as mentioned in the QRadioButton doc [3]: > If you need multiple exclusive button groups for radio buttons that > belong to the same parent widget, put them into a QButtonGroup. [1] https://docs.gtk.org/gtk3/property.RadioButton.group.html [2] https://doc.qt.io/qt-6/qbuttongroup.html [3] https://doc.qt.io/qt-6/qradiobutton.html Change-Id: Iaf8b0fef00fc10268c09410080156e7913634ab7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175639 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-10-25tdf#130857 qt weld: Handle combobox entries from .ui fileMichael Weghorn
Implement handling for combobox items in QtBuilder::insertComboBoxOrListBoxItems, similar to the VCL implementation in , similar to what's done in VclBuilder::insertComboBoxOrListBoxItems. This will be used e.g. by the "File" -> "Export As" -> "Export as EPUB" dialog (writerperfect/uiconfig/ui/exportepub.ui). Change-Id: Ie7a0f17c1a8ad523ca55c09dfce65a0b5d9cc41b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175572 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-10-24tdf#130857 qt weld: Handle entry for editable comboboxesMichael Weghorn
An editable GtkComboBox has a "has-entry" property of "true" and an internal GtkEntry child. Make the QComboBox editable depending on that "has-entry" property. Mark the QLineEdit object created for the "GtkEntry" for deletion again, as the QComboBox already has a QLineEdit by itself if it's editable, and the one created for the internal child would otherwise be useless and oddly overlap the combobox. (Seen e.g. with the "Tools" -> "Options" -> "Languages and Locales" -> "Writing Aids" -> "New" dialog" in a WIP branch where that dialog's .ui file ("cui/ui/optnewdictionarydialog.ui") was added to the list of supported files for QtInstanceBuilder. More work is needed on other aspects still.) Change-Id: I25ea74c732e60f50035604a4fc75dad50f4cf55f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175531 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-24qt: Have just a single toQString(const OUString&)Michael Weghorn
Move the `toQString` helper function to include/vcl/qt/QtUtils.hxx where it can be used from multiple modules, instead of defining it twice for both, avmedia (avmedia/source/qt6/QtPlayer.cxx) and vcl (vcl/inc/qt5/QtTools.hxx). Change-Id: I7ffe06eaa3aaf3e7c8cc7aa1a4ac41b14db5c20c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175526 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-10-23tdf#130857 qt weld: Add initial combobox handlingMichael Weghorn
* Add new class QtInstanceComboBox as a weld::ComboBox implementation using a native QComboBox. Implement some of the most important and straightforward methods and trigger an assert for all others for now. * In QtBuilder::makeObject, handle the "GtkComboBoxText" case and create a QComboBox for that. * Implement QtInstanceBuilder::weld_combo_box to return a QtInstanceComboBox instance. Change-Id: I2ac2d0f55a948ea2f090c81096484e22899ddcbc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175443 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-10-22tdf#130857 qt weld: Evaluate grid positionsMichael Weghorn
Implement handling for the "left-attach" and "top-attach" packing properties of "GtkGrid" children, which describe the column and row of these children within the grid. Introduce a new static helper method QtBuilder::applyGridPackingProperties that implements the handling for QWidget children for now. (Support for QLayout items within a grid will have to be added later in order to supported cases where e.g. a "GtkBox" is located inside of a "GtkGrid" in a .ui file.) In order to move the item to the proper position within the grid, first locate it to determine it's current row and column index, remove the item from the layout, and re-insert it at the new position. While this might not be the most efficient way of doing this, it is fairly easy to implement, without having to change the overall approach that QtBuilder, VclBuilder and the WidgetBuilder base currently process .ui files. This is sufficient for Writer's "Word Count" dialog, for which support will be declared in an upcoming commit. Change-Id: Ia296373c408e6cd84ffcc29b9d9a03d3c2441816 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175366 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-10-22tdf#130857 qt weld: Create QGridLayout for "GtkGrid"Michael Weghorn
Create a QGridLayout [1] when encountering a "GtkGrid" object in a .ui file. This will be needed e.g. by Writer's "Tools" -> "Word Count" dialog. With this commit in place, adding "modules/swriter/ui/wordcount.ui" to the list of supported .ui files in QtInstanceBuilder::IsUIFileSupported would already result in each of the labels in the dialog showing up, but each one as a single row rather than they being properly arranged in rows and columns. (That will be handled in an upcoming commit.) [1] https://doc.qt.io/qt-6/qgridlayout.html Change-Id: Ib9a9de4aa2820ac7e6771acf884072768508fe59 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175365 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-12tdf#130857 qt weld: Set visibility based on "visible" propMichael Weghorn
Use BuilderBase::extractVisible to assess and set the visibility of a QWidget created from a .ui file. As described in the GTK 3 documentation of the corresponding GtkWidget property [1], the default value is false, i.e. if an object is not explicitly set as visible, it should not be shown. This will be needed e.g. by the svtools/uiconfig/ui/restartdialog.ui dialog shown when toggling experimental mode in "Tools" -> "Options" and closing the dialog with the "OK" button. Without this preparatory commit, using native Qt widgets would result in all the labels (with different reasons for restarting) being shown at the same time. This depends on previous commit Change-Id: Ic7a932556e02f47ee6007b5167f82bef152e1ef0 Author: Michael Weghorn <m.weghorn@posteo.de> Date: Fri Oct 11 23:01:44 2024 +0200 tdf#130857 VclBuilder: Move internal child visible logic to base to not cause buttons in dialogs to become invisible if they're contained in the "internal" button box object whose visibility is usually not explicitly set to True. [1] https://docs.gtk.org/gtk3/property.Widget.visible.html Change-Id: Iff254324a852a2fe73b3d9fcfe499bc8639380b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174834 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-10-07tdf#130857 qt a11y weld: Handle "accepts-tab" text view propertyMichael Weghorn
Evaluate the "accepts-tab" GtkTextView property [1] and set the `tabChangesFocus` QPlainTextEdit property based on that, so tab moves focus to the next control when "accepts-tab" is set to false in a "GtkTextView" object in a .ui file, like the ones where this property was newly set in previous commit Change-Id: I4bbecfc3f967b83768319e68ea3fb1f89b4c5014 Author: Michael Weghorn <m.weghorn@posteo.de> Date: Mon Oct 7 08:10:56 2024 +0200 a11y: Leave accessible description text view on simple tab key (They're not yet supported by QtInstanceBuilder yet, but once they are, that will work as expected.) [1] https://docs.gtk.org/gtk3/property.TextView.accepts-tab.html [2] https://doc.qt.io/qt-6/qplaintextedit.html#tabChangesFocus-prop Change-Id: Ib1d33f37016a2601aa9ab9c370c9076dbae5bed3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174570 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-10-05tdf#130857 qt a11y weld: Convert accelerator for labelsMichael Weghorn
Convert the accelerator from GTK to Qt convention for labels as well, to not display a literal "_", but use the next letter as the accelerator. For Qt, a literal "&" would still be displayed if no buddy is actually set, i.e. there is no related widget that can receive keyboard focus when the accelerator key is pressed together with Alt. Setting buddies was implemented in previous commit Change-Id: Iba1e766c0f2c5162beb5b938c134afab0dac68b7 Author: Michael Weghorn <m.weghorn@posteo.de> Date: Fri Oct 4 22:56:05 2024 +0200 tdf#130857 qt a11y weld: Set "buddy" (mnemonic widget) . Together with the above commit, this commit makes the "Alt Text" label in the "Alt Text" dialog (cui/ui/objecttitledescdialog.ui) show up as expected with qt6 in a WIP branch that declares that .ui file as supported in QtInstanceBuilder::IsUIFileSupported, while it was previously shown as "_Alt Text". Change-Id: Ief58dfc6864da9043766eec4eec36da44ae7017b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174511 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-05tdf#130857 qt a11y weld: Set "buddy" (mnemonic widget)Michael Weghorn
Based on previous commits Change-Id: I878eec7be5e82fac3e1b944d7fed7bf6711744ce Author: Michael Weghorn <m.weghorn@posteo.de> Date: Fri Oct 4 22:04:08 2024 +0200 tdf#130857 VclBuilder: Move mnemonic-widget bookkeeping to base class and Change-Id: I32c922f91e5e1d06c003e6d26a4342cbb98942e1 Author: Michael Weghorn <m.weghorn@posteo.de> Date: Fri Oct 4 22:18:17 2024 +0200 tdf#130857 VclBuilder: Extract setMnemonicWidget helper + call from base , implement handling for mnemonic widgets for labels for native Qt widgets in QtBuilder: * call BuilderBase::extractMnemonicWidget when processing a "GtkLabel" object, in the same way that VclBuilder does that. * implement actually setting the mnemonic widget by calling QLabel::setBuddy [1] in QtBuilder::setMnemonicWidget to set the "buddy" (mnemonic widget) This makes Orca in a WIP branch to support a native qt6 "Alt Text" dialog announce the label text as well when the corresponding QLineEdit/QPlainTextEdit receives focus, as setting the buddy also ensures that the accessible labelledy-by/label-for relations get reported on the AT-SPI layer, see also commit 09789838bbbe57d207a66532b38cbba67ec59d70 Author: Michael Weghorn <m.weghorn@posteo.de> Date: Fri Oct 4 21:39:44 2024 +0200 tdf#119931: cui a11y: Specify mnenomic-widget in "Alt Text" dialog which describes the scenario a bit more for the gtk3 variant. [1] https://doc.qt.io/qt-6/qlabel.html#setBuddy Change-Id: Iba1e766c0f2c5162beb5b938c134afab0dac68b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174510 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-05tdf#130857 VclBuilder: Extract setMnemonicWidget helper + call from baseMichael Weghorn
Instead of iterating over the map of mnemonic widgets in the VclBuilder ctor, split the logic: Add a new purely virtual WidgetBuilder::setMnemonicWidget method to the base class that passes the IDs of a single pair of label + the corresponding mnemonic widget as params, and let WidgetBuilder::processUIFile call the method once for every pair in the map. Implement that for VclBuilder (by moving the remaining logic for that previously in the ctor) to the new override VclBuilder::setMnemonicWidget and add a dummy implementation for QtBuilder that only triggers a warning for now. Change-Id: I32c922f91e5e1d06c003e6d26a4342cbb98942e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174509 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-05tdf#130857 qt weld: Add a QtInstanceTextViewMichael Weghorn
Add a native Qt implementation for weld::TextView QtInstanceTextView, that uses a QPlainTextEdit, and let QtInstanceBuilder use it when it encounters a "GtkTextView" object in a .ui file. Implement methods which are probably the most relevant ones. For now, trigger an assert in case any of the not yet implemented methods gets called. None of the .ui files currently marked as supported by QtInstanceBuilder uses this new class yet, but it will be needed to support more in the future, e.g. for cui/uiconfig/ui/objecttitledescdialog.ui. With this commit in place, adding that file to the set of supported ones in QtInstanceBuilder::IsUIFileSupported makes the dialog somehow show up as a native Qt dialog with the qt6 VCL plugin when e.g. selecting a QR code in an existing document, then opening the context menu and choosing "Alt Text", but there are various issues that still need to be fixed before it can actually be claimed as working/supported. Change-Id: Id7217d4a8a86f953d8b289c8a09cb8d1e2040bf1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174495 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-05tdf#130857 qt weld: Add basic handling for "GtkScrolledWindow"Michael Weghorn
Create a QScrollArea when encountering a "GtkScrolledWindow" object in a .ui file. This commit does not yet implement an actual Qt-native weld::ScrolledWindow, i.e. QtInstanceBuilder::weld_scrolled_window currently still triggeres an assert. This will help to support cui/uiconfig/ui/objecttitledescdialog.ui, which has a GtkScrolledWindow, but SvxObjectTitleDescDialog doesn't explicitly interact with it, so this basic implementation is sufficient for a start. Change-Id: I80d2565e57809be0cc3ae452359d0d1b827e46f6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174494 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
2024-10-05tdf#130857 qt weld: Add QtInstanceEntryMichael Weghorn
Add a native Qt implementation for weld::Entry, QtInstanceEntry, that uses a QLineEdit, and let QtInstanceBuilder use it when it encounters a "GtkEntry" object in a .ui file. Implement the most straightforward and probably most relevant methods, and trigger an assert in case one of the not yet implemented methods gets called for now. These can be implemented when adding support for .ui files whose dialogs make use of these features. None of the .ui files currently marked as supported by QtInstanceBuilder uses this new class yet, but it will be needed to support more in the future. Change-Id: I56e26fe22b1cc0cb7d61cfd1503991273957e23f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174489 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-05tdf#130857 qt weld: Show help when help button clickedMichael Weghorn
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 <m.weghorn@posteo.de> 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 <m.weghorn@posteo.de> 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 <m.weghorn@posteo.de>