LibreOffice Module vcl (master)  1
Qt5Widget.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #pragma once
21 
22 #include <QtWidgets/QWidget>
23 #include <rtl/ustring.hxx>
24 
25 #include <com/sun/star/uno/Reference.hxx>
26 #include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
27 
28 class QInputEvent;
29 class Qt5Frame;
30 class Qt5Object;
32 
33 class Qt5Widget : public QWidget
34 {
35  Q_OBJECT
36 
39  int m_nDeltaX;
40  int m_nDeltaY;
41 
42  enum class ButtonKeyState
43  {
44  Pressed,
45  Released
46  };
47 
48  static void commitText(Qt5Frame&, const QString& aText);
49  static bool handleKeyEvent(Qt5Frame&, const QWidget&, QKeyEvent*, const ButtonKeyState);
50  static void handleMouseButtonEvent(const Qt5Frame&, const QMouseEvent*, const ButtonKeyState);
51  static void fillSalAbstractMouseEvent(const Qt5Frame& rFrame, const QInputEvent* pQEvent,
52  const QPoint& rPos, Qt::MouseButtons eButtons, int nWidth,
53  SalAbstractMouseEvent& aSalEvent);
54 
55  virtual bool event(QEvent*) override;
56 
57  virtual void focusInEvent(QFocusEvent*) override;
58  virtual void focusOutEvent(QFocusEvent*) override;
59  // keyPressEvent(QKeyEvent*) is handled via event(QEvent*); see comment
60  virtual void keyReleaseEvent(QKeyEvent*) override;
61  virtual void mouseMoveEvent(QMouseEvent*) override;
62  virtual void mousePressEvent(QMouseEvent*) override;
63  virtual void mouseReleaseEvent(QMouseEvent*) override;
64  virtual void dragEnterEvent(QDragEnterEvent*) override;
65  virtual void dragLeaveEvent(QDragLeaveEvent*) override;
66  virtual void dragMoveEvent(QDragMoveEvent*) override;
67  virtual void dropEvent(QDropEvent*) override;
68  virtual void moveEvent(QMoveEvent*) override;
69  virtual void paintEvent(QPaintEvent*) override;
70  virtual void resizeEvent(QResizeEvent*) override;
71  virtual void showEvent(QShowEvent*) override;
72  virtual void wheelEvent(QWheelEvent*) override;
73  virtual void closeEvent(QCloseEvent*) override;
74  virtual void changeEvent(QEvent*) override;
75 
76  void inputMethodEvent(QInputMethodEvent*) override;
77  QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
78 
79 public:
80  Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
81 
82  Qt5Frame& frame() const { return m_rFrame; }
83  void endExtTextInput();
84 
85  static bool handleEvent(Qt5Frame&, const QWidget&, QEvent*);
86  // key events might be propagated further down => call base on false
87  static inline bool handleKeyReleaseEvent(Qt5Frame&, const QWidget&, QKeyEvent*);
88  // mouse events are always accepted
89  static inline void handleMousePressEvent(const Qt5Frame&, const QMouseEvent*);
90  static inline void handleMouseReleaseEvent(const Qt5Frame&, const QMouseEvent*);
91 };
92 
93 bool Qt5Widget::handleKeyReleaseEvent(Qt5Frame& rFrame, const QWidget& rWidget, QKeyEvent* pEvent)
94 {
95  return handleKeyEvent(rFrame, rWidget, pEvent, ButtonKeyState::Released);
96 }
97 
98 void Qt5Widget::handleMousePressEvent(const Qt5Frame& rFrame, const QMouseEvent* pEvent)
99 {
101 }
102 
103 void Qt5Widget::handleMouseReleaseEvent(const Qt5Frame& rFrame, const QMouseEvent* pEvent)
104 {
106 }
107 
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void paintEvent(QPaintEvent *) override
virtual void closeEvent(QCloseEvent *) override
virtual bool event(QEvent *) override
Qt5Frame & m_rFrame
Definition: Qt5Widget.hxx:37
void inputMethodEvent(QInputMethodEvent *) override
static bool handleKeyEvent(Qt5Frame &, const QWidget &, QKeyEvent *, const ButtonKeyState)
virtual void dropEvent(QDropEvent *) override
static void fillSalAbstractMouseEvent(const Qt5Frame &rFrame, const QInputEvent *pQEvent, const QPoint &rPos, Qt::MouseButtons eButtons, int nWidth, SalAbstractMouseEvent &aSalEvent)
virtual void dragLeaveEvent(QDragLeaveEvent *) override
static void handleMousePressEvent(const Qt5Frame &, const QMouseEvent *)
Definition: Qt5Widget.hxx:98
virtual void resizeEvent(QResizeEvent *) override
virtual void dragEnterEvent(QDragEnterEvent *) override
virtual void focusInEvent(QFocusEvent *) override
virtual void showEvent(QShowEvent *) override
virtual void mousePressEvent(QMouseEvent *) override
int m_nDeltaX
Definition: Qt5Widget.hxx:39
static void handleMouseButtonEvent(const Qt5Frame &, const QMouseEvent *, const ButtonKeyState)
virtual void focusOutEvent(QFocusEvent *) override
Qt5Frame & frame() const
Definition: Qt5Widget.hxx:82
Qt5Widget(Qt5Frame &rFrame, Qt::WindowFlags f=Qt::WindowFlags())
virtual void wheelEvent(QWheelEvent *) override
int m_nDeltaY
Definition: Qt5Widget.hxx:40
virtual void keyReleaseEvent(QKeyEvent *) override
QVariant inputMethodQuery(Qt::InputMethodQuery) const override
static bool handleKeyReleaseEvent(Qt5Frame &, const QWidget &, QKeyEvent *)
Definition: Qt5Widget.hxx:93
virtual void moveEvent(QMoveEvent *) override
static bool handleEvent(Qt5Frame &, const QWidget &, QEvent *)
static void commitText(Qt5Frame &, const QString &aText)
virtual void mouseMoveEvent(QMouseEvent *) override
bool m_bNonEmptyIMPreeditSeen
Definition: Qt5Widget.hxx:38
virtual void dragMoveEvent(QDragMoveEvent *) override
virtual void mouseReleaseEvent(QMouseEvent *) override
void(* f)(TrueTypeTable *)
Definition: ttcr.cxx:483
static void handleMouseReleaseEvent(const Qt5Frame &, const QMouseEvent *)
Definition: Qt5Widget.hxx:103
void endExtTextInput()
virtual void changeEvent(QEvent *) override