64 Commits
Author SHA1 Message Date
Michael Weghorn 1959e62ea3 tdf#130857 qt weld: Add initial dummy SizeGroup implementation
Introduce QtInstanceSizeGroup as the Qt-based
weld::SizeGroup implementation.

Initially, this is doesn't actually implement the
logic to keep widgets that are added at the same
size, but emits warnings when its methods are
called.

Change-Id: I26dcab92a13ca4a4907c06d5834d98d566246920
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203995
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-04-21 10:25:52 +02:00
Michael Weghorn 23d652f883 qt: Use Q_OBJECT macro for QtInstanceFrame
Be consistent with other QtInstance* classes and
follow the recommendation in [1]:

> Notice that the Q_OBJECT macro is mandatory for any object that
> implements signals, slots or properties. You also need to run the Meta
> Object Compiler on the source file. We strongly recommend the use of
> this macro in all subclasses of QObject regardless of whether or not
> they actually use signals, slots and properties, since failure to do so
> may lead certain functions to exhibit strange behavior.

[1] https://doc.qt.io/qt-6/qobject.html#details

Change-Id: I9acd0fa95769959587ff14b95702e8306aa715da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202847
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-03-27 15:07:07 +01:00
Michael Weghorn f2a6ca180e qt: Make svp-specific code (Cairo rendering) dependent on USE_HEADLESS_CODE
The classes whose name starts with "QtSvp" depend on svp/headless
code that is only built when USE_HEADLESS_CODE is true
(see vcl/Library_vcl.mk).

Therefore, make the code in the qt5/qt6 VCL plugins
depending on them also dependent on the same condition.

This helps prepare for adding support for the qt6
vcl plugin on Windows (see WIP change at [1]) where
headless code is currently not built by default.

[1] https://gerrit.libreoffice.org/c/core/+/199615

Change-Id: I2c957b96be2e29eb2ba4fe864fbae46e1ecd3fbe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201615
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-03-15 17:45:40 +01:00
Michael Weghorn b7b7e31ed3 qt: Move graphics backend specific logic to new QtInstance subclasses
Similar to how

    commit 6717d7612e
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Thu Mar 12 20:34:40 2026 +0100

        qt: Move graphics backend specific logic to new QtFrame subclasses

had done for QtFrame, also move out the logic specific
to the (currently) two different supported graphics backends
out of QtInstance, into two new subclasses:

* QtSvpSalInstance for the case of Cairo rendering
* QtSalInstance for the case of non-Cairo rendering

Let create_SalInstance() create an instance of
the corresponding new subclass, depending on whether
or not the use of Cairo is enabled.

Do likewise for the kf5/kf6 VCL plugin, where
a KFInstance subclassing the new QtInstance
subclasses is created now.

Change-Id: Ib9312eeb00aabedc4966cb6619151e44cdbf4b05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201605
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-03-15 17:44:16 +01:00
Michael Weghorn 6717d7612e qt: Move graphics backend specific logic to new QtFrame subclasses
As outlined in previous commit

    Change-Id: Id96fa83f3a348cbc1816b87a9ca6141936736bf0
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Thu Mar 12 17:56:45 2026 +0100

        qt: Extract rendering backend specific code to new helper methods

, move the graphics backend specific logic out of
QtFrame into 2 new subclasses that each implement
one of the two currently supported graphics backends.

Turn the new helper methods introduced in the
above-mentioned commit into new purely virtual
protected methods in the QtFrame base class
and override them in the 2 new subclasses.

Move the Cairo-based logic to QtSvpSalFrame, the
non-Cairo one to QtSalFrame.

In QtInstance, create an instance of the
new subclasses, depending on whether Cairo or
the QFont rendering path shall be used.

No change in behavior expected or seen in a quick
test with and without SAL_VCL_QT_USE_QFONT=1
(the latter enables the use of the non-Cairo
rendering path, which currently triggers an
assert, but that is unrelated to this commit).

Change-Id: I91f4bda82f8a841b83f43110287f69c1879bf3ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201575
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-03-13 07:48:49 +01:00
Michael Weghorn a7a8c98858 tdf#130857 qt weld: Call TreeView signal hdls when editing starts/ends
weld::TreeView has signal_editing_started
and signal_editing_done methods that are supposed
to be called by the toolkit-specific weld::TreeView
implementations when editing is about to start
and when it is about to end.

weld::TreeView::signal_editing_started returns a
bool indicating whether or not editing should
actually start for the given index/entry.

weld::TreeView::signal_editing_done returns a
bool indicating whether the entry should actually
be updated with the newly typed text.

In addition, the handlers connected to those signals
may do additional work.

For the Qt-based implementation, introduce a custom
item delegate called QtTreeViewItemDelegate
that subclasses QStyledItemDelegate. As [1] says:

> QStyledItemDelegate is the default delegate for all Qt item views, and
> is installed upon them when they are created.

In the new QtTreeViewItemDelegate class,
override the methods that get called when the editor
gets created and when the model data is supposed to get
updated. Call the weld::TreeView signal handlers and return
early in case they return false.

In QtTreeViewItemDelegate::setModelData, only handle the
case where the editor is a QLineEdit, which is used
for editing (single-line) strings, as that is what
weld::TreeView::signal_editing_done also expects.

The newly introduced logic will e.g. be used by Writer's
"Insert" -> "Bookmark" dialog once it is declared as supported
by QtInstanceBuilder, which will happen in an upcoming commit.

Sample scenario:

* start Writer
* type "Hello world"
* select the text
* "Insert -> Bookmark"
* confirm bookmark creation with "Insert"
* "Insert" -> "Bookmark"
* select the treeview entry
* press the "Edit Text" button
* type new text "Something else" and press Enter to confirm

-> The text in the document is changed to "Something else"
by the handler called by the call to
weld::TreeView::signal_editing_done.

[1] https://doc.qt.io/qt-6/qstyleditemdelegate.html#details

Change-Id: I98ea4e9237ac3174c6049075cf0ecb04b2448167
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197890
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-01-23 10:41:23 +01:00
Michael Weghorn c1fbad5477 tdf#130857 qt weld: Add custom class for QtInstanceTreeView model
Instead of using Qt's QSortFilterProxyModel directly
for the model of the QTreeView used in QtInstanceTreeView,
introduce a new subclass QtTreeViewModel that will be used
to customize behavior to account for the weld::TreeView
requirements.

Initially, only move the logic to set the
underlying QStandardItemModel into the new
class.
No change in behavior intended yet.

Further changes will follow in upcoming commits,
in order to implement support for on-demand children
and distinguising between readonly and editable columns
(see the currently still unimplemented methods
QtInstanceTreeView::do_set_children_on_demand and
QtInstanceTreeView::set_column_editables).

Change-Id: Ic5165e99b9fa3e3c51ade7863f979e2067496f9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197264
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-01-15 01:34:08 +01:00
Michael Weghorn 711d389c0c tdf#130857 qt weld: Introduce QtInstancePaned
Introduce QtInstancePaned as weld::Paned implementation
using a native QSplitter and return an instance
in QtInstanceBuilder::weld_paned.

Creating a QSplitter for a "GtkPaned" object in a .ui
file was already implemented in previous commit

    commit 78a2703354
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Thu Dec 19 23:35:40 2024 +0100

        tdf#130857 qt weld: Create QSplitter for "GtkPaned"

Implementing the actual logic for
QtInstancePaned::{g,s}et_position is left for a
future commit.

Change-Id: Iff4b24368aa4ac5006adf4944d6ea2db0a70c7ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196897
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-01-10 23:19:46 +01:00
Michael Weghorn e16e437d16 tdf#130857 qt weld: Introduce QtInstanceTextWidget
Move the duplicate logic to set the font (color) from
QtInstanceEntry and QtInstanceTextView to a new
shared base class QtInstanceTextWidget.

Change-Id: I817aa8342b6126c8dcdd1cf2a6f0b137faf12db1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196457
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-01-04 15:04:50 +01:00
Michael Weghorn 63b6ce5cba tdf#130857 qt weld: Introduce QtInstanceItemView
This is the implementation for the abstract
weld::ItemView class introduced in

    commit 94aee0cd3d
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Wed Dec 17 12:14:41 2025 +0100

        weld: Introduce weld::ItemView as IconView/TreeView base

Having an equivalent for the Qt-based weld implementation
will allow sharing code between QtInstanceIconView
and QtInstanceTreeView.

In an initial step, deduplicate the weld::ItemView::do_clear
implementations by moving the QtInstanceTreeView one to
the new base class and dropping the implementations in the
subclasses.

Change-Id: I91edd89743afc5cfa53d3b8343a3a69ab0a0c51b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195795
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-12-18 07:20:24 +01:00
Michael Weghorn 6835fbc81e tdf#130857 qt weld: Introduce QtInstanceSpinner
This is the weld::Spinner implementation using a
native Qt widget.

There seems to be no direct equivalent for GTK's
GtkSpinner, whose doc [1] says:

> A GtkSpinner widget displays an icon-size spinning animation. It is
> often used as an alternative to a GtkProgressBar for displaying
> indefinite activity, instead of actual progress.

QProgressBar does support an undeterminate state however.
Quoting from the QProgressBar::setRange doc [2]:

> The QProgressBar can be set to undetermined state by
> using setRange(0, 0).

Use a QProgressBar in undeterminate state, and simply
show/hide the widget in the weld::Spinner::start
and weld::Spinner::stop overrides.

[1] https://docs.gtk.org/gtk3/class.Spinner.html
[2] https://doc.qt.io/qt-6/qprogressbar.html#setRange

Change-Id: I555b6b21d1a610aae4deecf7402ef9ebc00f0863
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188391
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-07-29 10:00:54 +02:00
Michael Weghorn 072010169b tdf#167669 tdf#130857 qt: Use native QColorDialog
Similar to how previous commit

    Change-Id: If5bfb453b55c905ffe332707e2fb261a48664c31
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Fri Jul 25 14:55:34 2025 +0200

        tdf#167669 gtk: Use native GtkColorChooserDialog

introduced the use of the native GtkColorChooserDialog
for gtk3 and gtk4, use the native QColorDialog [1]
for the Qt-based VCL plugins.

Like GtkColorChooserDialog, it also has the advantage
of providing a color picker to select a color from a pixel
on screen, which the custom LO implementation doesn't have.

[1] https://doc.qt.io/qt-6/qcolordialog.html

Change-Id: If371d75c8a2687430a89de798d50aa10b8db1c29
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188345
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-07-25 19:58:15 +02:00
Michael Weghorn d257afba4d qt: Make QtDropTarget a QObject
This will allow to switch QtFrame::m_pDropTarget
to a QPointer in an upcoming commit.

Change-Id: Ic36b25a524a880d3d04805dbd1fde1ef80b17ca6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187112
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-06-27 19:45:29 +02:00
Michael Weghorn be3e1d32a8 tdf#130857 qt weld: Introduce QtInstanceCalendar
This is the weld::Calendar implementation using
a native QCalendarWidget.

It's not used in practice yet, as no dialog using
it has been declared as supported yet, but this
is one step in preparation of doing so in the future.

Change-Id: I8a65701a1aa477a04dcf66f63df7864db0b0cdf4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186010
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-05-30 07:46:32 +02:00
Michael Weghorn e5e4873576 tdf#130857 qt: Let QtAccessibleWidget subclass QObject
This will allow to pass it in a QVariant, which will
be used to support custom accessible implementations
for QtInstanceDrawingArea in
QtInstanceBuilder::weld_drawing_area in an upcoming
commit.

At least the Qt 5 moc does not process Qt version
checks like

    #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)

which would result in failures like

    In file included from /home/michi/development/git/libreoffice/vcl/qt5/QtAccessibleWidget.cxx:21:
    /home/michi/development/git/libreoffice/workdir/CustomTarget/vcl/qt5/QtAccessibleWidget.moc:91:29: error: unknown type name 'QAccessibleAttributesInterface'; did you mean 'QAccessibleActionInterface'?
       91 |         return static_cast< QAccessibleAttributesInterface*>(this);
          |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |                             QAccessibleActionInterface
    /usr/include/x86_64-linux-gnu/qt5/QtGui/qaccessible.h:627:20: note: 'QAccessibleActionInterface' declared here
      627 | class Q_GUI_EXPORT QAccessibleActionInterface
          |                    ^
    In file included from /home/michi/development/git/libreoffice/vcl/qt5/QtAccessibleWidget.cxx:21:
    /home/michi/development/git/libreoffice/workdir/CustomTarget/vcl/qt5/QtAccessibleWidget.moc:97:29: error: unknown type name 'QAccessibleSelectionInterface'; did you mean 'QAccessibleActionInterface'?
       97 |         return static_cast< QAccessibleSelectionInterface*>(this);
          |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |                             QAccessibleActionInterface
    /usr/include/x86_64-linux-gnu/qt5/QtGui/qaccessible.h:627:20: note: 'QAccessibleActionInterface' declared here
      627 | class Q_GUI_EXPORT QAccessibleActionInterface
          |                    ^
    2 errors generated.

Explicitly exclude the Qt >= 6.x specific
code in the header from the moc run by making it
conditional on

    #ifndef Q_MOC_RUN

to make that work.

Change-Id: I1ea3c37d0041dac89d632970d810ae951ff4afbb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184876
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-05-02 09:32:16 +02:00
Michael Weghorn e61a6f9598 tdf#130857 qt weld: Introduce QtInstanceEntryTreeView
This is the weld::EntryTreeView implementation
using native Qt widgets.

A weld::EntryTreeView is a combobox-like widget,
but consisting of two widgets: a weld::Entry and
a weld::TreeView.

In QtInstanceEntryTreeView, implement logic similar
to the GTK (GtkInstanceEntryTreeView) and VCL
(SalInstanceEntryTreeView) implementations:

* Auto-completion based on the tree view entries
  when typing in the entry/edit
* automatically selecting the corresponding tree
  view entry when the entry/edit text matches one
* forward (page) up/down key events on the entry/edit
  to the tree view, so this can be used to navigate
  through the entries

This worked as expected in a quick test of Math's font
dialog that can be triggered as follows:

* "Format" -> "Fonts"
* click the "Modify" menu buttton and select any entry

Support for that dialog will be declared in QtInstanceBuilder
in a separate commit.

Change-Id: Ide3063e27dd36e87539b9eaf7165dc073669323f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184362
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-04-19 09:50:56 +02:00
Michael Weghorn 5d5b1c0c1b tdf#130857 qt weld: Add Q_OBJECT macro to QtHyperlinkLabel
This is needed to `qobject_cast` to that class.

This prepares for upcoming commit

    Change-Id: I5e8c9f9bc441f2c60d7a6b78ba52c7027d3fab7d
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Mon Mar 10 13:00:11 2025 -0700

        tdf#130857 qt weld: Assert type before static_cast

Change-Id: I89b930d4cacbf11ab5e85f627c0caf7aebaf61d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182751
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-03-11 04:52:37 +01:00
Michael Weghorn 7d467fab95 tdf#130857 qt weld: Introduce QtInstanceScrollbar
Add new class QtInstanceScrollbar as the weld::Scrollbar
implementation using a native QScrollBar.

QtInstanceScrolledWindow already contains similar logic
to what is needed for some of the methods.

Extend QtBuilder to create a QScrollBar for "GtkScrollbar"
objects.

Change-Id: Iccb08659852f216df143e2d4293eead2bc9215f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182401
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-03-02 11:52:40 +01:00
Michael Weghorn ffd236bdf8 tdf#130857 qt weld: Introduce QtInstanceAssistant
Add new class QtInstanceAssistant as the weld::Assistant
implementation using native Qt widgets.

A QWizard is used for the widget.

This commit introduces QtInstanceAssistant and adds an
initial implementation for most of its methods.
(Others still need to be added in the future and
calling them currently triggers an assert.)

While GtkAssistant [2] and weld::Assistant use
indices to identify pages, QWizard uses IDs. For now,
assume that those are equivalent. Some extra logic may
be needed to ensure this in the future (or an implementation
that is not built on this assumption).
The OUString identifier used in the weld::Assistant
API is something different and set as the QObject::objectName
property of the pages.

In QtBuilder, create a QWizard widget when encountering
a "GtkAssistant" object in a .ui file.

[1] https://doc.qt.io/qt-6/qwizard.html
[2] https://docs.gtk.org/gtk3/class.Assistant.html

Change-Id: I91b44da40736f6e61c64167d00305a1d7ba06b45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182036
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-02-23 10:14:26 +01:00
Michael Weghorn 2bd9ff78c7 tdf#130857 qt weld: Introduce QtInstanceFormattedSpinField
This is the weld::FormattedSpinField implementation
using a native Qt widget.

Implementation mostly inspired by the GTK implementation
in GtkInstanceFormattedSpinButton as well as
QtInstanceSpinButton.

What's still missing is to implement the conversion
between value and text (both ways) similar to what

    commit 6871b55b69
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Sat Feb 15 17:47:01 2025 +0100

        tdf#130857 qt weld: Implement SpinButton text <-> value conversion

implemented for QtInstanceSpinButton.

However, this needs more refactoring elsewhere first.

Change-Id: I06647dc1b43a05dd86d4488f213d0f0c72566cd8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181847
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-02-19 08:29:50 +01:00
Michael Weghorn d7fd4f2f84 tdf#130857 qt weld: Introduce QtInstanceBox
Introduce QtInstanceBox as the weld::Box implementation
using native Qt widgets.

weld::Box is used e.g. in the (not yet supported by
QtInstanceBuilder) macro security dialog, which however
doesn't make use of any weld::Box-specific API
(only uses the weld::Container API), so leave
implementing the logic for those for later.

Change-Id: I6d3948e1282dd6178a3762c235bd8fc97c6e9e34
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180609
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-01-23 08:29:22 +01:00
Michael Weghorn bcc518102a tdf#130857 qt weld: Introduce QtInstanceToolbar
Introduce QtInstanceToolbar as the native Qt implementation
for weld::Toolbar that uses a QToolBar widget.

This mostly adds the basic structure and lets Qt{,Instance}Builder
create an instance of the class when encountering a
"GtkToolbar" object in a .ui file.

The actual logic for the QtInstanceToolbar methods
still needs to be implemented. Calling them currently
triggers an assert.

Change-Id: I2734e5b931d5cb9608ec4d01222634a8ffada299
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179883
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-01-08 09:52:01 +01:00
Michael Weghorn a7428730f7 tdf#130857 qt weld: Introduce QtInstancePopover
When encountering a "GtkPopover" object in a .ui
file, create a QWidget with window flags Qt::Popup
and set a layout, as weld::Popover is a weld::Container
subclass.

Add new QtInstancePopover that QtInstanceBuilder::weld_popover
creates.
For now, methods in that class simply trigger an assert;
actual logic still needs to be implemented.

Change-Id: I9a0dfefd9fb79d24fe40dd5efe13ef0c3ab9b7fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179098
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-12-22 11:41:20 +01:00
Michael Weghorn b8ca64234f tdf#130857 qt weld: Introduce QtInstanceMenu
Introduce QtInstanceMenu as the native Qt implementation
for weld::Menu.

This mostly adds the basic structure.
For all methods except QtInstanceMenu::clear,
the actual logic still needs to be implemented.

Change-Id: I983f2cd3976eee50f55b2ac702578833dbad3d39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178964
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-12-21 09:29:21 +01:00
Michael Weghorn a6f206c92d tdf#130857 qt weld: Introduce QtInstanceMenuButton
Add new QtInstanceMenuButton class as the native Qt
weld::MenuButton implementation.

The actual logic of the class methods still needs to
be implemented, they all just trigger an assert when
called right now.

Create a QToolButton for "GtkMenuButton" objects in .ui files.

Let QtInstanceBuilder::weld_menu_button create an instance
of that new class and pass the button in the ctor.

Change-Id: Ie5ba0bad8e351554323e8f4ec1281b2c5ae8fbc3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178963
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-12-21 09:29:01 +01:00
Michael Weghorn 9bce3ab468 tdf#130857 qt weld: Add QtInstanceScale
QSlider [1] is the Qt equivalent for GtkScale [2],
so use it.

[1] https://doc.qt.io/qt-6/qslider.html
[2] https://docs.gtk.org/gtk4/class.Scale.html

Change-Id: I0d04b4db0b4531daba1e1110879acf85aff53aa3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178867
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-12-20 12:07:04 +01:00
Michael Weghorn feaf080065 tdf#130857 qt weld: Add a QtInstanceToggleButton
QAbstractButton, which is a base class for both,
QPushButton and QToggleButton already provides the
API needed for toggling.

Use a QToggleButton, as the QPushButton doc [1] says:

> As a general rule, use a push button when the application or dialog
> window performs an action when the user clicks on it (such as Apply,
> Cancel, Close and Help) and when the widget is supposed to have
> a wide, rectangular shape with a text label. Small, typically square
> buttons that change the state of the window rather than performing an
> action (such as the buttons in the top-right corner of the QFileDialog)
> are not command buttons, but tool buttons. Qt provides a special
> class (QToolButton) for these buttons.
>
> If you need toggle behavior (see setCheckable()) or a button that
> auto-repeats the activation signal when being pushed down like the
> arrows in a scroll bar (see setAutoRepeat()), a command button is
> probably not what you want. When in doubt, use a tool button.

For the weld::Toggleable::{g,s}et_inconsistent overrides, it's a bit unclear
to me what these should reasonably do for a button. Just let
them trigger an assert for now.

[1] https://doc.qt.io/qt-6/qpushbutton.html

Change-Id: I51605ee02709bd78f77aeddf9c1993f930fcddd8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178848
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-12-20 07:15:11 +01:00
Michael Weghorn fb3f9d72d1 tdf#130857 qt weld: Introduce QtInstanceGrid
... as the weld::Grid implementation using
native Qt widgets.

This adds an implementation of the API
newly added in

    commit 7056ea9c29
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Mon Dec 16 11:02:00 2024 +0100

        weld: Add weld::Grid to handle grid child positions

Change-Id: I3db89aa9fe2986dfa7fc617440f530334d029bc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178733
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-12-19 08:28:18 +01:00
Michael Weghorn dc7e8be039 tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
QtBuilder::makeObject already creates a QScrollbar
for "GtkScrolledWindow" objects.

Implement QtInstanceBuilder::weld_scrolled_window
to return an instance of the newly added
QtInstanceScrolledWindow class.

While weld::ScrolledWindow subclasses weld::Container,
don't let QtInstanceScrolledWindow subclass
QtInstanceContainer, because the latter requires
a QWidget that has a layout set, while QScrollArea
directly manages its child widget without using
a layout.

Implement QtInstanceScrolledWindow::vadjustment_set_step_increment,
which is the only weld::ScrolledWindow method used by
FontFeaturesDialog and trigger an assert in all others.
(Leave implementing them for later, e.g. when adding support for
dialogs that actually make use of them.)

Change-Id: Ie122225f70f90b9421f902fce320d414f03291f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178496
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-12-16 07:19:05 +01:00
Michael Weghorn 995866ebfc tdf#130857 qt weld: Add QtInstanceIconView skeleton
Most of the logic still needs to be implemented.

Change-Id: I2b6a684f36a6aadcba527c0aaf8a9a29702e37c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178178
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-12-10 07:10:24 +01:00
Michael Weghorn 2d0d3500c2 tdf#130857 qt weld: Let QtInstanceWidget derive from QObject
Also add Q_OBJECT macros for all subclasses
that didn't have them and run moc for them, too.

Change-Id: Ia42ee7d02b68d54df308d33c88bf286468bfa68f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177833
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-12-05 09:27:50 +01:00
Michael Weghorn df32eb6023 tdf#130857 qt weld: Call spinbutton value changed handler
Change-Id: I435ed112469b58cec191badaf98e7f019381707b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177446
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-11-28 08:37:49 +01:00
Michael Weghorn 6ab6dcf920 tdf#130857 qt weld: Introduce custom QDoubleSpinBox subclass
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-27 23:29:00 +01:00
Michael Weghorn ec760b2110 tdf#130857 qt weld: Add QtInstanceExpander
Add a new QtInstanceExpander class that is the
weld::Expander implementation using a native
Qt widget. It uses the custom QtExpander widget
added in

    Change-Id: Id2366834cb542eba613ea087e70f3a812d20fa89
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Sun Nov 24 00:07:44 2024 +0100

        tdf#130857 qt weld: Implement "GtkExpander" equivalent

Extend QtExpander to provide what's needed
to implement the QtInstanceExpander methods.

Let QtInstanceBuilder::weld_expander return an
instance of the new class.

Signal handling still needs to be implemented
(calling `weld::Expander::signal_expanded` when
the expanded state is toggled).

QtInstanceExpander is e.g. needed by the "Set Password"
dialog. ("File" -> "Save As", check "Save with password"
checkbox and press "Save" to trigger the dialog.)

Change-Id: I7e3a332c0417b1897ae57d7d4c29609245fb5e19
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177197
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-11-24 17:04:48 +01:00
Michael Weghorn 9ca43e71e2 tdf#130857 qt weld: Implement "GtkExpander" equivalent
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-24 17:04:18 +01:00
Michael Weghorn 3e65d085ef tdf#130857 qt weld: Call checkbox toggled handler
Change-Id: I0943a2d8e35acea8e1af97bdd151bba65b0af24a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177056
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-11-23 10:49:05 +01:00
Michael Weghorn 6c957f1b49 tdf#130857 qt weld: Add QtInstanceNotebook skeleton
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-10 12:28:51 +01:00
Michael Weghorn d0ea15aace tdf#130857 qt weld: Add QtInstanceTreeView skeleton
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-09 19:05:28 +01:00
Michael Weghorn 028a525986 tdf#130857 qt weld: Signal container focus on window (de)activation
Set QtInstanceWindow as an event filter for it's
QWidget, and call `signal_container_focus_changed`
when receiving a QEvent::WindowActivate or QEvent::WindowDeactivate
event.
This code path got triggered as expected in a
quick test switching between e.g. the "Help" -> "About"
dialog and other windows in KDE Plasma using the Alt+Tab
shortcut.

The VCL implementation does something similar by
handling VclEventId::WindowActivate and
VclEventId::WindowDeactivate events, see
SalInstanceContainer::HandleEventListener.

For non-top-level containers, a different solution
will probably be needed.
For now, adjust the assert in
QtInstanceContainer::connect_container_focus_changed
to only trigger for non-QtInstanceWindow containers.

And call the base class implementation, so that the
handler is actually set for the QtInstanceWindow
case.

A potential solution for QtInstanceContainer
might be to connect to the QApplication::focusChanged
signal in QtInstanceContainer::connect_container_focus_changed
and in the slot check whether exactly one of the old and
new focus widgets has the container's widget in
hierarchy.

Change-Id: I945c8bf0999d93ae91cf25dcffd3fd3ce164d214
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176302
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-11-09 19:04:51 +01:00
Michael Weghorn 5c85ef3df0 tdf#130857 qt weld: Add QtInstanceDrawingArea basics
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-07 09:53:43 +01:00
Michael Weghorn ef1eaad00f tdf#130857 qt weld: Add a QtInstanceProgressBar
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-30 12:08:30 +01:00
Michael Weghorn d247f2e9e6 tdf#130857 qt weld: Add a QtInstanceLevelBar
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-30 09:08:17 +01:00
Michael Weghorn 8bf22f69ff tdf#130857 qt weld: Signal when radio button gets toggled
Call weld::RadioButton::signal_toggle when the
QRadioButton::toggled signal gets emitted.

Change-Id: Ib9713c452fef94448a4f101a7ef6b1dc1d93966c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175799
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-10-30 09:08:01 +01:00
Michael Weghorn ec59d5aec5 tdf#130857 qt weld: Make link buttons focusable + handle activation
Set the text interaction flags [1] for the QLabel used for
hyperlinks so that the links can be highlighted and activated
using mouse and keyboard.

Connect to the QLabel::linkActivated signal that gets emitted
when a link gets activated, and call signal_activate_link
in response. If that returns false, open the URL using
QDesktopServices::openUrl instead.

Another way to only support opening the URL using
QDesktopServices::openUrl automatically would be
to set the `openExternalLinks` property [2], but
IIUC, the custom activation handler should have
priority.

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 tab
order now includes the hyperlinks in the dialog, and pressing
Enter while one is focused, or clicking on one of them opens them
in the browser when using the qt6 VCL plugin.

[1] https://doc.qt.io/qt-6/qlabel.html#textInteractionFlags-prop
[2] https://doc.qt.io/qt-6/qlabel.html#openExternalLinks-prop

Change-Id: I4e3cbca6d01a652a1038b9750ee9049e1c7491be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175670
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-10-26 13:20:29 +02:00
Michael Weghorn 2db9f1c08e tdf#130857 qt weld: Notify about weld::Entry text/cursor changes
In QtInstanceEntry, notify about cursor and text
changes by connecting to the corresponding
QLineEdit signals and calling
weld::Entry::signal_cursor_position and
weld::Entrysignal_changed accordingly.

This is made use of e.g. in 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.
Without this commit, the "OK" button would remain
greyed out even after typing a new name in the
edit.

Change-Id: I006ed711652c65b0af1d8af5ae5c4dc80691a9b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175545
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-25 08:57:17 +02:00
Michael Weghorn 8c8a48eb06 tdf#130857 qt weld: Signal when current combobox item changes
Connect to the QComboBox::currentIndexChanged signal and
call `weld::ComboBox::signal_changed` to notify of that change.

This is in preparation for upcoming

    Change-Id: I7806688102f690faa02fb5e712943d6ae216ff9a
    Author: Michael Weghorn <m.weghorn@posteo.de>

        tdf#130857 qt weld: Declare support for "Printer Settings" dialog

and causes the infos for the printer previously selected
in the combobox in the "File" -> "Printer Settings" dialog
to be shown after selecting a printer other than the initially
selected one in the combobox, then clicking the "Properties"
button in that dialog.
(Without this, properties of the initially selected printer would
always be shown.)

Change-Id: I9a8609e172fd1d6783a86395ff58e64b7cf5c4d2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175521
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-24 09:09:34 +02:00
Michael Weghorn 169c56518e tdf#130857 qt weld: Let QtInstancDialog subclass QObject
... and add the Q_OBJECT macro, in preparation of moving
some logic from the QtInstanceMessageDialog subclass
to QtInstanceDialog for reuse.

Change-Id: Iaf76ae3efb352dd04d15716174818e8a902a16cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174373
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-02 13:15:31 +02:00
Michael Weghorn be113bcfef qt: Use qobject_cast to cast to QtMimeData
Use `qobject_cast` instead of `dynamic_cast` to
cast to QtMimeData.

Add the `Q_OBJECT` macro to the class, as the
the qobject_cast doc [1] says:

> Warning: If T isn't declared with the Q_OBJECT macro, this function's
> return value is undefined.

Change-Id: I5de2d8dbf62ed1293f3660acae44e3b13ab5df71
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173660
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-19 15:36:41 +02:00
Christian Lohmaier 0c4c84a14b makefile simplification: replace $(call gb_CustomTarget_get_workdir,foo)
…by a simple/static $(gb_CustomTarget_workdir)/foo

The build system has a lot of overly complicated leftovers from when it
was introduced and had not only deal with split repositories but also
had to coexist with another buildsystem. Along with lots of copy'n'paste
along the years the makefiles became hard to grasp for newcomers with
all our calls and evals.
As a first step to streamline that, the macros from TargetLocations that
simply prefix a static path to the argument (and similar of the same
kind) are a natural pick before simplifying the rules themselves/getting
rid of a bunch of eval statements.

Change-Id: Ia06dbbcd5d1994755a2ff05b84f72ccbc4e3cab5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167005
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
2024-05-03 16:06:14 +02:00
Michael Weghorn a54abf77c4 tdf#130857 qt weld: Support asnyc running of msg dialogs
Implement methods required to run a welded Qt message dialog
asynchronously: `QtInstanceMessageDialog::runAsync` and
`QtInstanceMessageDialog::response`.

Run the dialog asynchronously using `QDialog::open` and
connect to the `QDialog::finished` signal to be notified
when the dialog gets closed.

Similar to how the gtk-based implementation, use local
variables for the `std::shared_ptr`s and reset the members
right away, not only at the end of the slot, since resetting
the relevant one set in the corresponding `runAsync` overload
will result in the object getting deallocated, thus the members
can no longer be accessed safely.

Take the solar mutex before calling the callback function
as that seems to be expected (e.g. otherwise triggers an assert
for the below example where the callback functions
modifies VCL widgets).

With this in place, running welded Qt message dialogs
asynchronously works instead of not showing up at all, e.g.

1) start Writer with qt6 VCL plugin and without
   `SAL_VCL_QT_NO_WELDED_WIDGETS` set
2) open "File" -> "Properties" -> "Security"
3) click the "Protect..." button
4) enter 2 different passwords and press "OK" button

Change-Id: Ic1b1bfc7d89c1be8a9f9dee59bc86cf3da37a280
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162948
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-02-04 07:01:14 +01:00