blob: b18bf85cfc646c19a7290e86cd207726affe60ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright (C) 2016 Jochen Becher
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <QGraphicsTextItem>
namespace qmt {
class EditableTextItem : public QGraphicsTextItem
{
Q_OBJECT
public:
explicit EditableTextItem(QGraphicsItem *parent);
~EditableTextItem() override;
signals:
void returnKeyPressed();
public:
void setEditable(bool editable);
void setShowFocus(bool showFocus);
void setFilterReturnKey(bool filterReturnKey);
void setFilterTabKey(bool filterTabKey);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
void selectAll();
protected:
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
private:
bool isReturnKey(QKeyEvent *event) const;
private:
bool m_showFocus = false;
bool m_filterReturnKey = false;
bool m_filterTabKey = false;
};
} // namespace qmt
|