-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGTextEdit.h
More file actions
34 lines (27 loc) · 840 Bytes
/
Copy pathGTextEdit.h
File metadata and controls
34 lines (27 loc) · 840 Bytes
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
#ifndef G_EDITOR_H
#define G_EDITOR_H
#include <QTextEdit>
#include <QEvent>
#include <QWheelEvent>
class GTextEdit : public QTextEdit
{
Q_OBJECT
public:
explicit GTextEdit(QWidget* parent = nullptr) : QTextEdit(parent) {}
~GTextEdit() override = default;
private:
// Handle gesture zooming event
void wheelEvent(QWheelEvent* event) override
{
if (event->modifiers() & Qt::ControlModifier) {
const int dy = event->angleDelta().y() != 0 ? event->angleDelta().y()
: event->pixelDelta().y();
if (dy > 0) zoomIn();
else if (dy < 0) zoomOut();
event->accept();
return;
}
QTextEdit::wheelEvent(event); // base class handles normal scrolling
}
};
#endif // G_EDITOR_H