vcl/README.vars.md            |    4 +++-
 vcl/qt5/QtInstance.cxx        |    5 ++++-
 vcl/qt5/QtInstanceBuilder.cxx |    1 +
 vcl/qt5/QtInstanceEntry.cxx   |   29 +++++++++++++++++++++++++++--
 4 files changed, 35 insertions(+), 4 deletions(-)

New commits:
commit 742b2d2416b7d80c3127cabd5c01db0e439204a5
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Nov 4 17:17:20 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Nov 5 08:21:17 2024 +0100

    tdf#130857 qt weld: Declare support for password dialog
    
    Add .ui file for the password that can be triggered via
    "File" -> "Properties" -> "Security" -> "Protect..." in Writer.
    
    This means that native Qt widgets are used for that dialog
    now when LO gets started with environment variable
    SAL_VCL_QT_USE_WELDED_WIDGETS=1 set.
    
    Change-Id: I106444178cd89b0f37b97bb528a144652fbb2567
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176019
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx
index 298f1f921333..a8ced91c1af2 100644
--- a/vcl/qt5/QtInstanceBuilder.cxx
+++ b/vcl/qt5/QtInstanceBuilder.cxx
@@ -55,6 +55,7 @@ bool QtInstanceBuilder::IsUIFileSupported(const OUString& 
rUIFile)
         u"modules/swriter/ui/renameobjectdialog.ui"_ustr,
         u"modules/swriter/ui/wordcount.ui"_ustr,
         u"sfx/ui/licensedialog.ui"_ustr,
+        u"sfx/ui/password.ui"_ustr,
         u"sfx/ui/querysavedialog.ui"_ustr,
         u"sfx/ui/safemodequerydialog.ui"_ustr,
         u"svt/ui/printersetupdialog.ui"_ustr,
commit c5bf243cb3734b19cb952d1dd7d628c704fab98a
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Nov 4 16:49:42 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Nov 5 08:21:09 2024 +0100

    tdf#130857 qt weld: Implement QtInstanceEntry::set_message_type
    
    For weld::EntryMessageType::Warning and
    weld::EntryMessageType::Error, set a warning/error
    icon from the icon theme at the end of the entry using
    QLineEdit::addAction.
    
    The GTK implementation (GtkInstanceEntry::set_message_type)
    also does this. That one also sets a background color, which
    the Qt implementation doesn't do for now.
    
    This method is used e.g. by the "File" -> "Properties"
    -> "Security" -> "Protect..." dialog in Writer, which
    will be declared as supported in an upcoming commit.
    
    Change-Id: I96b81e28faf82f17e33195cfa981c82522f59b98
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176018
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/QtInstanceEntry.cxx b/vcl/qt5/QtInstanceEntry.cxx
index f1001cc834db..46f9744138d4 100644
--- a/vcl/qt5/QtInstanceEntry.cxx
+++ b/vcl/qt5/QtInstanceEntry.cxx
@@ -12,6 +12,8 @@
 
 #include <vcl/qt/QtUtils.hxx>
 
+#include <QtGui/QIcon>
+
 QtInstanceEntry::QtInstanceEntry(QLineEdit* pLineEdit)
     : QtInstanceWidget(pLineEdit)
     , m_pLineEdit(pLineEdit)
@@ -114,9 +116,32 @@ bool QtInstanceEntry::get_editable() const
     return bEditable;
 }
 
-void QtInstanceEntry::set_message_type(weld::EntryMessageType)
+void QtInstanceEntry::set_message_type(weld::EntryMessageType eType)
 {
-    assert(false && "Not implemented yet");
+    SolarMutexGuard g;
+
+    GetQtInstance().RunInMainThread([&] {
+        for (QAction* pAction : m_pLineEdit->actions())
+            m_pLineEdit->removeAction(pAction);
+
+        switch (eType)
+        {
+            case weld::EntryMessageType::Normal:
+                // don't do anything special
+                return;
+            case weld::EntryMessageType::Warning:
+                m_pLineEdit->addAction(QIcon::fromTheme("dialog-warning"),
+                                       QLineEdit::TrailingPosition);
+                return;
+            case weld::EntryMessageType::Error:
+                m_pLineEdit->addAction(QIcon::fromTheme("dialog-error"),
+                                       QLineEdit::TrailingPosition);
+                return;
+            default:
+                assert(false && "Unknown EntryMessageType");
+                return;
+        }
+    });
 }
 
 void QtInstanceEntry::set_placeholder_text(const OUString& rText)
commit a2f5b750471c2fb29026b169bd1121e58a96927c
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Nov 4 15:17:31 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Nov 5 08:21:03 2024 +0100

    tdf#130857 qt weld: Make opt-in for now
    
    Except for the simple message dialogs created in
    QtInstance::CreateMessageDialog, disable the use
    of native Qt dialogs by default for now, and only
    use those if the user explicitly opts in to use
    them by setting the SAL_VCL_QT_USE_WELDED_WIDGETS
    environment variable.
    
    While those dialogs declared as supported in
    QtInstanceBuilder::IsUIFileSupported are meant to be
    fully functional, they are only a small subset
    of all LO dialogs and not all properties for
    widgets are evaluated by QtBuilder at this point in
    time (e.g. not all spacing, margins, text formatting
    properties,...).
    
    Therefore, default to VclBuilder again for now in order
    to have a more consistent visual appearance for dialogs
    with the Qt-based VCL plugins.
    
    This can be reconsidered in the future, but at least for
    25.2, sticking to VclBuilder by default seems reasonable
    to me.
    
    Change-Id: I7b275d3d3759093a6680327faeb3b86d7c623cea
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176013
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/README.vars.md b/vcl/README.vars.md
index baceef575c7b..18630181ede8 100644
--- a/vcl/README.vars.md
+++ b/vcl/README.vars.md
@@ -68,7 +68,9 @@ will be used to write the log under `instdir/uitest/`.
 * `SAL_VCL_QT_NO_FONTCONFIG` - ignore fontconfig provided font substitutions
 * `SAL_VCL_QT_NO_NATIVE` - disable `QStyle`'d controls
 * `SAL_VCL_QT_USE_QFONT` - use `QFont` for text layout and rendering (default 
is to use cairo)
-* `SAL_VCL_QT_NO_WELDED_WIDGETS` - disable the use of welded Qt widgets, 
reverts to previous VCL widget behavior
+* `SAL_VCL_QT_USE_WELDED_WIDGETS` - enable use of welded Qt widgets also for 
dialogs created from .ui files
+* `SAL_VCL_QT_NO_WELDED_WIDGETS` - disable the use of welded Qt widgets 
completely (also for simple message
+  dialogs), reverts to previous VCL widget behavior
 
 ## Mac
 
diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx
index b6b31366abfa..d2e631b4c001 100644
--- a/vcl/qt5/QtInstance.cxx
+++ b/vcl/qt5/QtInstance.cxx
@@ -830,7 +830,10 @@ QWidget* 
QtInstance::GetNativeParentFromWeldParent(weld::Widget* pParent)
 std::unique_ptr<weld::Builder>
 QtInstance::CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, 
const OUString& rUIFile)
 {
-    if (!QtData::noWeldedWidgets() && 
QtInstanceBuilder::IsUIFileSupported(rUIFile))
+    // for now, require explicitly enabling use of QtInstanceBuilder via 
SAL_VCL_QT_USE_WELDED_WIDGETS
+    static const bool bUseWeldedWidgets = 
(getenv("SAL_VCL_QT_USE_WELDED_WIDGETS") != nullptr);
+    if (bUseWeldedWidgets && !QtData::noWeldedWidgets()
+        && QtInstanceBuilder::IsUIFileSupported(rUIFile))
     {
         QWidget* pQtParent = GetNativeParentFromWeldParent(pParent);
         return std::make_unique<QtInstanceBuilder>(pQtParent, rUIRoot, 
rUIFile);

Reply via email to