Files
libreoffice/vcl/qt5/QtInstanceBuilder.cxx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

333 lines
10 KiB
C++
Raw Normal View History

tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <QtInstanceBuilder.hxx>
#include <unordered_set>
tdf#130857 qt weld: Implement QtBuilder + use it for first msg dialog This implements an initial QtBuilder, which is used by QtInstanceBuilder to create weld::Widget instances using native Qt widgets. This tries to be close to the VCL implementation (VclBuilder). The selected approach is based on Caolán's suggestion in [1] to rework VclBuilder to have overridable methods for widgets creation. This way, we can have common code for the UI parser but the function for widget creation is different. Qt equivalents for Gtk's widget classes in the .ui files: * GtkMessageDialog -> QMessageBox * GtkBox -> QLayout (can be QVBoxLayout/QHBoxLayout based on property in .ui file) * GtkButtonBox -> QDialogButtonBox * GtkButton -> QPushButton As QMessageBox already comes with a layout and a QDialogButtonBox, don't create new ones, but return the existing ones in QtBuilder::makeObject. This commit implements initial support for the above-mentioned widget types and adds the first message dialog to the list of supported .ui files in QtInstanceBuilder::IsUIFileSupported, so a native QMessageBox is used for it now, unless environment variable SAL_VCL_QT_NO_WELDED_WIDGETS is set when starting LibreOffice. The dialog ("modules/swriter/ui/inforeadonlydialog.ui") gets shown when taking the following steps: * start Writer * type "hello world" * select text * "Insert" -> "Section" * tick the "Protect" checkbox in the "Write Protection" section * close dialog via "Insert" button * try to type in the protected section The dialog can be dismissed using the default "OK" button. (Handling for response codes for buttons is not implemented yet, which will be needed when welding dialogs that have multiple buttons resulting in different behavior depending on what button gets clicked.) This change was originally submitted as a WIP change as part of Omkar Acharekar's Outreachy project "Implement Qt/KDE Frameworks theming using native Qt widgets" (see [2]), then further refined by Michael Weghorn. [1] https://lists.freedesktop.org/archives/libreoffice/2023-December/091288.html [2] https://lists.freedesktop.org/archives/libreoffice/2023-December/091281.html Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: I6dd010a2138c245dc1e6d83dd08123898e9d9048 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161831 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-25 09:48:09 +02:00
#include <QtBuilder.hxx>
#include <QtInstanceCheckButton.hxx>
#include <QtInstanceComboBox.hxx>
#include <QtInstanceEntry.hxx>
#include <QtInstanceFrame.hxx>
#include <QtInstanceImage.hxx>
#include <QtInstanceLabel.hxx>
tdf#130857 qt weld: Implement QtBuilder + use it for first msg dialog This implements an initial QtBuilder, which is used by QtInstanceBuilder to create weld::Widget instances using native Qt widgets. This tries to be close to the VCL implementation (VclBuilder). The selected approach is based on Caolán's suggestion in [1] to rework VclBuilder to have overridable methods for widgets creation. This way, we can have common code for the UI parser but the function for widget creation is different. Qt equivalents for Gtk's widget classes in the .ui files: * GtkMessageDialog -> QMessageBox * GtkBox -> QLayout (can be QVBoxLayout/QHBoxLayout based on property in .ui file) * GtkButtonBox -> QDialogButtonBox * GtkButton -> QPushButton As QMessageBox already comes with a layout and a QDialogButtonBox, don't create new ones, but return the existing ones in QtBuilder::makeObject. This commit implements initial support for the above-mentioned widget types and adds the first message dialog to the list of supported .ui files in QtInstanceBuilder::IsUIFileSupported, so a native QMessageBox is used for it now, unless environment variable SAL_VCL_QT_NO_WELDED_WIDGETS is set when starting LibreOffice. The dialog ("modules/swriter/ui/inforeadonlydialog.ui") gets shown when taking the following steps: * start Writer * type "hello world" * select text * "Insert" -> "Section" * tick the "Protect" checkbox in the "Write Protection" section * close dialog via "Insert" button * try to type in the protected section The dialog can be dismissed using the default "OK" button. (Handling for response codes for buttons is not implemented yet, which will be needed when welding dialogs that have multiple buttons resulting in different behavior depending on what button gets clicked.) This change was originally submitted as a WIP change as part of Omkar Acharekar's Outreachy project "Implement Qt/KDE Frameworks theming using native Qt widgets" (see [2]), then further refined by Michael Weghorn. [1] https://lists.freedesktop.org/archives/libreoffice/2023-December/091288.html [2] https://lists.freedesktop.org/archives/libreoffice/2023-December/091281.html Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: I6dd010a2138c245dc1e6d83dd08123898e9d9048 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161831 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-25 09:48:09 +02:00
#include <QtInstanceMessageDialog.hxx>
tdf#130857 qt weld: Add QtInstanceRadioButton 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-25 13:21:55 +02:00
#include <QtInstanceRadioButton.hxx>
#include <QtInstanceTextView.hxx>
tdf#130857 qt weld: Implement QtBuilder + use it for first msg dialog This implements an initial QtBuilder, which is used by QtInstanceBuilder to create weld::Widget instances using native Qt widgets. This tries to be close to the VCL implementation (VclBuilder). The selected approach is based on Caolán's suggestion in [1] to rework VclBuilder to have overridable methods for widgets creation. This way, we can have common code for the UI parser but the function for widget creation is different. Qt equivalents for Gtk's widget classes in the .ui files: * GtkMessageDialog -> QMessageBox * GtkBox -> QLayout (can be QVBoxLayout/QHBoxLayout based on property in .ui file) * GtkButtonBox -> QDialogButtonBox * GtkButton -> QPushButton As QMessageBox already comes with a layout and a QDialogButtonBox, don't create new ones, but return the existing ones in QtBuilder::makeObject. This commit implements initial support for the above-mentioned widget types and adds the first message dialog to the list of supported .ui files in QtInstanceBuilder::IsUIFileSupported, so a native QMessageBox is used for it now, unless environment variable SAL_VCL_QT_NO_WELDED_WIDGETS is set when starting LibreOffice. The dialog ("modules/swriter/ui/inforeadonlydialog.ui") gets shown when taking the following steps: * start Writer * type "hello world" * select text * "Insert" -> "Section" * tick the "Protect" checkbox in the "Write Protection" section * close dialog via "Insert" button * try to type in the protected section The dialog can be dismissed using the default "OK" button. (Handling for response codes for buttons is not implemented yet, which will be needed when welding dialogs that have multiple buttons resulting in different behavior depending on what button gets clicked.) This change was originally submitted as a WIP change as part of Omkar Acharekar's Outreachy project "Implement Qt/KDE Frameworks theming using native Qt widgets" (see [2]), then further refined by Michael Weghorn. [1] https://lists.freedesktop.org/archives/libreoffice/2023-December/091288.html [2] https://lists.freedesktop.org/archives/libreoffice/2023-December/091281.html Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: I6dd010a2138c245dc1e6d83dd08123898e9d9048 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161831 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-25 09:48:09 +02:00
QtInstanceBuilder::QtInstanceBuilder(QWidget* pParent, std::u16string_view sUIRoot,
const OUString& rUIFile)
: m_xBuilder(std::make_unique<QtBuilder>(pParent, sUIRoot, rUIFile))
{
}
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
QtInstanceBuilder::~QtInstanceBuilder() {}
bool QtInstanceBuilder::IsUIFileSupported(const OUString& rUIFile)
{
tdf#130857 qt weld: Implement QtBuilder + use it for first msg dialog This implements an initial QtBuilder, which is used by QtInstanceBuilder to create weld::Widget instances using native Qt widgets. This tries to be close to the VCL implementation (VclBuilder). The selected approach is based on Caolán's suggestion in [1] to rework VclBuilder to have overridable methods for widgets creation. This way, we can have common code for the UI parser but the function for widget creation is different. Qt equivalents for Gtk's widget classes in the .ui files: * GtkMessageDialog -> QMessageBox * GtkBox -> QLayout (can be QVBoxLayout/QHBoxLayout based on property in .ui file) * GtkButtonBox -> QDialogButtonBox * GtkButton -> QPushButton As QMessageBox already comes with a layout and a QDialogButtonBox, don't create new ones, but return the existing ones in QtBuilder::makeObject. This commit implements initial support for the above-mentioned widget types and adds the first message dialog to the list of supported .ui files in QtInstanceBuilder::IsUIFileSupported, so a native QMessageBox is used for it now, unless environment variable SAL_VCL_QT_NO_WELDED_WIDGETS is set when starting LibreOffice. The dialog ("modules/swriter/ui/inforeadonlydialog.ui") gets shown when taking the following steps: * start Writer * type "hello world" * select text * "Insert" -> "Section" * tick the "Protect" checkbox in the "Write Protection" section * close dialog via "Insert" button * try to type in the protected section The dialog can be dismissed using the default "OK" button. (Handling for response codes for buttons is not implemented yet, which will be needed when welding dialogs that have multiple buttons resulting in different behavior depending on what button gets clicked.) This change was originally submitted as a WIP change as part of Omkar Acharekar's Outreachy project "Implement Qt/KDE Frameworks theming using native Qt widgets" (see [2]), then further refined by Michael Weghorn. [1] https://lists.freedesktop.org/archives/libreoffice/2023-December/091288.html [2] https://lists.freedesktop.org/archives/libreoffice/2023-December/091281.html Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: I6dd010a2138c245dc1e6d83dd08123898e9d9048 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161831 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-25 09:48:09 +02:00
// set of supported UI files
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
//
// The idea is to implement functionality needed for a specific UI file/dialog
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
// in QtInstanceBuilder, then add it to the set of supported UI files here.
// This allows looking at one .ui file at a time and only having to implement
// what is relevant for that particular one, without having to implement the full
// weld API at once.
tdf#130857 qt weld: Implement QtBuilder + use it for first msg dialog This implements an initial QtBuilder, which is used by QtInstanceBuilder to create weld::Widget instances using native Qt widgets. This tries to be close to the VCL implementation (VclBuilder). The selected approach is based on Caolán's suggestion in [1] to rework VclBuilder to have overridable methods for widgets creation. This way, we can have common code for the UI parser but the function for widget creation is different. Qt equivalents for Gtk's widget classes in the .ui files: * GtkMessageDialog -> QMessageBox * GtkBox -> QLayout (can be QVBoxLayout/QHBoxLayout based on property in .ui file) * GtkButtonBox -> QDialogButtonBox * GtkButton -> QPushButton As QMessageBox already comes with a layout and a QDialogButtonBox, don't create new ones, but return the existing ones in QtBuilder::makeObject. This commit implements initial support for the above-mentioned widget types and adds the first message dialog to the list of supported .ui files in QtInstanceBuilder::IsUIFileSupported, so a native QMessageBox is used for it now, unless environment variable SAL_VCL_QT_NO_WELDED_WIDGETS is set when starting LibreOffice. The dialog ("modules/swriter/ui/inforeadonlydialog.ui") gets shown when taking the following steps: * start Writer * type "hello world" * select text * "Insert" -> "Section" * tick the "Protect" checkbox in the "Write Protection" section * close dialog via "Insert" button * try to type in the protected section The dialog can be dismissed using the default "OK" button. (Handling for response codes for buttons is not implemented yet, which will be needed when welding dialogs that have multiple buttons resulting in different behavior depending on what button gets clicked.) This change was originally submitted as a WIP change as part of Omkar Acharekar's Outreachy project "Implement Qt/KDE Frameworks theming using native Qt widgets" (see [2]), then further refined by Michael Weghorn. [1] https://lists.freedesktop.org/archives/libreoffice/2023-December/091288.html [2] https://lists.freedesktop.org/archives/libreoffice/2023-December/091281.html Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: I6dd010a2138c245dc1e6d83dd08123898e9d9048 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161831 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-25 09:48:09 +02:00
static std::unordered_set<OUString> aSupportedUIFiles = {
u"cui/ui/optnewdictionarydialog.ui"_ustr,
u"modules/scalc/ui/inputstringdialog.ui"_ustr,
u"modules/schart/ui/insertaxisdlg.ui"_ustr,
u"modules/smath/ui/alignmentdialog.ui"_ustr,
tdf#130857 qt weld: Implement QtBuilder + use it for first msg dialog This implements an initial QtBuilder, which is used by QtInstanceBuilder to create weld::Widget instances using native Qt widgets. This tries to be close to the VCL implementation (VclBuilder). The selected approach is based on Caolán's suggestion in [1] to rework VclBuilder to have overridable methods for widgets creation. This way, we can have common code for the UI parser but the function for widget creation is different. Qt equivalents for Gtk's widget classes in the .ui files: * GtkMessageDialog -> QMessageBox * GtkBox -> QLayout (can be QVBoxLayout/QHBoxLayout based on property in .ui file) * GtkButtonBox -> QDialogButtonBox * GtkButton -> QPushButton As QMessageBox already comes with a layout and a QDialogButtonBox, don't create new ones, but return the existing ones in QtBuilder::makeObject. This commit implements initial support for the above-mentioned widget types and adds the first message dialog to the list of supported .ui files in QtInstanceBuilder::IsUIFileSupported, so a native QMessageBox is used for it now, unless environment variable SAL_VCL_QT_NO_WELDED_WIDGETS is set when starting LibreOffice. The dialog ("modules/swriter/ui/inforeadonlydialog.ui") gets shown when taking the following steps: * start Writer * type "hello world" * select text * "Insert" -> "Section" * tick the "Protect" checkbox in the "Write Protection" section * close dialog via "Insert" button * try to type in the protected section The dialog can be dismissed using the default "OK" button. (Handling for response codes for buttons is not implemented yet, which will be needed when welding dialogs that have multiple buttons resulting in different behavior depending on what button gets clicked.) This change was originally submitted as a WIP change as part of Omkar Acharekar's Outreachy project "Implement Qt/KDE Frameworks theming using native Qt widgets" (see [2]), then further refined by Michael Weghorn. [1] https://lists.freedesktop.org/archives/libreoffice/2023-December/091288.html [2] https://lists.freedesktop.org/archives/libreoffice/2023-December/091281.html Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: I6dd010a2138c245dc1e6d83dd08123898e9d9048 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161831 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-25 09:48:09 +02:00
u"modules/swriter/ui/inforeadonlydialog.ui"_ustr,
u"modules/swriter/ui/renameobjectdialog.ui"_ustr,
u"modules/swriter/ui/wordcount.ui"_ustr,
u"sfx/ui/licensedialog.ui"_ustr,
u"sfx/ui/querysavedialog.ui"_ustr,
u"svt/ui/printersetupdialog.ui"_ustr,
u"svt/ui/restartdialog.ui"_ustr,
u"writerperfect/ui/exportepub.ui"_ustr,
tdf#130857 qt weld: Implement QtBuilder + use it for first msg dialog This implements an initial QtBuilder, which is used by QtInstanceBuilder to create weld::Widget instances using native Qt widgets. This tries to be close to the VCL implementation (VclBuilder). The selected approach is based on Caolán's suggestion in [1] to rework VclBuilder to have overridable methods for widgets creation. This way, we can have common code for the UI parser but the function for widget creation is different. Qt equivalents for Gtk's widget classes in the .ui files: * GtkMessageDialog -> QMessageBox * GtkBox -> QLayout (can be QVBoxLayout/QHBoxLayout based on property in .ui file) * GtkButtonBox -> QDialogButtonBox * GtkButton -> QPushButton As QMessageBox already comes with a layout and a QDialogButtonBox, don't create new ones, but return the existing ones in QtBuilder::makeObject. This commit implements initial support for the above-mentioned widget types and adds the first message dialog to the list of supported .ui files in QtInstanceBuilder::IsUIFileSupported, so a native QMessageBox is used for it now, unless environment variable SAL_VCL_QT_NO_WELDED_WIDGETS is set when starting LibreOffice. The dialog ("modules/swriter/ui/inforeadonlydialog.ui") gets shown when taking the following steps: * start Writer * type "hello world" * select text * "Insert" -> "Section" * tick the "Protect" checkbox in the "Write Protection" section * close dialog via "Insert" button * try to type in the protected section The dialog can be dismissed using the default "OK" button. (Handling for response codes for buttons is not implemented yet, which will be needed when welding dialogs that have multiple buttons resulting in different behavior depending on what button gets clicked.) This change was originally submitted as a WIP change as part of Omkar Acharekar's Outreachy project "Implement Qt/KDE Frameworks theming using native Qt widgets" (see [2]), then further refined by Michael Weghorn. [1] https://lists.freedesktop.org/archives/libreoffice/2023-December/091288.html [2] https://lists.freedesktop.org/archives/libreoffice/2023-December/091281.html Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: I6dd010a2138c245dc1e6d83dd08123898e9d9048 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161831 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-25 09:48:09 +02:00
};
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
return aSupportedUIFiles.contains(rUIFile);
}
tdf#130857 qt weld: Implement QtBuilder + use it for first msg dialog This implements an initial QtBuilder, which is used by QtInstanceBuilder to create weld::Widget instances using native Qt widgets. This tries to be close to the VCL implementation (VclBuilder). The selected approach is based on Caolán's suggestion in [1] to rework VclBuilder to have overridable methods for widgets creation. This way, we can have common code for the UI parser but the function for widget creation is different. Qt equivalents for Gtk's widget classes in the .ui files: * GtkMessageDialog -> QMessageBox * GtkBox -> QLayout (can be QVBoxLayout/QHBoxLayout based on property in .ui file) * GtkButtonBox -> QDialogButtonBox * GtkButton -> QPushButton As QMessageBox already comes with a layout and a QDialogButtonBox, don't create new ones, but return the existing ones in QtBuilder::makeObject. This commit implements initial support for the above-mentioned widget types and adds the first message dialog to the list of supported .ui files in QtInstanceBuilder::IsUIFileSupported, so a native QMessageBox is used for it now, unless environment variable SAL_VCL_QT_NO_WELDED_WIDGETS is set when starting LibreOffice. The dialog ("modules/swriter/ui/inforeadonlydialog.ui") gets shown when taking the following steps: * start Writer * type "hello world" * select text * "Insert" -> "Section" * tick the "Protect" checkbox in the "Write Protection" section * close dialog via "Insert" button * try to type in the protected section The dialog can be dismissed using the default "OK" button. (Handling for response codes for buttons is not implemented yet, which will be needed when welding dialogs that have multiple buttons resulting in different behavior depending on what button gets clicked.) This change was originally submitted as a WIP change as part of Omkar Acharekar's Outreachy project "Implement Qt/KDE Frameworks theming using native Qt widgets" (see [2]), then further refined by Michael Weghorn. [1] https://lists.freedesktop.org/archives/libreoffice/2023-December/091288.html [2] https://lists.freedesktop.org/archives/libreoffice/2023-December/091281.html Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: I6dd010a2138c245dc1e6d83dd08123898e9d9048 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161831 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-25 09:48:09 +02:00
std::unique_ptr<weld::MessageDialog> QtInstanceBuilder::weld_message_dialog(const OUString& id)
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
{
tdf#130857 qt weld: Implement QtBuilder + use it for first msg dialog This implements an initial QtBuilder, which is used by QtInstanceBuilder to create weld::Widget instances using native Qt widgets. This tries to be close to the VCL implementation (VclBuilder). The selected approach is based on Caolán's suggestion in [1] to rework VclBuilder to have overridable methods for widgets creation. This way, we can have common code for the UI parser but the function for widget creation is different. Qt equivalents for Gtk's widget classes in the .ui files: * GtkMessageDialog -> QMessageBox * GtkBox -> QLayout (can be QVBoxLayout/QHBoxLayout based on property in .ui file) * GtkButtonBox -> QDialogButtonBox * GtkButton -> QPushButton As QMessageBox already comes with a layout and a QDialogButtonBox, don't create new ones, but return the existing ones in QtBuilder::makeObject. This commit implements initial support for the above-mentioned widget types and adds the first message dialog to the list of supported .ui files in QtInstanceBuilder::IsUIFileSupported, so a native QMessageBox is used for it now, unless environment variable SAL_VCL_QT_NO_WELDED_WIDGETS is set when starting LibreOffice. The dialog ("modules/swriter/ui/inforeadonlydialog.ui") gets shown when taking the following steps: * start Writer * type "hello world" * select text * "Insert" -> "Section" * tick the "Protect" checkbox in the "Write Protection" section * close dialog via "Insert" button * try to type in the protected section The dialog can be dismissed using the default "OK" button. (Handling for response codes for buttons is not implemented yet, which will be needed when welding dialogs that have multiple buttons resulting in different behavior depending on what button gets clicked.) This change was originally submitted as a WIP change as part of Omkar Acharekar's Outreachy project "Implement Qt/KDE Frameworks theming using native Qt widgets" (see [2]), then further refined by Michael Weghorn. [1] https://lists.freedesktop.org/archives/libreoffice/2023-December/091288.html [2] https://lists.freedesktop.org/archives/libreoffice/2023-December/091281.html Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: I6dd010a2138c245dc1e6d83dd08123898e9d9048 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161831 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-25 09:48:09 +02:00
QMessageBox* pMessageBox = m_xBuilder->get<QMessageBox>(id);
std::unique_ptr<weld::MessageDialog> xRet(
pMessageBox ? std::make_unique<QtInstanceMessageDialog>(pMessageBox) : nullptr);
return xRet;
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
}
std::unique_ptr<weld::Dialog> QtInstanceBuilder::weld_dialog(const OUString& rId)
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
{
QDialog* pDialog = m_xBuilder->get<QDialog>(rId);
std::unique_ptr<weld::Dialog> xRet(pDialog ? std::make_unique<QtInstanceDialog>(pDialog)
: nullptr);
return xRet;
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
}
std::unique_ptr<weld::Assistant> QtInstanceBuilder::weld_assistant(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Window> QtInstanceBuilder::create_screenshot_window()
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Widget> QtInstanceBuilder::weld_widget(const OUString& rId)
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
{
QWidget* pWidget = m_xBuilder->get<QWidget>(rId);
std::unique_ptr<weld::Widget> xRet(pWidget ? std::make_unique<QtInstanceWidget>(pWidget)
: nullptr);
return xRet;
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
}
std::unique_ptr<weld::Container> QtInstanceBuilder::weld_container(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Box> QtInstanceBuilder::weld_box(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Paned> QtInstanceBuilder::weld_paned(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Frame> QtInstanceBuilder::weld_frame(const OUString& rId)
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
{
QGroupBox* pGroupBox = m_xBuilder->get<QGroupBox>(rId);
std::unique_ptr<weld::Frame> xRet(pGroupBox ? std::make_unique<QtInstanceFrame>(pGroupBox)
: nullptr);
return xRet;
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
}
std::unique_ptr<weld::ScrolledWindow> QtInstanceBuilder::weld_scrolled_window(const OUString&, bool)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Notebook> QtInstanceBuilder::weld_notebook(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Button> QtInstanceBuilder::weld_button(const OUString& rId)
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
{
QPushButton* pButton = m_xBuilder->get<QPushButton>(rId);
std::unique_ptr<weld::Button> xRet(pButton ? std::make_unique<QtInstanceButton>(pButton)
: nullptr);
return xRet;
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
}
std::unique_ptr<weld::MenuButton> QtInstanceBuilder::weld_menu_button(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::MenuToggleButton> QtInstanceBuilder::weld_menu_toggle_button(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::LinkButton> QtInstanceBuilder::weld_link_button(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::ToggleButton> QtInstanceBuilder::weld_toggle_button(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
tdf#130857 qt weld: Add QtInstanceRadioButton 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-25 13:21:55 +02:00
std::unique_ptr<weld::RadioButton> QtInstanceBuilder::weld_radio_button(const OUString& rId)
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
{
tdf#130857 qt weld: Add QtInstanceRadioButton 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-25 13:21:55 +02:00
QRadioButton* pRadioButton = m_xBuilder->get<QRadioButton>(rId);
std::unique_ptr<weld::RadioButton> xRet(
pRadioButton ? std::make_unique<QtInstanceRadioButton>(pRadioButton) : nullptr);
return xRet;
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
}
std::unique_ptr<weld::CheckButton> QtInstanceBuilder::weld_check_button(const OUString& rId)
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
{
QCheckBox* pCheckBox = m_xBuilder->get<QCheckBox>(rId);
std::unique_ptr<weld::CheckButton> xRet(
pCheckBox ? std::make_unique<QtInstanceCheckButton>(pCheckBox) : nullptr);
return xRet;
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
}
std::unique_ptr<weld::Scale> QtInstanceBuilder::weld_scale(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::ProgressBar> QtInstanceBuilder::weld_progress_bar(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::LevelBar> QtInstanceBuilder::weld_level_bar(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Spinner> QtInstanceBuilder::weld_spinner(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Image> QtInstanceBuilder::weld_image(const OUString& rId)
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
{
QLabel* pLabel = m_xBuilder->get<QLabel>(rId);
std::unique_ptr<weld::Image> xRet(pLabel ? std::make_unique<QtInstanceImage>(pLabel) : nullptr);
return xRet;
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
}
std::unique_ptr<weld::Calendar> QtInstanceBuilder::weld_calendar(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Entry> QtInstanceBuilder::weld_entry(const OUString& rId)
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
{
QLineEdit* pLineEdit = m_xBuilder->get<QLineEdit>(rId);
std::unique_ptr<weld::Entry> xRet(pLineEdit ? std::make_unique<QtInstanceEntry>(pLineEdit)
: nullptr);
return xRet;
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
}
std::unique_ptr<weld::SpinButton> QtInstanceBuilder::weld_spin_button(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::MetricSpinButton> QtInstanceBuilder::weld_metric_spin_button(const OUString&,
FieldUnit)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::FormattedSpinButton>
QtInstanceBuilder::weld_formatted_spin_button(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::ComboBox> QtInstanceBuilder::weld_combo_box(const OUString& rId)
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
{
QComboBox* pComboBox = m_xBuilder->get<QComboBox>(rId);
std::unique_ptr<weld::ComboBox> xRet(pComboBox ? std::make_unique<QtInstanceComboBox>(pComboBox)
: nullptr);
return xRet;
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
}
std::unique_ptr<weld::EntryTreeView>
QtInstanceBuilder::weld_entry_tree_view(const OUString&, const OUString&, const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::TreeView> QtInstanceBuilder::weld_tree_view(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::IconView> QtInstanceBuilder::weld_icon_view(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Label> QtInstanceBuilder::weld_label(const OUString& rId)
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
{
QLabel* pLabel = m_xBuilder->get<QLabel>(rId);
std::unique_ptr<weld::Label> xRet(pLabel ? std::make_unique<QtInstanceLabel>(pLabel) : nullptr);
return xRet;
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
}
std::unique_ptr<weld::TextView> QtInstanceBuilder::weld_text_view(const OUString& rId)
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
{
QPlainTextEdit* pTextEdit = m_xBuilder->get<QPlainTextEdit>(rId);
std::unique_ptr<weld::TextView> xRet(pTextEdit ? std::make_unique<QtInstanceTextView>(pTextEdit)
: nullptr);
return xRet;
tdf#130857 qt weld: Add QtInstanceBuilder skeleton Add new `QtInstanceBuilder` that derives from `weld::Builder` and is meant to use `weld::Widget` implementations using native Qt widgets. Override `SalInstance::CreateBuilder` in `QtInstance` to return an instance of the new `QtInstanceBuilder` for UI files that that one can handle/supports. As of now, `QtInstanceBuilder` doesn't yet implement what's needed, so `QtInstanceBuilder::IsUIFileSupported` currently still always returns `false`, meaning that `SalInstanceBuilder` is still always used in practice. The idea is to implement funcationality needed for a specific UI file/dialog in `QtInstanceBuilder`, then add it to the set of supported UI files in `QtInstanceBuilder::IsUIFileSupported`. This allows looking at one .ui file at a time and only having to implement what is relevant for that particular one, without having to implement the full weld API at once. The use of `QtInstanceBuilder` can completely be disabled by starting LO with environment variable `SAL_VCL_QT_NO_WELDED_WIDGETS` set. This commit is mostly extraced from Omkar Acharekar's WIP Gerrit change [1] (patch set 22) with some further adjustments by Michael Weghorn. Patch set 23 of that WIP Gerrit change demonstrates adding support for a dialog (the "Save Document?" one), but still needs more work. [1] https://gerrit.libreoffice.org/c/core/+/161831 Co-authored-by: Michael Weghorn <m.weghorn@posteo.de> Change-Id: If2d1ea30d43c2c1d84d64e577035489c8e158a7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173592 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-18 09:35:09 +02:00
}
std::unique_ptr<weld::Expander> QtInstanceBuilder::weld_expander(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::DrawingArea>
QtInstanceBuilder::weld_drawing_area(const OUString&, const a11yref&, FactoryFunction, void*)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Menu> QtInstanceBuilder::weld_menu(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Popover> QtInstanceBuilder::weld_popover(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Toolbar> QtInstanceBuilder::weld_toolbar(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::Scrollbar> QtInstanceBuilder::weld_scrollbar(const OUString&)
{
assert(false && "Not implemented yet");
return nullptr;
}
std::unique_ptr<weld::SizeGroup> QtInstanceBuilder::create_size_group()
{
assert(false && "Not implemented yet");
return nullptr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */