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 Qt5Frame;
29 class Qt5Object;
30 
31 class Qt5Widget : public QWidget
32 {
33  Q_OBJECT
34 
37  int m_nDeltaX;
38  int m_nDeltaY;
39 
40  enum class ButtonKeyState
41  {
42  Pressed,
43  Released
44  };
45 
46  static void commitText(Qt5Frame&, const QString& aText);
47  static bool handleKeyEvent(Qt5Frame&, const QWidget&, QKeyEvent*, const ButtonKeyState);
48  static void handleMouseButtonEvent(const Qt5Frame&, const QMouseEvent*, const ButtonKeyState);
49 
50  virtual bool event(QEvent*) override;
51 
52  virtual void focusInEvent(QFocusEvent*) override;
53  virtual void focusOutEvent(QFocusEvent*) override;
54  // keyPressEvent(QKeyEvent*) is handled via event(QEvent*); see comment
55  virtual void keyReleaseEvent(QKeyEvent*) override;
56  virtual void mouseMoveEvent(QMouseEvent*) override;
57  virtual void mousePressEvent(QMouseEvent*) override;
58  virtual void mouseReleaseEvent(QMouseEvent*) override;
59  virtual void dragEnterEvent(QDragEnterEvent*) override;
60  virtual void dragLeaveEvent(QDragLeaveEvent*) override;
61  virtual void dragMoveEvent(QDragMoveEvent*) override;
62  virtual void dropEvent(QDropEvent*) override;
63  virtual void moveEvent(QMoveEvent*) override;
64  virtual void paintEvent(QPaintEvent*) override;
65  virtual void resizeEvent(QResizeEvent*) override;
66  virtual void showEvent(QShowEvent*) override;
67  virtual void wheelEvent(QWheelEvent*) override;
68  virtual void closeEvent(QCloseEvent*) override;
69  virtual void changeEvent(QEvent*) override;
70 
71  void inputMethodEvent(QInputMethodEvent*) override;
72  QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
73 
74 public:
75  Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
76 
77  Qt5Frame& frame() const { return m_rFrame; }
78  void endExtTextInput();
79 
80  static bool handleEvent(Qt5Frame&, const QWidget&, QEvent*);
81  // key events might be propagated further down => call base on false
82  static inline bool handleKeyReleaseEvent(Qt5Frame&, const QWidget&, QKeyEvent*);
83  // mouse events are always accepted
84  static inline void handleMousePressEvent(const Qt5Frame&, const QMouseEvent*);
85  static inline void handleMouseReleaseEvent(const Qt5Frame&, const QMouseEvent*);
86 };
87 
88 bool Qt5Widget::handleKeyReleaseEvent(Qt5Frame& rFrame, const QWidget& rWidget, QKeyEvent* pEvent)
89 {
90  return handleKeyEvent(rFrame, rWidget, pEvent, ButtonKeyState::Released);
91 }
92 
93 void Qt5Widget::handleMousePressEvent(const Qt5Frame& rFrame, const QMouseEvent* pEvent)
94 {
96 }
97 
98 void Qt5Widget::handleMouseReleaseEvent(const Qt5Frame& rFrame, const QMouseEvent* pEvent)
99 {
101 }
102 
103 /* 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:35
void inputMethodEvent(QInputMethodEvent *) override
static bool handleKeyEvent(Qt5Frame &, const QWidget &, QKeyEvent *, const ButtonKeyState)
virtual void dropEvent(QDropEvent *) override
virtual void dragLeaveEvent(QDragLeaveEvent *) override
static void handleMousePressEvent(const Qt5Frame &, const QMouseEvent *)
Definition: Qt5Widget.hxx:93
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:37
static void handleMouseButtonEvent(const Qt5Frame &, const QMouseEvent *, const ButtonKeyState)
virtual void focusOutEvent(QFocusEvent *) override
Qt5Frame & frame() const
Definition: Qt5Widget.hxx:77
Qt5Widget(Qt5Frame &rFrame, Qt::WindowFlags f=Qt::WindowFlags())
virtual void wheelEvent(QWheelEvent *) override
int m_nDeltaY
Definition: Qt5Widget.hxx:38
virtual void keyReleaseEvent(QKeyEvent *) override
QVariant inputMethodQuery(Qt::InputMethodQuery) const override
static bool handleKeyReleaseEvent(Qt5Frame &, const QWidget &, QKeyEvent *)
Definition: Qt5Widget.hxx:88
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:36
virtual void dragMoveEvent(QDragMoveEvent *) override
virtual void mouseReleaseEvent(QMouseEvent *) override
void(* f)(TrueTypeTable *)
Definition: ttcr.cxx:466
static void handleMouseReleaseEvent(const Qt5Frame &, const QMouseEvent *)
Definition: Qt5Widget.hxx:98
void endExtTextInput()
virtual void changeEvent(QEvent *) override