| 226 | } |
| 227 | |
| 228 | DiffWidget::DiffWidget(DiffParams p, QWidget *parent) |
| 229 | : QWidget(parent) |
| 230 | , m_left(new DiffEditor(p.flags, this)) |
| 231 | , m_right(new DiffEditor(p.flags, this)) |
| 232 | , m_commitInfo(new CommitInfoView(this)) |
| 233 | , m_toolbar(new Toolbar(this)) |
| 234 | , m_params(p) |
| 235 | { |
| 236 | auto layout = new QVBoxLayout(this); |
| 237 | layout->setSpacing(2); |
| 238 | layout->setContentsMargins({}); |
| 239 | layout->addWidget(m_toolbar); |
| 240 | layout->addWidget(m_commitInfo); |
| 241 | auto diffLayout = new QHBoxLayout; |
| 242 | diffLayout->setContentsMargins({}); |
| 243 | diffLayout->addWidget(m_left); |
| 244 | diffLayout->addWidget(m_right); |
| 245 | layout->addLayout(diffLayout); |
| 246 | |
| 247 | leftHl = new DiffSyntaxHighlighter(m_left->document(), this); |
| 248 | rightHl = new DiffSyntaxHighlighter(m_right->document(), this); |
| 249 | leftHl->setTheme(KTextEditor::Editor::instance()->theme()); |
| 250 | rightHl->setTheme(KTextEditor::Editor::instance()->theme()); |
| 251 | |
| 252 | connect(KTextEditor::Editor::instance(), &KTextEditor::Editor::configChanged, this, [this] { |
| 253 | auto currentThemeName = leftHl->theme().name(); |
| 254 | auto newTheme = KTextEditor::Editor::instance()->theme(); |
| 255 | if (currentThemeName != newTheme.name()) { |
| 256 | leftHl->setTheme(newTheme); |
| 257 | rightHl->setTheme(newTheme); |
| 258 | leftHl->rehighlight(); |
| 259 | rightHl->rehighlight(); |
| 260 | } |
| 261 | }); |
| 262 | |
| 263 | connect(m_left->verticalScrollBar(), &QScrollBar::valueChanged, this, [this](int) { |
| 264 | if (m_stopScrollSync) { |
| 265 | return; |
| 266 | } |
| 267 | m_stopScrollSync = true; |
| 268 | syncScroll(m_left, m_right); |
| 269 | m_stopScrollSync = false; |
| 270 | }); |
| 271 | connect(m_right->verticalScrollBar(), &QScrollBar::valueChanged, this, [this](int) { |
| 272 | if (m_stopScrollSync) { |
| 273 | return; |
| 274 | } |
| 275 | m_stopScrollSync = true; |
| 276 | syncScroll(m_right, m_left); |
| 277 | m_stopScrollSync = false; |
| 278 | }); |
| 279 | |
| 280 | for (DiffEditor *e : {m_left, m_right}) { |
| 281 | connect(e, &DiffEditor::switchStyle, this, &DiffWidget::handleStyleChange); |
| 282 | connect(e, &DiffEditor::actionTriggered, this, &DiffWidget::handleStageUnstage); |
| 283 | } |
| 284 | |
| 285 | // Connect both left and right editors to open line requests |
nothing calls this directly
no test coverage detected