core.git: 2 commits - vcl/inc vcl/qt5

2024-04-29 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtTransferable.hxx |   11 --
 vcl/qt5/QtClipboard.cxx|2 -
 vcl/qt5/QtTransferable.cxx |   43 +++--
 3 files changed, 35 insertions(+), 21 deletions(-)

New commits:
commit 621cfc0e4120ab2b381b54268fe39bd19257df9b
Author: Michael Weghorn 
AuthorDate: Fri Apr 26 15:04:24 2024 +0200
Commit: Michael Weghorn 
CommitDate: Tue Apr 30 06:53:19 2024 +0200

qt: Guard clipboard mime data with SolarMutex

Most of the access to the QtClipboardTransferable
mime data happens exclusively on the main thread,
with the solar mutex held.

However, `mimeData()`, called from `QtClipboard::getContents`
didn't ensure that yet, so as Michael Stahl pointed out in [1],

commit 1db5b87fe69c2375f1d66974dafcd563303c76db
Author: Michael Weghorn 
Date:   Tue Feb 13 13:23:17 2024 +0100

tdf#156562 qt: Sync with system clipboard content if necessary

introduced a data race by allowing to set new mime data.

Introduce a new
`QtClipboardTransferable::hasMimeData(const QMimeData* pMimeData)`
that guards access to the mime data with the solar mutext as well
and use that instead, so all access to the `QtClipboardTransferable`
mime data is now guarded by the solar mutex.

Also add an explicit note for the mime data getter/setter in the
`QtTransferable` base class that subclasses allowing to update
mime data are responsible for preventing data races.

[1] https://gerrit.libreoffice.org/c/core/+/166141/comment/fe75f418_40c1b622

Change-Id: I01dbbb0b37a4c6ad06b4d3001ecce8b0260eb32e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166750
Reviewed-by: Michael Weghorn 
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/vcl/inc/qt5/QtTransferable.hxx b/vcl/inc/qt5/QtTransferable.hxx
index c58490e90460..5687fa06df52 100644
--- a/vcl/inc/qt5/QtTransferable.hxx
+++ b/vcl/inc/qt5/QtTransferable.hxx
@@ -40,12 +40,17 @@ protected:
  *  Since data flavors supported by this class depend on the mime data,
  *  results from previous calls to the public methods of this
  *  class are no longer valid after setting new mime data using this 
method.
+ *
+ *  Subclasses that set new mime data must ensure that no data race exists
+ *  on m_pMimeData.
+ *  (For the current only subclass doing so, QtClipboardTransferable, all 
access
+ *  to m_pMimeData happens with the SolarMutex held.)
  */
 void setMimeData(const QMimeData* pMimeData) { m_pMimeData = pMimeData; }
+const QMimeData* mimeData() const { return m_pMimeData; }
 
 public:
 QtTransferable(const QMimeData* pMimeData);
-const QMimeData* mimeData() const { return m_pMimeData; }
 
 css::uno::Sequence SAL_CALL 
getTransferDataFlavors() override;
 sal_Bool SAL_CALL isDataFlavorSupported(const 
css::datatransfer::DataFlavor& rFlavor) override;
@@ -74,6 +79,9 @@ class QtClipboardTransferable final : public QtTransferable
 public:
 explicit QtClipboardTransferable(const QClipboard::Mode aMode, const 
QMimeData* pMimeData);
 
+// whether pMimeData are the current mime data
+bool hasMimeData(const QMimeData* pMimeData) const;
+
 // these are the same then QtTransferable, except they go through 
RunInMainThread
 css::uno::Sequence SAL_CALL 
getTransferDataFlavors() override;
 sal_Bool SAL_CALL isDataFlavorSupported(const 
css::datatransfer::DataFlavor& rFlavor) override;
diff --git a/vcl/qt5/QtClipboard.cxx b/vcl/qt5/QtClipboard.cxx
index e9eb476fb253..ea05784bbfb2 100644
--- a/vcl/qt5/QtClipboard.cxx
+++ b/vcl/qt5/QtClipboard.cxx
@@ -103,7 +103,7 @@ css::uno::Reference 
QtClipboard::getContents()
 {
 const auto* pTrans = 
dynamic_cast(m_aContents.get());
 assert(pTrans);
-if (pTrans && pTrans->mimeData() == pMimeData)
+if (pTrans && pTrans->hasMimeData(pMimeData))
 return m_aContents;
 }
 
diff --git a/vcl/qt5/QtTransferable.cxx b/vcl/qt5/QtTransferable.cxx
index a6902824ab3a..1aec5da27843 100644
--- a/vcl/qt5/QtTransferable.cxx
+++ b/vcl/qt5/QtTransferable.cxx
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -173,10 +174,17 @@ void 
QtClipboardTransferable::ensureConsistencyWithSystemClipboard()
 {
 SAL_WARN("vcl.qt", "In flight clipboard change detected - updating 
mime data with current "
"clipboard contents.");
+DBG_TESTSOLARMUTEX();
 setMimeData(pCurrentClipboardData);
 }
 }
 
+bool QtClipboardTransferable::hasMimeData(const QMimeData* pMimeData) const
+{
+SolarMutexGuard aGuard;
+return QtTransferable::mimeData() == pMimeData;
+}
+
 css::uno::Any SAL_CALL
 QtClipboardTransferable::getTransferData(const css::datatransfer::DataFlavor& 
rFlavor)
 {
commit 893deef4f77f19d7b2d31df09260a34affe1
Author: Michael Weghorn 
AuthorDate: 

core.git: 2 commits - vcl/inc vcl/qt5

2024-02-14 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtInstanceContainer.hxx |2 ++
 vcl/inc/qt5/QtInstanceDialog.hxx|2 +-
 vcl/inc/qt5/QtInstanceWidget.hxx|6 ++
 vcl/inc/qt5/QtInstanceWindow.hxx|2 --
 vcl/qt5/QtInstanceContainer.cxx |5 +
 vcl/qt5/QtInstanceDialog.cxx|4 ++--
 vcl/qt5/QtInstanceWidget.cxx|6 ++
 vcl/qt5/QtInstanceWindow.cxx|7 +++
 8 files changed, 25 insertions(+), 9 deletions(-)

New commits:
commit 6712963e231e7ab50a3d11b8a8c75e54e0c79b32
Author: Michael Weghorn 
AuthorDate: Wed Feb 14 10:54:00 2024 +0100
Commit: Michael Weghorn 
CommitDate: Thu Feb 15 08:07:42 2024 +0100

tdf#130857 qt weld: Implement QtInstanceDialog::{g,s}et_modal

Change-Id: I975d10ccc73c79b34da733411097a7970c8bf916
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163361
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtInstanceDialog.hxx b/vcl/inc/qt5/QtInstanceDialog.hxx
index 04b45d57a31f..303206be7194 100644
--- a/vcl/inc/qt5/QtInstanceDialog.hxx
+++ b/vcl/inc/qt5/QtInstanceDialog.hxx
@@ -37,7 +37,7 @@ public:
 
 virtual void add_button(const OUString&, int, const OUString& rHelpId = 
{}) override;
 
-virtual void set_modal(bool) override;
+virtual void set_modal(bool bModal) override;
 
 virtual bool get_modal() const override;
 
diff --git a/vcl/qt5/QtInstanceDialog.cxx b/vcl/qt5/QtInstanceDialog.cxx
index e65e4b749e13..cdd75cd9675f 100644
--- a/vcl/qt5/QtInstanceDialog.cxx
+++ b/vcl/qt5/QtInstanceDialog.cxx
@@ -41,9 +41,9 @@ void QtInstanceDialog::response(int) {}
 
 void QtInstanceDialog::add_button(const OUString&, int, const OUString&) {}
 
-void QtInstanceDialog::set_modal(bool) {}
+void QtInstanceDialog::set_modal(bool bModal) { m_pDialog->setModal(bModal); }
 
-bool QtInstanceDialog::get_modal() const { return true; }
+bool QtInstanceDialog::get_modal() const { return m_pDialog->isModal(); }
 
 weld::Button* QtInstanceDialog::weld_widget_for_response(int) { return 
nullptr; }
 
commit 092bcd7133c30c0614056928a16baea44704735e
Author: Michael Weghorn 
AuthorDate: Wed Feb 14 10:32:11 2024 +0100
Commit: Michael Weghorn 
CommitDate: Thu Feb 15 08:07:33 2024 +0100

tdf#130857 qt weld: Move QWidget* member to QtInstanceWidget

Move the `m_pWidget` member from `QtInstanceWindow`
to the base class `QtInstanceWidget` and add a getter
for it.

This allows to get the `QWidget` directly from the
base class, which will be used in an upcoming commit.

Change-Id: I9c41b48936e5a6051afb9721dae2fac5add22e4b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163360
Tested-by: Jenkins
Reviewed-by: Omkar Acharekar  
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtInstanceContainer.hxx 
b/vcl/inc/qt5/QtInstanceContainer.hxx
index 87a89c48bd46..a0cd31869dc6 100644
--- a/vcl/inc/qt5/QtInstanceContainer.hxx
+++ b/vcl/inc/qt5/QtInstanceContainer.hxx
@@ -14,6 +14,8 @@
 class QtInstanceContainer : public QtInstanceWidget, public virtual 
weld::Container
 {
 public:
+QtInstanceContainer(QWidget* pWidget);
+
 virtual void move(weld::Widget*, weld::Container*) override;
 
 virtual css::uno::Reference CreateChildFrame() override;
diff --git a/vcl/inc/qt5/QtInstanceWidget.hxx b/vcl/inc/qt5/QtInstanceWidget.hxx
index ee0c5b8c451d..f5038ee5ad66 100644
--- a/vcl/inc/qt5/QtInstanceWidget.hxx
+++ b/vcl/inc/qt5/QtInstanceWidget.hxx
@@ -21,7 +21,13 @@
 
 class QtInstanceWidget : public virtual weld::Widget
 {
+QWidget* m_pWidget;
+
 public:
+QtInstanceWidget(QWidget* pWidget);
+
+QWidget* getQWidget() const { return m_pWidget; }
+
 virtual void set_sensitive(bool) override;
 
 virtual bool get_sensitive() const override;
diff --git a/vcl/inc/qt5/QtInstanceWindow.hxx b/vcl/inc/qt5/QtInstanceWindow.hxx
index c29863da4f67..db80a6e71458 100644
--- a/vcl/inc/qt5/QtInstanceWindow.hxx
+++ b/vcl/inc/qt5/QtInstanceWindow.hxx
@@ -13,8 +13,6 @@
 
 class QtInstanceWindow : public QtInstanceContainer, public virtual 
weld::Window
 {
-QWidget* m_pWidget;
-
 public:
 QtInstanceWindow(QWidget* pWidget);
 
diff --git a/vcl/qt5/QtInstanceContainer.cxx b/vcl/qt5/QtInstanceContainer.cxx
index e22b1afb2a55..35f0a4bbaa69 100644
--- a/vcl/qt5/QtInstanceContainer.cxx
+++ b/vcl/qt5/QtInstanceContainer.cxx
@@ -9,6 +9,11 @@
 
 #include 
 
+QtInstanceContainer::QtInstanceContainer(QWidget* pWidget)
+: QtInstanceWidget(pWidget)
+{
+}
+
 void QtInstanceContainer::move(weld::Widget*, weld::Container*) {}
 
 css::uno::Reference QtInstanceContainer::CreateChildFrame()
diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx
index cbccac8799db..9c17ebe6cb1d 100644
--- a/vcl/qt5/QtInstanceWidget.cxx
+++ b/vcl/qt5/QtInstanceWidget.cxx
@@ -9,6 +9,12 @@
 
 #include 
 
+QtInstanceWidget::QtInstanceWidget(QWidget* pWidget)
+: m_pWidget(pWidget)
+{
+assert(pWidget);
+}
+
 void QtInstanceWidget::set_sensitive(bool) {}
 
 

core.git: 2 commits - vcl/inc vcl/qt5

2024-02-13 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtTransferable.hxx |   20 +---
 vcl/qt5/QtTransferable.cxx |   37 +++--
 2 files changed, 28 insertions(+), 29 deletions(-)

New commits:
commit 1db5b87fe69c2375f1d66974dafcd563303c76db
Author: Michael Weghorn 
AuthorDate: Tue Feb 13 13:23:17 2024 +0100
Commit: Michael Weghorn 
CommitDate: Tue Feb 13 17:19:19 2024 +0100

tdf#156562 qt: Sync with system clipboard content if necessary

If the `QtClipboardTransferable`'s mime data gets out of sync
with the system clipboard's one, no longer cease operation
and stop reporting any transfer data, but sync with  the
clipboard data, i.e. update the mime data with those
currently in the system clipboard.

For the "Paste Special" dialog with qt6 on Wayland
(see tdf#156562), an external clipboard update gets
triggered between the point in time when the

std::shared_ptr aDataHelper

in the `SID_PASTE_SPECIAL` case in `SwBaseShell::ExecClpbrd`
gets assigned and when the callback set via
`pDlg->StartExecuteAsync` gets called, even if there
was no user interaction with the system clipboard at all.

This however meant that the `aDataHelper` used in the
callback would no longer return any transfer/mime data,
so pasting wouldn't work.

Handle that case by updating the `QtClipboardTransferable`
mime data with the current system clipboard's data, but
keep emitting a warning at least.

As a consequence, opening the "Paste Special" dialog, then
copying something else to the clipboard, then confirming
the dialog will copy the newly copied data rather than
what was in the clipboard when the dialog was initially
started. That's the same for gtk3 already, but on Windows,
the original clipboard content would still be pasted.

(Retrieving the clipboard content anew in the callback using
`TransferableDataHelper::CreateFromSystemClipboard` instead
of passing the original `aDataHelper` into the callback
would have a similar effect. However, on other platforms,
reusing the previously copied data from the clipboard when
the actual system clipboard was changed in between may
be what's desired.)

The observed extra/unexpected clipboard change event may be
related/similar to what the following commit was addressing for
the case of LO itself being the clipboard owner:

commit 71471a36b125f6bdc915d5dbcae92ebcaa7ff5a4
Date:   Tue Apr 6 01:41:08 2021 +0200

tdf#140404 Qt ignore "unchanged" clipboard events

LO gets a Qt signal on all clipboard changes. For X11 you get one
signal when you set the clipboard. Anything else normally signals
lost of clipboard ownership.

But on Wayland LO somehow gets a second notification without any
actual change. AFAIK it's not triggered by any LO actions and
isOwner still indicates, that LO has the ownership. This breaks
the single notification assumption, the code was relying on.

(...)

Backtrace showing how the clipboard update gets triggered
(with mode `QClipboardMode::Clipboard`, not just
`QClipboardMode::Selection`; qtbase dev as of
0d0810e2dcc8a9ee28935af5daadc2ef36ed25a2):

1 QtClipboard::handleChanged QtClipboard.cxx 156 0x7f6284c7a7a8
2 QtPrivate::FunctorCall, 
QtPrivate::List, void, void (QtClipboard:: 
*)(QClipboard::Mode)>::call(void (QtClipboard:: *)(QClipboard::Mode), 
QtClipboard *, void * *)::{lambda()#1}::operator()() const qobjectdefs_impl.h 
153 0x7f6284c8450f
3 QtPrivate::FunctorCallBase::call_internal, 
QtPrivate::List, void, void (QtClipboard:: 
*)(QClipboard::Mode)>::call(void (QtClipboard:: *)(QClipboard::Mode), 
QtClipboard *, void * *)::{lambda()#1}>(void * *, 
QtPrivate::FunctorCall, 
QtPrivate::List, void, void (QtClipboard:: 
*)(QClipboard::Mode)>::call(void (QtClipboard:: *)(QClipboard::Mode), 
QtClipboard *, void * *)::{lambda()#1}&&) qobjectdefs_impl.h 72 0x7f6284c8500b
4 QtPrivate::FunctorCall, 
QtPrivate::List, void, void (QtClipboard:: 
*)(QClipboard::Mode)>::call qobjectdefs_impl.h 152 0x7f6284c8457f
5 QtPrivate::FunctionPointer::call, void> 
qobjectdefs_impl.h 200 0x7f6284c833ee
6 QtPrivate::QCallableObject, void>::impl qobjectdefs_impl.h 571 
0x7f6284c81f81
7 QtPrivate::QSlotObjectBase::call qobjectdefs_impl.h 487 0x7f62841b863f
8 doActivate qobject.cpp 4116 0x7f628425772e
9 QMetaObject::activate qobject.cpp 4176 0x7f628424cdef
10 QClipboard::changed moc_qclipboard.cpp 182 0x7f62831e9fcc
11 QClipboard::emitChanged qclipboard.cpp 558 0x7f62831e9bc1
12 QPlatformClipboard::emitChanged qplatformclipboard.cpp 89 
0x7f628324ed69
13 QtWaylandClient::QWaylandDataDevice::data_device_selection 

core.git: 2 commits - vcl/inc vcl/qt5

2024-01-28 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtTools.hxx |1 
 vcl/qt5/QtInstance.cxx  |   34 +-
 vcl/qt5/QtInstanceMessageDialog.cxx |   85 +---
 vcl/qt5/QtTools.cxx |   29 
 4 files changed, 44 insertions(+), 105 deletions(-)

New commits:
commit 053b88c371461cda49e99ab2fc060eb1f1ded580
Author: Michael Weghorn 
AuthorDate: Thu Jan 25 10:28:48 2024 +0100
Commit: Michael Weghorn 
CommitDate: Sun Jan 28 16:42:12 2024 +0100

tdf#159323 qt weld: Remember VCL response code, don't try to map

Set the VCL return code of a button as a property
"response-code" for the `QPushButton` and use that instead of
trying to map the VCL response code for a
button to a `QMessageBox::ButtonRole` and then
mapping that back to the original VCL return code.

While the previous approach worked fine for return codes
from the `VclResponseType` enum, it turns out that
any arbitrary int can be used, and supporting that
needs a different approach.

One example (s. tdf#159323 comment 7) is `SbRtl_MsgBox`
(in basic/source/runtime/methods.cxx) which uses
values from the `BasicResponse` enum defined in there
that has a `BasicResponse::Yes = 6`, but the
`VclResponseType` enum has nothing for the value 6.

Just use `QMessageBox::ButtonRole::ActionRole` for
all buttons, since there's no clear way to map from
the VCL response code to the `QMessageBox::ButtonRole::ActionRole`
in general.

Change-Id: I1782512d4eb47b2dcf71214d16e64d56127e9e3f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162560
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/qt5/QtInstanceMessageDialog.cxx 
b/vcl/qt5/QtInstanceMessageDialog.cxx
index ed48c5298a6c..7e505aff7cd0 100644
--- a/vcl/qt5/QtInstanceMessageDialog.cxx
+++ b/vcl/qt5/QtInstanceMessageDialog.cxx
@@ -11,68 +11,11 @@
 
 #include 
 
-namespace
-{
-QMessageBox::ButtonRole lcl_vclResponseTypeToQtMessageBoxButtonRole(int 
nResponseType)
-{
-// RET_CANCEL, RET_HELP, RET_YES, RET_NO and RET_OK have a matching 
equivalent
-// in Qt, the others are a bit more arbitrary; what really matters about 
these
-// is only that the mapping here and the other way around
-// (in lcl_qtMessageBoxButtonRoleToVclResponseType) is consistent
-switch (nResponseType)
-{
-case RET_CANCEL:
-return QMessageBox::ButtonRole::RejectRole;
-case RET_HELP:
-return QMessageBox::ButtonRole::HelpRole;
-case RET_YES:
-return QMessageBox::ButtonRole::YesRole;
-case RET_NO:
-return QMessageBox::ButtonRole::NoRole;
-case RET_OK:
-return QMessageBox::ButtonRole::AcceptRole;
-case RET_RETRY:
-return QMessageBox::ButtonRole::ResetRole;
-case RET_IGNORE:
-return QMessageBox::ButtonRole::ActionRole;
-case RET_CLOSE:
-return QMessageBox::ButtonRole::DestructiveRole;
-default:
-assert(false && "Unhandled vcl response type");
-return QMessageBox::InvalidRole;
-}
-}
-
-VclResponseType lcl_qtMessageBoxButtonRoleToVclResponseType(int nRet)
-{
-// AcceptRole, HelpRole, NoRole, RejectRole and YesRole have a matching 
equivalent
-// in VCL, the others are a bit more arbitrary; what really matters about 
these
-// is only that the mapping here and the other way around
-// (in lcl_vclResponseTypeToQtMessageBoxButtonRole) is consistent
-switch (nRet)
-{
-case QMessageBox::ButtonRole::AcceptRole:
-return RET_OK;
-case QMessageBox::ButtonRole::HelpRole:
-return RET_HELP;
-case QMessageBox::ButtonRole::NoRole:
-return RET_NO;
-case QMessageBox::ButtonRole::RejectRole:
-return RET_CANCEL;
-case QMessageBox::ButtonRole::YesRole:
-return RET_YES;
-case QMessageBox::ButtonRole::ResetRole:
-return RET_RETRY;
-case QMessageBox::ButtonRole::ActionRole:
-return RET_IGNORE;
-case QMessageBox::ButtonRole::DestructiveRole:
-return RET_CLOSE;
-default:
-assert(false && "Unhandled QMessageBox::ButtonRole");
-return RET_CANCEL;
-}
-}
-}
+/**
+ * Name of the property to set on a QPushButton that holds the
+ * VCL response code of that button.
+ */
+const char* const PROPERTY_VCL_RESPONSE_CODE = "response-code";
 
 QtInstanceMessageDialog::QtInstanceMessageDialog(QMessageBox* pMessageDialog)
 : QtInstanceDialog(pMessageDialog)
@@ -107,8 +50,9 @@ OUString QtInstanceMessageDialog::get_secondary_text() const
 void QtInstanceMessageDialog::add_button(const OUString& rText, int nResponse, 
const OUString&)
 {
 assert(m_pMessageDialog);
-m_pMessageDialog->addButton(vclToQtStringWithAccelerator(rText),
-

core.git: 2 commits - vcl/inc vcl/qt5

2024-01-24 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtMenu.hxx  |1 -
 vcl/inc/qt5/QtTools.hxx |5 +
 vcl/qt5/QtMenu.cxx  |   21 +
 vcl/qt5/QtTools.cxx |9 -
 4 files changed, 18 insertions(+), 18 deletions(-)

New commits:
commit ae910722fcd778d71c9e73a860a9ad94eb449608
Author: Michael Weghorn 
AuthorDate: Tue Jan 23 13:47:07 2024 +0100
Commit: Michael Weghorn 
CommitDate: Wed Jan 24 17:14:56 2024 +0100

qt: Move VCL -> Qt accelerator text handling to QtTools

Move the functionality to convert a string (potentially)
containing a VCL-style accelerator ('~') to the Qt equivalent
from `QtMenu::NativeItemText` to a new helper function
`vclToQtStringtWithAccelerator` in QtTools.hxx

This will be reused for button text in welded message dialogs
in an upcoming commit.

Change-Id: Ibedabb7937b97d195244045799c092463810d766
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162439
Tested-by: Jenkins
Reviewed-by: Omkar Acharekar  
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtMenu.hxx b/vcl/inc/qt5/QtMenu.hxx
index 587e1cfea8d1..28e5ac57146b 100644
--- a/vcl/inc/qt5/QtMenu.hxx
+++ b/vcl/inc/qt5/QtMenu.hxx
@@ -57,7 +57,6 @@ private:
 static OUString m_sCurrentHelpId;
 
 void DoFullMenuUpdate(Menu* pMenuBar);
-static void NativeItemText(OUString& rItemText);
 
 void InsertMenuItem(QtMenuItem* pSalMenuItem, unsigned nPos);
 
diff --git a/vcl/inc/qt5/QtTools.hxx b/vcl/inc/qt5/QtTools.hxx
index 20e0452188af..b419c1fd3da9 100644
--- a/vcl/inc/qt5/QtTools.hxx
+++ b/vcl/inc/qt5/QtTools.hxx
@@ -158,6 +158,11 @@ QString vclMessageTypeToQtTitle(VclMessageType eType);
 QMessageBox::StandardButtons vclButtonsTypeToQtButton(VclButtonsType 
eButtonType);
 int qtResponseTypeToVclResponseType(int ret);
 
+/** Converts a string potentially containing a '~' character to indicate an 
accelerator
+ *  to the Qt variant using '&' for the accelerator.
+ */
+QString vclToQtStringWithAccelerator(const OUString& rText);
+
 template 
 inline std::basic_ostream& operator<<(std::basic_ostream& stream,
  const QString& rString)
diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx
index 93f3d6f5a378..e3494356fc8b 100644
--- a/vcl/qt5/QtMenu.cxx
+++ b/vcl/qt5/QtMenu.cxx
@@ -71,8 +71,7 @@ bool QtMenu::VisibleMenuBar() { return true; }
 void QtMenu::InsertMenuItem(QtMenuItem* pSalMenuItem, unsigned nPos)
 {
 sal_uInt16 nId = pSalMenuItem->mnId;
-OUString aText = mpVCLMenu->GetItemText(nId);
-NativeItemText(aText);
+const QString aText = 
vclToQtStringWithAccelerator(mpVCLMenu->GetItemText(nId));
 vcl::KeyCode nAccelKey = mpVCLMenu->GetAccelKey(nId);
 
 pSalMenuItem->mpAction.reset();
@@ -83,7 +82,7 @@ void QtMenu::InsertMenuItem(QtMenuItem* pSalMenuItem, 
unsigned nPos)
 // top-level menu
 if (validateQMenuBar())
 {
-QMenu* pQMenu = new QMenu(toQString(aText), nullptr);
+QMenu* pQMenu = new QMenu(aText, nullptr);
 connectHelpSignalSlots(pQMenu, pSalMenuItem);
 pSalMenuItem->mpMenu.reset(pQMenu);
 
@@ -122,7 +121,7 @@ void QtMenu::InsertMenuItem(QtMenuItem* pSalMenuItem, 
unsigned nPos)
 if (pSalMenuItem->mpSubMenu)
 {
 // submenu
-QMenu* pQMenu = new QMenu(toQString(aText), nullptr);
+QMenu* pQMenu = new QMenu(aText, nullptr);
 connectHelpSignalSlots(pQMenu, pSalMenuItem);
 pSalMenuItem->mpMenu.reset(pQMenu);
 
@@ -172,7 +171,7 @@ void QtMenu::InsertMenuItem(QtMenuItem* pSalMenuItem, 
unsigned nPos)
 else
 {
 // leaf menu
-QAction* pAction = new QAction(toQString(aText), nullptr);
+QAction* pAction = new QAction(aText, nullptr);
 pSalMenuItem->mpAction.reset(pAction);
 
 if ((nPos != MENU_APPEND)
@@ -556,9 +555,7 @@ void QtMenu::SetItemText(unsigned, SalMenuItem* pItem, 
const OUString& rText)
 QAction* pAction = pSalMenuItem->getAction();
 if (pAction)
 {
-OUString aText(rText);
-NativeItemText(aText);
-pAction->setText(toQString(aText));
+pAction->setText(vclToQtStringWithAccelerator(rText));
 }
 }
 
@@ -683,14 +680,6 @@ void QtMenu::slotMenuAboutToHide(QtMenuItem* pQItem)
 }
 }
 
-void QtMenu::NativeItemText(OUString& rItemText)
-{
-// preserve literal '&'s in menu texts
-rItemText = rItemText.replaceAll("&", "&&");
-
-rItemText = rItemText.replace('~', '&');
-}
-
 void QtMenu::slotCloseDocument()
 {
 MenuBar* pVclMenuBar = static_cast(mpVCLMenu.get());
diff --git a/vcl/qt5/QtTools.cxx b/vcl/qt5/QtTools.cxx
index 0f8af934d2fa..e4000f9a99c1 100644
--- a/vcl/qt5/QtTools.cxx
+++ b/vcl/qt5/QtTools.cxx
@@ -212,4 +212,10 @@ int qtResponseTypeToVclResponseType(int ret)
 return ret;
 }
 
+QString vclToQtStringWithAccelerator(const OUString& rText)
+{
+

core.git: 2 commits - vcl/inc vcl/qt5

2024-01-24 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtInstanceDialog.hxx |4 ++--
 vcl/inc/qt5/QtInstanceWindow.hxx |7 ++-
 vcl/qt5/QtInstanceDialog.cxx |3 ++-
 vcl/qt5/QtInstanceWindow.cxx |   13 +++--
 4 files changed, 21 insertions(+), 6 deletions(-)

New commits:
commit d76d4df7ea1db0fdd27d350119ff7c0b2024b6e1
Author: Michael Weghorn 
AuthorDate: Tue Jan 23 13:45:48 2024 +0100
Commit: Michael Weghorn 
CommitDate: Wed Jan 24 17:14:37 2024 +0100

tdf#154381 qt weld: Implement QtInstanceWindow::{g,s}et_title

Implement methods to set and get the window title.

In order to do that, add a `m_pWidget` member to
`QtInstanceWindow`. For the `QtInstanceDialog` case, that widget
is a pointer to the same dialog that `QtInstanceDialog::m_pDialog`
points to, which is a unique_ptr and thus takes care of the memory
management.

The non-dialog case is not supported yet, s.a. this commit
adding support for simple welded message dialogs initially:

commit 1ace23443b85d4a81b94656844f1b27e2987
Date:   Wed Dec 20 19:13:50 2023 +0530

tdf#130857 Use native qt widgets - simple message dialog

With this in place, the qt6 welded message dialog that
shows up when opening a file that's already open in another
instance of LO has the correct title ("Document in Use"),
just as is the case for the non-welded one
(whose use can be forced by setting env var
`SAL_VCL_QT_NO_WELDED_WIDGETS=1`).

Change-Id: I35f323cdfa70fb953b6bc73aaf726fb1f3098c45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162437
Tested-by: Jenkins
Reviewed-by: Omkar Acharekar  
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtInstanceWindow.hxx b/vcl/inc/qt5/QtInstanceWindow.hxx
index be6aec6623cd..c29863da4f67 100644
--- a/vcl/inc/qt5/QtInstanceWindow.hxx
+++ b/vcl/inc/qt5/QtInstanceWindow.hxx
@@ -13,7 +13,12 @@
 
 class QtInstanceWindow : public QtInstanceContainer, public virtual 
weld::Window
 {
-virtual void set_title(const OUString&) override;
+QWidget* m_pWidget;
+
+public:
+QtInstanceWindow(QWidget* pWidget);
+
+virtual void set_title(const OUString& rTitle) override;
 virtual OUString get_title() const override;
 virtual void window_move(int, int) override;
 virtual void set_modal(bool) override;
diff --git a/vcl/qt5/QtInstanceDialog.cxx b/vcl/qt5/QtInstanceDialog.cxx
index 8d884688e247..e65e4b749e13 100644
--- a/vcl/qt5/QtInstanceDialog.cxx
+++ b/vcl/qt5/QtInstanceDialog.cxx
@@ -10,7 +10,8 @@
 #include 
 
 QtInstanceDialog::QtInstanceDialog(QDialog* pDialog)
-: m_pDialog(pDialog)
+: QtInstanceWindow(pDialog)
+, m_pDialog(pDialog)
 {
 }
 
diff --git a/vcl/qt5/QtInstanceWindow.cxx b/vcl/qt5/QtInstanceWindow.cxx
index e0bf4bfdd2af..0e74c8d6f873 100644
--- a/vcl/qt5/QtInstanceWindow.cxx
+++ b/vcl/qt5/QtInstanceWindow.cxx
@@ -9,9 +9,18 @@
 
 #include 
 
-void QtInstanceWindow::set_title(const OUString&) {}
+QtInstanceWindow::QtInstanceWindow(QWidget* pWidget)
+: m_pWidget(pWidget)
+{
+assert(m_pWidget);
+}
+
+void QtInstanceWindow::set_title(const OUString& rTitle)
+{
+m_pWidget->setWindowTitle(toQString(rTitle));
+}
 
-OUString QtInstanceWindow::get_title() const { return OUString(); }
+OUString QtInstanceWindow::get_title() const { return 
toOUString(m_pWidget->windowTitle()); }
 
 void QtInstanceWindow::window_move(int, int) {}
 
commit 8efcb80c95ab173a3931da3b35fc1b5bf1e4e0d2
Author: Michael Weghorn 
AuthorDate: Tue Jan 23 13:43:48 2024 +0100
Commit: Michael Weghorn 
CommitDate: Wed Jan 24 17:14:29 2024 +0100

qt weld: Make QtInstanceDialog::m_pDialog private

Change-Id: I757849beb06d0ce986be352feb34af463430333b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162436
Tested-by: Jenkins
Reviewed-by: Omkar Acharekar  
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtInstanceDialog.hxx b/vcl/inc/qt5/QtInstanceDialog.hxx
index 1eb7e5f63eb5..04b45d57a31f 100644
--- a/vcl/inc/qt5/QtInstanceDialog.hxx
+++ b/vcl/inc/qt5/QtInstanceDialog.hxx
@@ -13,9 +13,9 @@
 
 class QtInstanceDialog : public QtInstanceWindow, public virtual weld::Dialog
 {
-public:
 std::unique_ptr m_pDialog;
 
+public:
 QtInstanceDialog(QDialog* pDialog);
 
 virtual bool runAsync(std::shared_ptr const&,
@@ -48,4 +48,4 @@ public:
 virtual weld::Container* weld_content_area() override;
 };
 
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


[Libreoffice-commits] core.git: 2 commits - vcl/inc vcl/qt5

2023-09-02 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtFrame.hxx |1 +
 vcl/qt5/QtFrame.cxx |   20 +++-
 2 files changed, 20 insertions(+), 1 deletion(-)

New commits:
commit 19b8bac2aa59d02968c33ac6f83c66907d5ab94c
Author: Michael Weghorn 
AuthorDate: Sat Sep 2 10:37:47 2023 +0200
Commit: Michael Weghorn 
CommitDate: Sat Sep 2 15:42:44 2023 +0200

tdf#149611 qt: Make auto-selection of dark app colors work

Rename the newly introduced method
`QtFrame::isUsingDarkColorScheme` to detect whether
a dark color scheme is in use from

Change-Id I8f347c6e7f775cc55377c5c84481de3051c3cf24
tdf#156894 qt: Prefer dark icon theme in dark mode

and let it override `SalFrame::GetUseDarkMode`.

This gets used (via `MiscSettings::GetUseDarkMode`)
in `ColorConfig::GetDefaultColor` to determine what
application colors to use.

With this, setting "Tools" -> "Options" -> "LibreOfficeDev"
-> "Application Colors" -> "Automatic" to "System Theme"
will now automatically switch to dark application colors
(like a dark doc background instead of white) for kf5/qt6
when a dark global theme is active (e.g. because "Breeze Dark"
has been selected in Plasma system settings).

Change-Id: I151e7eb35a94a9c525452a7d90b24283f6226904
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156467
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index ecedc3ae2e29..b5ae7508a506 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -128,7 +128,6 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public 
SalFrame
 bool isWindow() const;
 QWindow* windowHandle() const;
 QScreen* screen() const;
-static bool isUsingDarkColorScheme();
 bool isMinimized() const;
 bool isMaximized() const;
 void SetWindowStateImpl(Qt::WindowStates eState);
@@ -215,6 +214,7 @@ public:
 virtual void SetScreenNumber(unsigned int) override;
 virtual void SetApplicationID(const OUString&) override;
 virtual void ResolveWindowHandle(SystemEnvData& rData) const override;
+virtual bool GetUseDarkMode() const override;
 virtual bool GetUseReducedAnimation() const override;
 
 inline bool CallCallback(SalEvent nEvent, const void* pEvent) const;
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index ff7edb9fd7b2..49d542a64909 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -354,7 +354,7 @@ QScreen* QtFrame::screen() const
 #endif
 }
 
-bool QtFrame::isUsingDarkColorScheme()
+bool QtFrame::GetUseDarkMode() const
 {
 #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
 const QStyleHints* pStyleHints = QApplication::styleHints();
@@ -1234,7 +1234,7 @@ void QtFrame::UpdateSettings(AllSettings& rSettings)
 style.SetMenuFont(aFont);
 
 // Icon theme
-const bool bPreferDarkTheme = isUsingDarkColorScheme();
+const bool bPreferDarkTheme = GetUseDarkMode();
 style.SetPreferredIconTheme(toOUString(QIcon::themeName()), 
bPreferDarkTheme);
 
 // Scroll bar size
commit 73d0d205c43a9848acd313ff1845ebafe63e807c
Author: Michael Weghorn 
AuthorDate: Sat Sep 2 10:12:54 2023 +0200
Commit: Michael Weghorn 
CommitDate: Sat Sep 2 15:42:37 2023 +0200

tdf#156894 qt: Prefer dark icon theme in dark mode

When in dark mode, pass the param to prefer a dark
icon theme to
`StyleSettings::SetPreferredIconTheme`.

For Qt >= 6.5 use `QStyleHints::colorScheme`
introduced in Qt 6.5 to get the color scheme.
For older Qt versions, use the same algorithm based
on the gray value of the window background as
xdg-desktop-portal-kde does for evaluating whether
a light or dark color scheme is preferred [1].

On my Debian testing, the Breeze dark icon theme is
now used as expected with kf5 or qt6 when setting
the Global KDE Plasma theme to "Breeze Dark" and
manually setting the Icon theme to "GNOME" afterwards.
Previously, this would not use a dark icon theme and
icons would be hard to see.

Without manually setting the icon theme to "GNOME",
the Breeze Dark icon theme would already be used
before, because selecting "Breeze Dark" as the
global KDE Plasma theme also selects the "Breeze Dark"
icon theme by default, and therefore "breeze-dark"
was already passed as the first param to
`StyleSettings::SetPreferredIconTheme` and since
that icon theme is present, the `bPreferDarkTheme`
wouldn't be evaluated at all; it's only used
when determining the fallback icon theme when
the specified icon theme is not present.

(Likewise, by enabling the "Breeze Dark" global theme
and then manually setting the icon theme to "Breeze"
in Plasma System settings, the Breeze light icon theme
will be used in LibreOffice as well, resulting in hard
to see icons, but I tend to think that that behavior is
correct and works 

[Libreoffice-commits] core.git: 2 commits - vcl/inc vcl/qt5 vcl/unx

2023-07-25 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtFrame.hxx   |1 +
 vcl/inc/qt5/QtInstance.hxx|2 ++
 vcl/inc/unx/gtk/gtkframe.hxx  |1 +
 vcl/qt5/QtFrame.cxx   |2 ++
 vcl/unx/gtk3/gtkframe.cxx |   10 ++
 vcl/unx/kf5/KFSalInstance.cxx |   23 +++
 vcl/unx/kf5/KFSalInstance.hxx |2 ++
 7 files changed, 41 insertions(+)

New commits:
commit f3a4b6e1d71ed40d84ef65c6626fb7eb77a13545
Author: Michael Weghorn 
AuthorDate: Tue Jul 25 11:52:32 2023 +0200
Commit: Michael Weghorn 
CommitDate: Tue Jul 25 14:48:26 2023 +0200

tdf#155414 kf a11y: Honor KDE Plasma setting to reduce animation

When using the kf5/kf6 VCL plugin on KDE Plasma, use the animation speed
setting to determine whether animations should be disabled, in line with
what is documented in MDN docs for Firefox using for the
"prefers-reduced-motion" CSS media feature [1] and how
kde-gtk-config maps that to the "gtk-enable-animations" setting [2].

The setting can be set as described in [2]:

> In Plasma/KDE: System Settings > Workspace Behavior -> General Behavior >
> "Animation speed" is set all the way to right to "Instant".

On top of

commit 9d68c794d67259a38de1465090f6f1e7fb588d62
Author: Patrick Luby 
Date:   Fri Jul 21 19:55:02 2023 -0400

tdf#155414 include system "reduce animation" preferences

, this basically implements the KF5/KDE Plasma equivalent of what that 
change does
for macOS.

Other than Gtk, Qt does not seem to have a general way to specify
that animations should be reduced/disabled, so evaluate
that based on the desktop environment instead, and implement
for KDE Plasma for the kf5/kf6 VCL plugin only for now, which is
probably the most common use case.

Logically, this would better fit in the qt5/qt6 VCL plugin
than the kf5/kf6 one, but do it in the KF-specific code to avoid
a dependency on KF5/KF6 libraries in qt5/qt6. (And other than
qt5/qt6, kf5/kf6 are auto-selected in Qt-based desktop environments,
so it shouldn't make much of a difference in practice.)
Another alternative - should the need aries - might be to move this
from the VCL plugin to the desktop backend (`shell/source/backends/kf5be/`
for the case of KDE Plasma 5.) and introduce a new property for that.

[1] 
https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
[2] https://docs.gtk.org/gtk4/property.Settings.gtk-enable-animations.html
[3] 
https://invent.kde.org/plasma/kde-gtk-config/-/blob/881ae01ad361a03396f7f327365f225ef87688e8/kded/gtkconfig.cpp#L205

Change-Id: I35cd6c2568a3716491581e51dfaeaf32cad454aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154888
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index 1fd010d7c8ae..90195f55a543 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -214,6 +214,7 @@ public:
 virtual void SetScreenNumber(unsigned int) override;
 virtual void SetApplicationID(const OUString&) override;
 virtual void ResolveWindowHandle(SystemEnvData& rData) const override;
+virtual bool GetUseReducedAnimation() const override;
 
 inline bool CallCallback(SalEvent nEvent, const void* pEvent) const;
 
diff --git a/vcl/inc/qt5/QtInstance.hxx b/vcl/inc/qt5/QtInstance.hxx
index a0a2f6fa60f7..2073c8ac05d8 100644
--- a/vcl/inc/qt5/QtInstance.hxx
+++ b/vcl/inc/qt5/QtInstance.hxx
@@ -174,6 +174,8 @@ public:
 virtual css::uno::Reference
 ImplCreateDropTarget(const SystemEnvData*) override;
 
+// whether to reduce animations; KFSalInstance overrides this to read 
Plasma settings
+virtual bool GetUseReducedAnimation() { return false; }
 void UpdateStyle(bool bFontsChanged);
 
 void* CreateGStreamerSink(const SystemChildWindow*) override;
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 08d206261b88..0bd436266714 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -1349,6 +1349,8 @@ void QtFrame::ResolveWindowHandle(SystemEnvData& rData) 
const
 rData.SetWindowHandle(static_cast(rData.pWidget)->winId());
 }
 
+bool QtFrame::GetUseReducedAnimation() const { return 
GetQtInstance()->GetUseReducedAnimation(); }
+
 // Drag'n'drop foo
 
 void QtFrame::registerDragSource(QtDragSource* pDragSource)
diff --git a/vcl/unx/kf5/KFSalInstance.cxx b/vcl/unx/kf5/KFSalInstance.cxx
index bed513167957..cc280e9d99a1 100644
--- a/vcl/unx/kf5/KFSalInstance.cxx
+++ b/vcl/unx/kf5/KFSalInstance.cxx
@@ -21,6 +21,8 @@
 
 #include 
 
+#include 
+#include 
 #include 
 
 #include 
@@ -40,6 +42,27 @@ KFSalInstance::KFSalInstance(std::unique_ptr& 
pQApp)
 pSVData->maAppData.mxToolkitName = constructToolkitID(sToolkit);
 }
 
+bool KFSalInstance::GetUseReducedAnimation()
+{
+// since Qt doesn not have a standard way to disable animations for the 
toolkit
+ 

[Libreoffice-commits] core.git: 2 commits - vcl/inc vcl/qt5

2023-07-24 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtFrame.hxx |2 +-
 vcl/qt5/QtMenu.cxx  |   10 +++---
 2 files changed, 8 insertions(+), 4 deletions(-)

New commits:
commit 447b91964daf3ffed5bfd59382ba5724e9992fe8
Author: Michael Weghorn 
AuthorDate: Mon Jul 24 10:50:20 2023 +0200
Commit: Michael Weghorn 
CommitDate: Mon Jul 24 17:27:20 2023 +0200

tdf#154447 qt: Take menu bar into account for popup pos

Change-Id I66b312fe09e078ec067773a483f9e59f627fcf93
("tdf#154447 Fix menu position in kf5") fixes the
position for menu popups for the case where no menu
bar is present, e.g. the default after switching to
the Tabbed interface.

While it improves the case where a menu bar is present,
the menu would would still open a bit too far up for
that case.

Adapt the position by the menu bar height to make that
case work as expected as well.

Do this in `QtMenu::ShowNativePopupMenu` for now since that's
easiest. Potentially, the height should have been taken
into consideration somewhere earlier, but since the whole
handling of menu bar height is quite "special", don't
aim to address that elsewhere now, s.a. an earlier attempt
to rework the whole handling in

commit afc828b9833b7a612369e95606ba56d41ef2c369
Date:   Sat May 28 23:47:21 2022 +0200

VCL expect correct frame size for native menubars

which was later reverted in

commit f51b220b953ec71fb742f799fbe645a93cf3d944
Date:   Fri Mar 24 08:06:56 2023 +0100

tdf#149805 tdf#151677 tdf#152217 tdf#154043 tdf#153458 tdf#153800 
Revert "VCL expect

... correct frame size for native menubars"

Change-Id: Iafd80997f9f506cb22afe1aaf6d1a3f716700ea3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154839
Tested-by: Jenkins
Tested-by: Rafael Lima 
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index 09abe5301538..1fd010d7c8ae 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -131,7 +131,6 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public 
SalFrame
 bool isMinimized() const;
 bool isMaximized() const;
 void SetWindowStateImpl(Qt::WindowStates eState);
-int menuBarOffset() const;
 
 void fixICCCMwindowGroup();
 
@@ -146,6 +145,7 @@ public:
 QtMainWindow* GetTopLevelWindow() const { return m_pTopLevel; }
 QWidget* asChild() const;
 qreal devicePixelRatioF() const;
+int menuBarOffset() const;
 
 void Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 
nExtentsWidth,
 sal_Int32 nExtentsHeight) const;
diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx
index b239b457ce9a..b976fa3f5739 100644
--- a/vcl/qt5/QtMenu.cxx
+++ b/vcl/qt5/QtMenu.cxx
@@ -837,9 +837,13 @@ bool QtMenu::ShowNativePopupMenu(FloatingWindow* pWin, 
const tools::Rectangle& r
 mpQMenu->setTearOffEnabled(bool(nFlags & 
FloatWinPopupFlags::AllowTearOff));
 
 const VclPtr xParent = 
pWin->ImplGetWindowImpl()->mpRealParent;
-const QtFrame* pFrame = static_cast(xParent->ImplGetFrame());
+tools::Rectangle aFloatRect = FloatingWindow::ImplConvertToAbsPos(xParent, 
rRect);
+
+// tdf#154447 Menu bar height has to be added
+QtFrame* pFrame = static_cast(pWin->ImplGetFrame());
 assert(pFrame);
-const tools::Rectangle aFloatRect = 
FloatingWindow::ImplConvertToAbsPos(xParent, rRect);
+aFloatRect.SetPosY(aFloatRect.getY() + pFrame->menuBarOffset());
+
 const QRect aRect = toQRect(aFloatRect, 1 / pFrame->devicePixelRatioF());
 mpQMenu->exec(aRect.bottomLeft());
 
commit 7b060d1c2acf03378c87abb7215f9c0a957b549c
Author: Rafael Lima 
AuthorDate: Sun Jul 23 14:57:58 2023 +0200
Commit: Michael Weghorn 
CommitDate: Mon Jul 24 17:27:12 2023 +0200

tdf#154447 Fix menu position in kf5

Prior to this patch the menus were using "topLeft" as reference for 
positioning the menu, which made them appear on top of the control that 
originated their appearance.

With this patch, it now uses "bototmLeft" to place the menu below the 
control (similar to gtk3).

Change-Id: I66b312fe09e078ec067773a483f9e59f627fcf93
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154771
Tested-by: Jenkins
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 
Reviewed-by: Michael Weghorn 

diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx
index dca03050c30e..b239b457ce9a 100644
--- a/vcl/qt5/QtMenu.cxx
+++ b/vcl/qt5/QtMenu.cxx
@@ -841,7 +841,7 @@ bool QtMenu::ShowNativePopupMenu(FloatingWindow* pWin, 
const tools::Rectangle& r
 assert(pFrame);
 const tools::Rectangle aFloatRect = 
FloatingWindow::ImplConvertToAbsPos(xParent, rRect);
 const QRect aRect = toQRect(aFloatRect, 1 / pFrame->devicePixelRatioF());
-mpQMenu->exec(aRect.topLeft());
+mpQMenu->exec(aRect.bottomLeft());
 
 return 

[Libreoffice-commits] core.git: 2 commits - vcl/inc vcl/qt5 vcl/source

2023-02-19 Thread Michael Weghorn (via logerrit)
 vcl/inc/listbox.hxx|1 -
 vcl/qt5/QtGraphics_Controls.cxx|4 +++-
 vcl/source/control/imp_listbox.cxx |   36 ++--
 vcl/source/control/listbox.cxx |   14 ++
 4 files changed, 27 insertions(+), 28 deletions(-)

New commits:
commit b845ba1900387b8ea44a27a1f7d045ca0091adf2
Author: Michael Weghorn 
AuthorDate: Tue Feb 14 17:20:49 2023 +0100
Commit: Michael Weghorn 
CommitDate: Mon Feb 20 06:11:05 2023 +

tdf#153614 qt: Set keyboard focus state when focused, too

For example the Breeze theme only draws a light blue
focus rectangle for list boxes when the
`QStyle::State_KeyboardFocusChange` state is set in addition
to `QStyle::State_HasFocus`.
Therefore, set that state in addition to ensure that the focused
control actually gets a focus indicator when moving there
using the keyboard.

Change-Id: Ib4b85f9140629e6b69c80b85e85913392a6c000f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147019
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/qt5/QtGraphics_Controls.cxx b/vcl/qt5/QtGraphics_Controls.cxx
index 0c5b85d28a11..4bb4df1e6e66 100644
--- a/vcl/qt5/QtGraphics_Controls.cxx
+++ b/vcl/qt5/QtGraphics_Controls.cxx
@@ -40,7 +40,9 @@ static QStyle::State vclStateValue2StateFlag(ControlState 
nControlState,
 {
 QStyle::State nState
 = ((nControlState & ControlState::ENABLED) ? QStyle::State_Enabled : 
QStyle::State_None)
-  | ((nControlState & ControlState::FOCUSED) ? QStyle::State_HasFocus 
: QStyle::State_None)
+  | ((nControlState & ControlState::FOCUSED)
+ ? QStyle::State_HasFocus | QStyle::State_KeyboardFocusChange
+ : QStyle::State_None)
   | ((nControlState & ControlState::PRESSED) ? QStyle::State_Sunken : 
QStyle::State_None)
   | ((nControlState & ControlState::SELECTED) ? QStyle::State_Selected 
: QStyle::State_None)
   | ((nControlState & ControlState::ROLLOVER) ? QStyle::State_MouseOver
commit d5ace6bf0f1e48ee02e5eb22ce0f9f8953517f60
Author: Michael Weghorn 
AuthorDate: Tue Feb 14 16:16:30 2023 +0100
Commit: Michael Weghorn 
CommitDate: Mon Feb 20 06:10:58 2023 +

tdf#153520 vcl: Align listbox invalidation with mouseover check

Before

commit 4cb11d8a6682fecd661b926a417ae7f26f76e7db
Date:   Fri Oct 7 16:40:23 2022 +0100

Related: tdf#98067 do RollOver for Edit as well as SpinButton

, the check whether the mouse is over a control
was only checking the control's child windows.
The above commit introduced a check for the control's
window as well in `ImplSmallBorderWindowView::DrawWindow`.

When moving the mouse inside or outside a `ListBox` control,
the invalidation of the corresponding border window happened
when the mouse cursor would enter or leave the `ListBox`'s
`ImplWin` child (in `ImplWin::PreNotify`).

The `ImplWin` only covers a part of the `ListBox` area. As
a consequence, when moving the mouse out of the `ImplWin`
area, the mouse would still be over the parent `ListBox` area,
so the `ControlState::ROLLOVER` state would still be set
in `ImplSmallBorderWindowView::DrawWindow` from the above
commit on.

Since there was no additional invalidation when the mouse
moved out of the `ListBox` area, the `ROLLOVER` state would
remain set even when the mouse left the `ListBox` area as well.

Move the invalidation from `ImplWin` to `ListBox` so
this gets processed when the mouse cursor actually enters or
leaves the `ListBox`, not just the `ImplWin` child.

Also align the mouse over check in
`ImplWin::ImplDraw` with the one in
`ImplSmallBorderWindowView::DrawWindow` again.
(Take the parent into account there as well.)

Change-Id: I8974e370819719489e3d9f091d96b3353888d26b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147018
Tested-by: Jenkins
Reviewed-by: Rafael Lima 

diff --git a/vcl/inc/listbox.hxx b/vcl/inc/listbox.hxx
index 8aa23e90cff8..e9bd4f53b843 100644
--- a/vcl/inc/listbox.hxx
+++ b/vcl/inc/listbox.hxx
@@ -559,7 +559,6 @@ public:
 virtual voidResize() override;
 virtual voidGetFocus() override;
 virtual voidLoseFocus() override;
-virtual boolPreNotify( NotifyEvent& rNEvt ) override;
 
 sal_Int32   GetItemPos() const { return mnItemPos; }
 voidSetItemPos( sal_Int32  n ) { mnItemPos = n; }
diff --git a/vcl/source/control/imp_listbox.cxx 
b/vcl/source/control/imp_listbox.cxx
index 75bc1fd622e2..1b18498c68fc 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -2537,25 +2537,6 @@ void ImplWin::FillLayoutData() const
 pThis->ImplDraw(*pThis->GetOutDev(), true);
 }
 
-bool ImplWin::PreNotify( NotifyEvent& rNEvt )
-{
-if( rNEvt.GetType() == 

[Libreoffice-commits] core.git: 2 commits - vcl/inc vcl/qt5 vcl/source

2019-06-22 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx  |3 ---
 vcl/inc/qt5/Qt5Widget.hxx |3 ---
 vcl/qt5/Qt5Frame.cxx  |   10 +-
 vcl/qt5/Qt5Widget.cxx |7 ---
 vcl/source/app/salvtables.cxx |6 ++
 5 files changed, 11 insertions(+), 18 deletions(-)

New commits:
commit ab5f341efd144adb6b7d0e00fece76a2153acd10
Author: Jan-Marek Glogowski 
AuthorDate: Sat Jun 22 02:25:24 2019 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Sat Jun 22 19:28:12 2019 +0200

Qt5 directly show tooltips + respect the help area

I'm not sure why this redirection was implemented, which also ommited
the provided help area. I tried hard to use vc::Window code in the
beginning, but that also mirrors the cursor position for the window.
Using Qt here is simply straight forward, so just do that,

Change-Id: Ia8c4efc1e43b915c4b071ee26d4da37d7580817c
Reviewed-on: https://gerrit.libreoffice.org/74548
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index d7f8f1aa6e1f..5b1bc1025445 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -133,9 +133,6 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public 
SalFrame
 void TriggerPaintEvent();
 void TriggerPaintEvent(QRect aRect);
 
-Q_SIGNALS:
-void tooltipRequest(const OUString& rTooltip);
-
 public:
 Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nSalFrameStyle, bool 
bUseCairo);
 virtual ~Qt5Frame() override;
diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 8ead4b3ec945..85523951cda2 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -70,9 +70,6 @@ class Qt5Widget : public QWidget
 void inputMethodEvent(QInputMethodEvent*) override;
 QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
 
-public slots:
-static void showTooltip(const OUString& rTip);
-
 public:
 Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
 
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index dbdc51ea9465..d585f627b7fd 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -155,9 +155,6 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 else
 m_pQWidget = new Qt5Widget(*this, aWinFlags);
 
-connect(this, ::tooltipRequest, 
static_cast(m_pQWidget),
-::showTooltip);
-
 if (pParent && !(pParent->m_nStyle & SalFrameStyleFlags::PLUG))
 {
 QWindow* pParentWindow = 
pParent->GetQWidget()->window()->windowHandle();
@@ -743,9 +740,12 @@ void Qt5Frame::Flush()
 // destroyed, so that state should be safely flushed.
 }
 
-bool Qt5Frame::ShowTooltip(const OUString& rText, const tools::Rectangle& 
/*rHelpArea*/)
+bool Qt5Frame::ShowTooltip(const OUString& rText, const tools::Rectangle& 
rHelpArea)
 {
-emit tooltipRequest(rText);
+QRect aHelpArea(toQRect(rHelpArea));
+if (QGuiApplication::isRightToLeft())
+aHelpArea.moveLeft(maGeometry.nWidth - aHelpArea.width() - 
aHelpArea.left() - 1);
+QToolTip::showText(QCursor::pos(), toQString(rText), m_pQWidget, 
aHelpArea);
 return true;
 }
 
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 42f3353ff26b..843ce798a989 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -40,7 +40,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -503,12 +502,6 @@ void Qt5Widget::focusOutEvent(QFocusEvent*)
 m_rFrame.CallCallback(SalEvent::LoseFocus, nullptr);
 }
 
-void Qt5Widget::showTooltip(const OUString& rTooltip)
-{
-QPoint pt = QCursor::pos();
-QToolTip::showText(pt, toQString(rTooltip));
-}
-
 Qt5Widget::Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f)
 : QWidget(Q_NULLPTR, f)
 , m_rFrame(rFrame)
commit 4cbf5a4f666ac4d7b01746bc36ab01400e28ff40
Author: Caolán McNamara 
AuthorDate: Fri Jun 21 21:55:20 2019 +0100
Commit: Caolán McNamara 
CommitDate: Sat Jun 22 19:28:04 2019 +0200

Related: tdf#126036 sort button by native order for async dialogs too

Change-Id: Iddc689b8d332e8e0127806c37b5ccce66eadfcf6
Reviewed-on: https://gerrit.libreoffice.org/74540
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index b17e0215258d..fc62bb6441e2 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1218,6 +1218,9 @@ public:
 VclAbstractDialog::AsyncContext aCtx;
 aCtx.mxOwnerDialogController = aOwner;
 aCtx.maEndDialogFn = rEndDialogFn;
+VclButtonBox* pActionArea = m_xDialog->get_action_area();
+if (pActionArea)
+   pActionArea->sort_native_button_order();
 return m_xDialog->StartExecuteAsync(aCtx);
 }
 
@@ -1229,6 +1232,9 @@ public:
 // which is that rxSelf enforces.
 aCtx.mxOwnerSelf = rxSelf;

[Libreoffice-commits] core.git: 2 commits - vcl/inc vcl/qt5

2018-08-07 Thread Libreoffice Gerrit user
 vcl/inc/qt5/Qt5Frame.hxx |9 +
 vcl/qt5/Qt5Bitmap.cxx|6 +++---
 vcl/qt5/Qt5Timer.cxx |8 +++-
 3 files changed, 19 insertions(+), 4 deletions(-)

New commits:
commit b9a6760a371f00d49614732790782c9a456f4e86
Author: Jan-Marek Glogowski 
AuthorDate: Mon Aug 6 17:17:52 2018 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Tue Aug 7 16:43:38 2018 +0200

Qt5 static_cast bitmap data should be enough

This failed to build to on Haiku with:

/sources/core/vcl/qt5/Qt5Bitmap.cxx:
 In member function 'virtual bool Qt5Bitmap::Create(const SalBitmap&, 
sal_uInt16)':
/sources/core/vcl/qt5/Qt5Bitmap.cxx:155:92:
  error: invalid cast from type 'unsigned int' to type 'sal_uInt32 {aka 
long unsigned int}'
*image_data = 
reinterpret_cast(colorTable.at(*buffer_data >> 4));

Change-Id: Ib536901f8c55f854715089bce0ad5d954dd529e9
Reviewed-on: https://gerrit.libreoffice.org/58651
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/qt5/Qt5Bitmap.cxx b/vcl/qt5/Qt5Bitmap.cxx
index 23cde0cb31da..b8e8e4bdf159 100644
--- a/vcl/qt5/Qt5Bitmap.cxx
+++ b/vcl/qt5/Qt5Bitmap.cxx
@@ -154,15 +154,15 @@ bool Qt5Bitmap::Create(const SalBitmap& rSalBmp, 
sal_uInt16 nNewBitCount)
 buffer_data_pos += pBitmap->m_nScanline;
 for (sal_uInt32 w = 0; w < nWidth; ++w)
 {
-*image_data = 
reinterpret_cast(colorTable.at(*buffer_data >> 4));
+*image_data = 
static_cast(colorTable.at(*buffer_data >> 4));
 ++image_data;
-*image_data = 
reinterpret_cast(colorTable.at(*buffer_data & 0xF));
+*image_data = 
static_cast(colorTable.at(*buffer_data & 0xF));
 ++image_data;
 ++buffer_data;
 }
 if (isOdd)
 {
-*image_data = 
reinterpret_cast(colorTable.at(*buffer_data >> 4));
+*image_data = 
static_cast(colorTable.at(*buffer_data >> 4));
 ++image_data;
 }
 }
commit 0c02747e54d34c4148a8a8fe389726703187ab5d
Author: Jan-Marek Glogowski 
AuthorDate: Mon Aug 6 17:11:52 2018 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Tue Aug 7 16:43:25 2018 +0200

Qt5 fix main loop locking when processing events

In commit bded890a44cc ("Qt5 just release the SolarMutex for Qt
event") the Qt5 main loop was switched to running non-locked, as
most other backends do, so now we must take the lock when
processing Qt events.

Eventually CallCallback should be virtual for security?

Change-Id: I8cbfc9bb8b3de677a70ad3bd5cb3910fabec9b87
Reviewed-on: https://gerrit.libreoffice.org/58650
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 96446c28a358..310298879e52 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -25,6 +25,7 @@
 #include "Qt5Tools.hxx"
 
 #include 
+#include 
 
 class Qt5Graphics;
 class Qt5Instance;
@@ -140,6 +141,14 @@ public:
 
 virtual void SetScreenNumber(unsigned int) override;
 virtual void SetApplicationID(const OUString&) override;
+
+inline bool CallCallback(SalEvent nEvent, const void* pEvent) const;
 };
 
+inline bool Qt5Frame::CallCallback(SalEvent nEvent, const void* pEvent) const
+{
+SolarMutexGuard aGuard;
+return SalFrame::CallCallback(nEvent, pEvent);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Timer.cxx b/vcl/qt5/Qt5Timer.cxx
index 2fa07886f60f..56dec31d7d31 100644
--- a/vcl/qt5/Qt5Timer.cxx
+++ b/vcl/qt5/Qt5Timer.cxx
@@ -23,6 +23,8 @@
 #include 
 #include 
 
+#include 
+
 Qt5Timer::Qt5Timer()
 {
 m_aTimer.setSingleShot(true);
@@ -34,7 +36,11 @@ Qt5Timer::Qt5Timer()
 
 Qt5Timer::~Qt5Timer() {}
 
-void Qt5Timer::timeoutActivated() { CallCallback(); }
+void Qt5Timer::timeoutActivated()
+{
+SolarMutexGuard aGuard;
+CallCallback();
+}
 
 void Qt5Timer::startTimer() { m_aTimer.start(); }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits