[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - vcl/inc vcl/qt5 vcl/unx

2019-08-22 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5DragAndDrop.hxx  |   21 +
 vcl/inc/qt5/Qt5Frame.hxx|   10 +-
 vcl/inc/qt5/Qt5Tools.hxx|3 
 vcl/inc/qt5/Qt5Transferable.hxx |2 
 vcl/inc/qt5/Qt5Widget.hxx   |2 
 vcl/qt5/Qt5DragAndDrop.cxx  |   93 
 vcl/qt5/Qt5Frame.cxx|  153 
 vcl/qt5/Qt5Tools.cxx|   12 +++
 vcl/qt5/Qt5Widget.cxx   |   32 +---
 vcl/unx/kde5/KDE5SalFrame.hxx   |4 -
 10 files changed, 174 insertions(+), 158 deletions(-)

New commits:
commit 658ab1db3abce8941352d8d9def1468496985a60
Author: Jan-Marek Glogowski 
AuthorDate: Thu Aug 8 17:59:20 2019 +
Commit: Michael Weghorn 
CommitDate: Thu Aug 22 16:38:04 2019 +0200

tdf#126560 Qt5 fix D'n'D key-modifier handling

The patch has still one problem: the key-modifier state isn't
reflected by the cursor, unless the user moves the mouse. There is
an upstream Qt bug, reported in 2016-09 against Qt 5.6.1! It is
supposed to be fixed in Qt 5.12, according to the bug report at
https://bugreports.qt.io/browse/QTBUG-56218, which is still open.

I thought about adding a configure test, but I couldn't imagine
any realistic way to write it. And after Michael Weghorn found the
bug is actually not fixed, as claimed in one of the comments, I
decided to drop the warning.

Change-Id: Ice8ebc4ea149282b4c1551e755efe3d4856cf782
Reviewed-on: https://gerrit.libreoffice.org/77174
Reviewed-by: Michael Weghorn 
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 
(cherry picked from commit 3355be0616c24c5e44b71e7623c4191ed9c69074)
Reviewed-on: https://gerrit.libreoffice.org/77956

diff --git a/vcl/inc/qt5/Qt5DragAndDrop.hxx b/vcl/inc/qt5/Qt5DragAndDrop.hxx
index dcd6cb5e4048..0ec9ce5bbcb2 100644
--- a/vcl/inc/qt5/Qt5DragAndDrop.hxx
+++ b/vcl/inc/qt5/Qt5DragAndDrop.hxx
@@ -25,7 +25,6 @@ class Qt5DragSource
 osl::Mutex m_aMutex;
 Qt5Frame* m_pFrame;
 css::uno::Reference 
m_xListener;
-css::uno::Reference m_xTrans;
 
 public:
 Qt5DragSource()
@@ -55,17 +54,7 @@ public:
 
 css::uno::Sequence SAL_CALL getSupportedServiceNames() override;
 
-void dragFailed();
-void fire_dragEnd(sal_Int8 nAction);
-
-static Qt5DragSource* m_ActiveDragSource;
-static bool m_bDropSuccessSet;
-static bool m_bDropSuccess;
-
-css::uno::Reference const& 
GetTransferable() const
-{
-return m_xTrans;
-}
+void fire_dragEnd(sal_Int8 nAction, bool bSuccessful);
 };
 
 class Qt5DropTarget
@@ -76,11 +65,11 @@ class Qt5DropTarget
 {
 osl::Mutex m_aMutex;
 Qt5Frame* m_pFrame;
-sal_Int8 mnDragAction;
-sal_Int8 mnDropAction;
+sal_Int8 m_nDropAction;
 bool m_bActive;
 sal_Int8 m_nDefaultActions;
 
std::vector> 
m_aListeners;
+bool m_bDropSuccessful;
 
 public:
 Qt5DropTarget();
@@ -115,10 +104,12 @@ public:
 css::uno::Sequence SAL_CALL getSupportedServiceNames() override;
 
 void fire_dragEnter(const 
css::datatransfer::dnd::DropTargetDragEnterEvent& dtde);
+void fire_dragExit(const css::datatransfer::dnd::DropTargetEvent& dte);
 void fire_dragOver(const css::datatransfer::dnd::DropTargetDragEnterEvent& 
dtde);
 void fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde);
 
-sal_Int8 proposedDragAction() const { return mnDragAction; }
+sal_Int8 proposedDropAction() const { return m_nDropAction; }
+bool dropSuccessful() const { return m_bDropSuccessful; }
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 4c94b846bc93..e296ce92db29 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -56,6 +56,8 @@ class Qt5MainWindow;
 class Qt5Menu;
 class Qt5SvpGraphics;
 
+class QDragMoveEvent;
+class QDropEvent;
 class QImage;
 class QMimeData;
 class QPaintDevice;
@@ -159,10 +161,10 @@ public:
 virtual void deregisterDragSource(Qt5DragSource const* pDragSource);
 virtual void registerDropTarget(Qt5DropTarget* pDropTarget);
 virtual void deregisterDropTarget(Qt5DropTarget const* pDropTarget);
-void draggingStarted(const int x, const int y, Qt::DropActions eActions,
- Qt::KeyboardModifiers eKeyMod, const QMimeData* 
pQMimeData);
-void dropping(const int x, const int y, Qt::KeyboardModifiers eKeyMod,
-  const QMimeData* pQMimeData);
+
+void handleDragLeave();
+void handleDragMove(QDragMoveEvent* pEvent);
+void handleDrop(QDropEvent* pEvent);
 
 virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle) override;
 virtual void Show(bool bVisible, bool bNoActivate = false) override;
diff --git a/vcl/inc/qt5/Qt5Tools.hxx b/vcl/inc/qt5/Qt5Tools.hxx
index 6b1fb1adcc7e..697b703e28f4 100644
--- a/vcl/inc/qt5/Qt5Tools.hxx
+++ b/vcl/inc/qt5/Qt5Tools.hxx
@@ -70,6 +70,7 @@ inline QColor toQColor(const Color& rColor)
 

[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - vcl/inc vcl/qt5 vcl/unx

2019-07-14 Thread Stephan Bergmann (via logerrit)
 vcl/inc/qt5/Qt5FilePicker.hxx|5 -
 vcl/inc/qt5/Qt5Instance.hxx  |4 +++-
 vcl/qt5/Qt5FilePicker.cxx|   27 +--
 vcl/qt5/Qt5Instance.cxx  |   16 +---
 vcl/unx/kde5/KDE5FilePicker.hxx  |3 ++-
 vcl/unx/kde5/KDE5FilePicker2.cxx |5 +++--
 vcl/unx/kde5/KDE5SalInstance.cxx |   10 ++
 vcl/unx/kde5/KDE5SalInstance.hxx |3 ++-
 8 files changed, 54 insertions(+), 19 deletions(-)

New commits:
commit 4cbcbb0a45b243971eb2e1da88b28bc03829a18e
Author: Stephan Bergmann 
AuthorDate: Wed Jun 19 15:03:04 2019 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Sun Jul 14 20:43:48 2019 +0200

tdf#125971: map file URLs from QFileDialog to LO internal format

jmux' suggestion at
 turns out 
to be
the correct fix after all; explained in a lengthy comment why that seemingly
wrong call of translateToInternal happens to do the right thing.

(Much of this patch is about passing the XComponentContext down to where it 
is
now needed in Qt5FilePicker::getSelectedFiles.)

Change-Id: I235554f8494cd3094a011d5a903059326db499fc
Reviewed-on: https://gerrit.libreoffice.org/74359
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 
(cherry picked from commit e2589f4584efcf0306ab69f7223abdd7469e3604)
Reviewed-on: https://gerrit.libreoffice.org/75587
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5FilePicker.hxx b/vcl/inc/qt5/Qt5FilePicker.hxx
index 74d082a83aa0..d4e74b92ba15 100644
--- a/vcl/inc/qt5/Qt5FilePicker.hxx
+++ b/vcl/inc/qt5/Qt5FilePicker.hxx
@@ -58,6 +58,8 @@ class VCLPLUG_QT5_PUBLIC Qt5FilePicker : public QObject, 
public Qt5FilePicker_Ba
 Q_OBJECT
 
 private:
+css::uno::Reference m_context;
+
 // whether to show (i.e. not remove) the file extension in the filter 
title,
 // e.g. whether to use "ODF Text Document (*.odt)" or just
 // "ODF Text Document" as filter title
@@ -88,7 +90,8 @@ protected:
 public:
 // use non-native file dialog by default; there's no easy way to add 
custom widgets
 // in a generic way in the native one
-explicit Qt5FilePicker(QFileDialog::FileMode, bool 
bShowFileExtensionInFilterTitle = false,
+explicit Qt5FilePicker(css::uno::Reference 
const& context,
+   QFileDialog::FileMode, bool 
bShowFileExtensionInFilterTitle = false,
bool bUseNativeDialog = false);
 virtual ~Qt5FilePicker() override;
 
diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 2411cdb7f52c..881ac17803d4 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -78,7 +78,9 @@ Q_SIGNALS:
 void deleteObjectLaterSignal(QObject* pObject);
 
 protected:
-virtual Qt5FilePicker* createPicker(QFileDialog::FileMode);
+virtual Qt5FilePicker*
+createPicker(css::uno::Reference const& 
context,
+ QFileDialog::FileMode);
 
 public:
 explicit Qt5Instance(std::unique_ptr& pQApp, bool bUseCairo 
= false);
diff --git a/vcl/qt5/Qt5FilePicker.cxx b/vcl/qt5/Qt5FilePicker.cxx
index 084aa7622a0a..63b3ff79a2bc 100644
--- a/vcl/qt5/Qt5FilePicker.cxx
+++ b/vcl/qt5/Qt5FilePicker.cxx
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -77,9 +78,11 @@ uno::Sequence FilePicker_getSupportedServiceNames()
 }
 }
 
-Qt5FilePicker::Qt5FilePicker(QFileDialog::FileMode eMode, bool 
bShowFileExtensionInFilterTitle,
+Qt5FilePicker::Qt5FilePicker(css::uno::Reference 
const& context,
+ QFileDialog::FileMode eMode, bool 
bShowFileExtensionInFilterTitle,
  bool bUseNativeDialog)
 : Qt5FilePicker_Base(m_aHelperMutex)
+, m_context(context)
 , m_bShowFileExtensionInFilterTitle(bShowFileExtensionInFilterTitle)
 , m_pFileDialog(new QFileDialog(nullptr, {}, QDir::homePath()))
 , m_bIsFolderPicker(eMode == QFileDialog::Directory)
@@ -254,9 +257,29 @@ uno::Sequence SAL_CALL 
Qt5FilePicker::getSelectedFiles()
 
 uno::Sequence seq(urls.size());
 
+auto const trans = 
css::uri::ExternalUriReferenceTranslator::create(m_context);
 size_t i = 0;
 for (const QUrl& aURL : urls)
-seq[i++] = toOUString(aURL.toString());
+{
+// Unlike LO, QFileDialog () 
apparently always
+// treats file-system pathnames as UTF-8--encoded, regardless of 
LANG/LC_CTYPE locale
+// setting.  And pathnames containing byte sequences that are not 
valid UTF-8 are apparently
+// filtered out and not even displayed by QFileDialog, so aURL will 
always have a "payload"
+// that matches the pathname's byte sequence.  So the pathname's byte 
sequence (which
+// happens to also be aURL's payload) in the LANG/LC_CTYPE encoding 
needs to be converted
+// into LO's internal UTF-8 file 

[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - vcl/inc vcl/qt5 vcl/unx

2019-06-08 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Instance.hxx  |5 +
 vcl/qt5/Qt5Instance.cxx  |   18 --
 vcl/unx/kde5/KDE5SalInstance.cxx |   25 +++--
 vcl/unx/kde5/KDE5SalInstance.hxx |   20 ++--
 4 files changed, 34 insertions(+), 34 deletions(-)

New commits:
commit 33ca4dbcc91164a3725263d8a8f61d9f2866da8f
Author: Jan-Marek Glogowski 
AuthorDate: Sun Jun 2 20:17:49 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Sat Jun 8 21:15:43 2019 +0200

Qt5/KDE5 always use either Qt5 or KDE5 pickers

And use RunInMain for both SalInstances and for both picker types,
as there is no reason to assume just the file and not the folder
picker can be called from the non-GUI thread.

Little drawback is the inclusion of Qt5FilePicker header in the
Qt5Instance header, as Qt's enums aren't forward-declarable.

Change-Id: Ie170d247a76134df9aff835393c71c9d6e907d32
Reviewed-on: https://gerrit.libreoffice.org/73416
Reviewed-by: Michael Weghorn 
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 
(cherry picked from commit ca69a1e17782d88580f2449e0252be52c26cae42)
Reviewed-on: https://gerrit.libreoffice.org/73721

diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 52b45b12d2b8..c87f3c93c1ac 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -33,6 +33,8 @@
 #include 
 #include 
 
+#include "Qt5FilePicker.hxx"
+
 class QApplication;
 class SalYieldMutex;
 class SalFrame;
@@ -74,6 +76,9 @@ Q_SIGNALS:
 void ImplRunInMainSignal();
 void deleteObjectLaterSignal(QObject* pObject);
 
+protected:
+virtual Qt5FilePicker* createPicker(QFileDialog::FileMode);
+
 public:
 explicit Qt5Instance(std::unique_ptr& pQApp, bool bUseCairo 
= false);
 virtual ~Qt5Instance() override;
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 1949d426de69..a7b7aeb8638a 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -394,18 +394,32 @@ void Qt5Instance::ProcessEvent(SalUserEvent aEvent)
 aEvent.m_pFrame->CallCallback(aEvent.m_nEvent, aEvent.m_pData);
 }
 
+Qt5FilePicker* Qt5Instance::createPicker(QFileDialog::FileMode eMode)
+{
+if (!IsMainThread())
+{
+SolarMutexGuard g;
+Qt5FilePicker* pPicker;
+RunInMainThread(std::function([&, this]() { pPicker = 
createPicker(eMode); }));
+assert(pPicker);
+return pPicker;
+}
+
+return new Qt5FilePicker(eMode);
+}
+
 css::uno::Reference
 Qt5Instance::createFilePicker(const 
css::uno::Reference&)
 {
 return css::uno::Reference(
-new Qt5FilePicker(QFileDialog::ExistingFile));
+createPicker(QFileDialog::ExistingFile));
 }
 
 css::uno::Reference
 Qt5Instance::createFolderPicker(const 
css::uno::Reference&)
 {
 return css::uno::Reference(
-new Qt5FilePicker(QFileDialog::Directory));
+createPicker(QFileDialog::Directory));
 }
 
 css::uno::Reference
diff --git a/vcl/unx/kde5/KDE5SalInstance.cxx b/vcl/unx/kde5/KDE5SalInstance.cxx
index 63ce689518f5..e2bd75277d23 100644
--- a/vcl/unx/kde5/KDE5SalInstance.cxx
+++ b/vcl/unx/kde5/KDE5SalInstance.cxx
@@ -50,34 +50,23 @@ SalFrame* KDE5SalInstance::CreateFrame(SalFrame* pParent, 
SalFrameStyleFlags nSt
 return pRet;
 }
 
-uno::Reference
-KDE5SalInstance::createFilePicker(const 
uno::Reference& xMSF)
+Qt5FilePicker* KDE5SalInstance::createPicker(QFileDialog::FileMode eMode)
 {
 if (!IsMainThread())
 {
 SolarMutexGuard g;
-uno::Reference xRet;
-RunInMainThread(
-std::function([, this, xMSF]() { xRet = 
this->createFilePicker(xMSF); }));
-assert(xRet);
-return xRet;
+Qt5FilePicker* pPicker;
+RunInMainThread(std::function([&, this]() { pPicker = 
createPicker(eMode); }));
+assert(pPicker);
+return pPicker;
 }
 
 // In order to insert custom controls, KDE5FilePicker currently relies on 
KFileWidget
 // being used in the native file picker, which is only the case for KDE 
Plasma.
 // Therefore, return the plain qt5 one in order to not lose custom 
controls.
 if (Application::GetDesktopEnvironment() == "KDE5")
-{
-return uno::Reference(
-new KDE5FilePicker(QFileDialog::ExistingFile));
-}
-return Qt5Instance::createFilePicker(xMSF);
-}
-
-uno::Reference
-KDE5SalInstance::createFolderPicker(const 
uno::Reference& /*xMSF*/)
-{
-return uno::Reference(new 
KDE5FilePicker(QFileDialog::Directory));
+return new KDE5FilePicker(eMode);
+return Qt5Instance::createPicker(eMode);
 }
 
 extern "C" {
diff --git a/vcl/unx/kde5/KDE5SalInstance.hxx b/vcl/unx/kde5/KDE5SalInstance.hxx
index 11276be3f4ec..53993a5ecc34 100644
--- a/vcl/unx/kde5/KDE5SalInstance.hxx
+++ b/vcl/unx/kde5/KDE5SalInstance.hxx
@@ -21,23 +21,15 @@
 
 #include 
 
-class QApplication;
-
-class KDE5SalInstance : public Qt5Instance
+class KDE5SalInstance final