diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-11-04 16:49:42 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-11-05 08:21:09 +0100 |
commit | c5bf243cb3734b19cb952d1dd7d628c704fab98a (patch) | |
tree | 87c2ceda56d3f75b750814a5823460f9b14084bc /vcl/qt5 | |
parent | a2f5b750471c2fb29026b169bd1121e58a96927c (diff) |
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.weghorn@posteo.de>
Diffstat (limited to 'vcl/qt5')
-rw-r--r-- | vcl/qt5/QtInstanceEntry.cxx | 29 |
1 files changed, 27 insertions, 2 deletions
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) |