-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrollsynchronizer.h
More file actions
34 lines (25 loc) · 838 Bytes
/
scrollsynchronizer.h
File metadata and controls
34 lines (25 loc) · 838 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
/////////////////////////////////////////////////////////////////////////////
// Name: scrollsynchronizer.h
// Purpose: Synchronize scrolling of MD editor with MD viewer (header)
// Author: Jan Buchholz
// Created: 2025-11-20
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QObject>
#include <QSplitter>
#include <QTextEdit>
class ScrollSynchronizer : public QObject {
Q_OBJECT
public:
explicit ScrollSynchronizer(QTextEdit* a, QTextEdit* b, QSplitter* parentSplitter);
void setEnabled(bool enabled);
private:
QTextEdit* m_editA;
QTextEdit* m_editB;
QSplitter* m_splitter;
bool m_syncing;
bool m_enabled;
void sync(QTextEdit* source, QTextEdit* target);
private slots:
void syncBtoA() { sync(m_editB, m_editA); }
};