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

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 23 21:16:28 UTC 2019


 vcl/inc/qt5/Qt5Tools.hxx        |    3 +++
 vcl/inc/qt5/Qt5Widget.hxx       |    2 +-
 vcl/qt5/Qt5AccessibleWidget.cxx |    2 +-
 vcl/qt5/Qt5DragAndDrop.cxx      |   28 ++++++++++------------------
 vcl/qt5/Qt5Frame.cxx            |   11 ++++-------
 vcl/qt5/Qt5Tools.cxx            |    2 --
 vcl/qt5/Qt5Widget.cxx           |    6 +++---
 7 files changed, 22 insertions(+), 32 deletions(-)

New commits:
commit 51c663b49deea46145eef185bf4e551f2c213428
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Thu Aug 15 10:35:33 2019 +0000
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Fri Aug 23 23:15:25 2019 +0200

    Qt5 some minor code cleanups
    
    Change-Id: I1ee81de7ef03447991e12dcf01aef7858408dc40
    Reviewed-on: https://gerrit.libreoffice.org/77975
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/inc/qt5/Qt5Tools.hxx b/vcl/inc/qt5/Qt5Tools.hxx
index 697b703e28f4..54257de86241 100644
--- a/vcl/inc/qt5/Qt5Tools.hxx
+++ b/vcl/inc/qt5/Qt5Tools.hxx
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include <QtCore/QPoint>
 #include <QtCore/QRect>
 #include <QtCore/QSize>
 #include <QtCore/QString>
@@ -62,6 +63,8 @@ inline QSize toQSize(const Size& rSize) { return QSize(rSize.Width(), rSize.Heig
 
 inline Size toSize(const QSize& rSize) { return Size(rSize.width(), rSize.height()); }
 
+inline Point toPoint(const QPoint& rPoint) { return Point(rPoint.x(), rPoint.y()); }
+
 inline QColor toQColor(const Color& rColor)
 {
     return QColor(rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue(),
diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index a69c86876a44..457fc8b78612 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -74,7 +74,7 @@ class Qt5Widget : public QWidget
 public:
     Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
 
-    Qt5Frame& getFrame() const { return m_rFrame; }
+    Qt5Frame& frame() const { return m_rFrame; }
     void endExtTextInput();
 
     static bool handleEvent(Qt5Frame&, const QWidget&, QEvent*);
diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx
index 6ee5eedb6414..6a828865036e 100644
--- a/vcl/qt5/Qt5AccessibleWidget.cxx
+++ b/vcl/qt5/Qt5AccessibleWidget.cxx
@@ -718,7 +718,7 @@ QAccessibleInterface* Qt5AccessibleWidget::customFactory(const QString& classnam
     if (classname == QLatin1String("Qt5Widget") && object && object->isWidgetType())
     {
         Qt5Widget* pWidget = static_cast<Qt5Widget*>(object);
-        vcl::Window* pWindow = pWidget->getFrame().GetWindow();
+        vcl::Window* pWindow = pWidget->frame().GetWindow();
 
         if (pWindow)
             return new Qt5AccessibleWidget(pWindow->GetAccessible());
diff --git a/vcl/qt5/Qt5DragAndDrop.cxx b/vcl/qt5/Qt5DragAndDrop.cxx
index 3f57f3bc303e..615b5d1f7e2a 100644
--- a/vcl/qt5/Qt5DragAndDrop.cxx
+++ b/vcl/qt5/Qt5DragAndDrop.cxx
@@ -78,16 +78,16 @@ void Qt5DragSource::startDrag(
 
 void Qt5DragSource::fire_dragEnd(sal_Int8 nAction, bool bDropSuccessful)
 {
-    if (m_xListener.is())
-    {
-        datatransfer::dnd::DragSourceDropEvent aEv;
-        aEv.DropAction = nAction;
-        aEv.DropSuccess = bDropSuccessful;
+    if (!m_xListener.is())
+        return;
 
-        auto xListener = m_xListener;
-        m_xListener.clear();
-        xListener->dragDropEnd(aEv);
-    }
+    datatransfer::dnd::DragSourceDropEvent aEv;
+    aEv.DropAction = nAction;
+    aEv.DropSuccess = bDropSuccessful;
+
+    auto xListener = m_xListener;
+    m_xListener.clear();
+    xListener->dragDropEnd(aEv);
 }
 
 OUString SAL_CALL Qt5DragSource::getImplementationName()
@@ -128,11 +128,7 @@ css::uno::Sequence<OUString> SAL_CALL Qt5DropTarget::getSupportedServiceNames()
     return { "com.sun.star.datatransfer.dnd.Qt5DropTarget" };
 }
 
-Qt5DropTarget::~Qt5DropTarget()
-{
-    //if (m_pFrame)
-    //m_pFrame->deregisterDropTarget(this);
-}
+Qt5DropTarget::~Qt5DropTarget() {}
 
 void Qt5DropTarget::deinitialize()
 {
@@ -213,9 +209,7 @@ void Qt5DropTarget::fire_dragOver(const css::datatransfer::dnd::DropTargetDragEn
     aGuard.clear();
 
     for (auto const& listener : aListeners)
-    {
         listener->dragOver(dtde);
-    }
 }
 
 void Qt5DropTarget::fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde)
@@ -228,9 +222,7 @@ void Qt5DropTarget::fire_drop(const css::datatransfer::dnd::DropTargetDropEvent&
     aGuard.clear();
 
     for (auto const& listener : aListeners)
-    {
         listener->drop(dtde);
-    }
 }
 
 void Qt5DropTarget::fire_dragExit(const css::datatransfer::dnd::DropTargetEvent& dte)
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index cd850e6c3c0f..a18af04b5cbd 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -1053,8 +1053,7 @@ void Qt5Frame::Beep() { QApplication::beep(); }
 SalFrame::SalPointerState Qt5Frame::GetPointerState()
 {
     SalPointerState aState;
-    QPoint pos = QCursor::pos();
-    aState.maPos = Point(pos.x(), pos.y());
+    aState.maPos = toPoint(QCursor::pos());
     aState.mnState = GetMouseModCode(QGuiApplication::mouseButtons())
                      | GetKeyModCode(QGuiApplication::keyboardModifiers());
     return aState;
@@ -1206,8 +1205,6 @@ static sal_Int8 lcl_getUserDropAction(const QDropEvent* pEvent, const sal_Int8 n
 {
     // we completely ignore all proposals by the Qt event, as they don't
     // match at all with the preferred LO DnD actions.
-    const sal_Int8 nFilterActions
-        = nSourceActions | css::datatransfer::dnd::DNDConstants::ACTION_DEFAULT;
 
     // check the key modifiers to detect a user-overridden DnD action
     const Qt::KeyboardModifiers eKeyMod = pEvent->keyboardModifiers();
@@ -1218,7 +1215,7 @@ static sal_Int8 lcl_getUserDropAction(const QDropEvent* pEvent, const sal_Int8 n
         nUserDropAction = css::datatransfer::dnd::DNDConstants::ACTION_COPY;
     else if ((eKeyMod & Qt::ShiftModifier) && (eKeyMod & Qt::ControlModifier))
         nUserDropAction = css::datatransfer::dnd::DNDConstants::ACTION_LINK;
-    nUserDropAction &= nFilterActions;
+    nUserDropAction &= nSourceActions;
 
     // select the default DnD action, if there isn't a user preference
     if (0 == nUserDropAction)
@@ -1227,7 +1224,7 @@ static sal_Int8 lcl_getUserDropAction(const QDropEvent* pEvent, const sal_Int8 n
         nUserDropAction = dynamic_cast<const Qt5MimeData*>(pMimeData)
                               ? css::datatransfer::dnd::DNDConstants::ACTION_MOVE
                               : css::datatransfer::dnd::DNDConstants::ACTION_COPY;
-        nUserDropAction &= nFilterActions;
+        nUserDropAction &= nSourceActions;
 
         // if the default doesn't match any allowed source action, fall back to the
         // preferred of all allowed source actions
@@ -1309,7 +1306,7 @@ void Qt5Frame::handleDrop(QDropEvent* pEvent)
         Qt5Widget* pWidget = dynamic_cast<Qt5Widget*>(pEvent->source());
         assert(pWidget); // AFAIK there shouldn't be any non-Qt5Widget as source in LO itself
         if (pWidget)
-            pWidget->getFrame().m_pDragSource->fire_dragEnd(nDropAction, bDropSuccessful);
+            pWidget->frame().m_pDragSource->fire_dragEnd(nDropAction, bDropSuccessful);
     }
 
     // the drop target accepted our drop action => inform Qt
diff --git a/vcl/qt5/Qt5Tools.cxx b/vcl/qt5/Qt5Tools.cxx
index 24e60b9e1375..667a5af6b8ef 100644
--- a/vcl/qt5/Qt5Tools.cxx
+++ b/vcl/qt5/Qt5Tools.cxx
@@ -95,14 +95,12 @@ sal_Int8 toVclDropAction(Qt::DropAction dragOperation)
 Qt::DropAction getPreferredDropAction(sal_Int8 dragOperation)
 {
     Qt::DropAction eAct = Qt::IgnoreAction;
-
     if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_MOVE)
         eAct = Qt::MoveAction;
     else if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_COPY)
         eAct = Qt::CopyAction;
     else if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_LINK)
         eAct = Qt::LinkAction;
-
     return eAct;
 }
 
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 4c1c474aa159..3450f433a808 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -230,13 +230,13 @@ void Qt5Widget::dragMoveEvent(QDragMoveEvent* pEvent) { m_rFrame.handleDragMove(
 
 void Qt5Widget::dropEvent(QDropEvent* pEvent) { m_rFrame.handleDrop(pEvent); }
 
-void Qt5Widget::moveEvent(QMoveEvent* event)
+void Qt5Widget::moveEvent(QMoveEvent* pEvent)
 {
     if (m_rFrame.m_pTopLevel)
         return;
 
-    m_rFrame.maGeometry.nX = event->pos().x();
-    m_rFrame.maGeometry.nY = event->pos().y();
+    m_rFrame.maGeometry.nX = pEvent->pos().x();
+    m_rFrame.maGeometry.nY = pEvent->pos().y();
     m_rFrame.CallCallback(SalEvent::Move, nullptr);
 }
 


More information about the Libreoffice-commits mailing list