mirror of
https://github.com/Murmele/Gittyup.git
synced 2024-09-17 13:37:18 +03:00
Add hotkeys D and U move DiffView down/up by half page
This commit is contained in:
parent
7e182735e2
commit
611052da32
@ -15,6 +15,7 @@
|
|||||||
#include "CommentWidget.h"
|
#include "CommentWidget.h"
|
||||||
#include "ui/DiffTreeModel.h"
|
#include "ui/DiffTreeModel.h"
|
||||||
#include "ui/DoubleTreeWidget.h"
|
#include "ui/DoubleTreeWidget.h"
|
||||||
|
#include "ui/HotkeyManager.h"
|
||||||
#include "git/Tree.h"
|
#include "git/Tree.h"
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
@ -47,6 +48,12 @@ bool copy(const QString &source, const QDir &targetDir) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
static Hotkey moveHalfPageDownHotKey = HotkeyManager::registerHotkey(
|
||||||
|
"d", "diffView/moveHalfPageDownHotKey", "DiffView/Move Half Page Down");
|
||||||
|
|
||||||
|
static Hotkey moveHalfPageUpHotKey = HotkeyManager::registerHotkey(
|
||||||
|
"u", "diffView/moveHalfPageUpHotKey", "DiffView/Move Half Page Up");
|
||||||
|
|
||||||
DiffView::DiffView(const git::Repository &repo, QWidget *parent)
|
DiffView::DiffView(const git::Repository &repo, QWidget *parent)
|
||||||
: QScrollArea(parent), mParent(parent) {
|
: QScrollArea(parent), mParent(parent) {
|
||||||
setStyleSheet(DiffViewStyle::kStyleSheet);
|
setStyleSheet(DiffViewStyle::kStyleSheet);
|
||||||
@ -84,6 +91,14 @@ DiffView::DiffView(const git::Repository &repo, QWidget *parent)
|
|||||||
fetchMore();
|
fetchMore();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QShortcut *shortcut = new QShortcut(this);
|
||||||
|
moveHalfPageDownHotKey.use(shortcut);
|
||||||
|
connect(shortcut, &QShortcut::activated, [this] { moveHalfPageDown(); });
|
||||||
|
|
||||||
|
shortcut = new QShortcut(this);
|
||||||
|
moveHalfPageUpHotKey.use(shortcut);
|
||||||
|
connect(shortcut, &QShortcut::activated, [this] { moveHalfPageUp(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
DiffView::~DiffView() {}
|
DiffView::~DiffView() {}
|
||||||
@ -513,3 +528,13 @@ void DiffView::indexChanged(const QStringList &paths) {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiffView::moveHalfPageDown() { moveRelative(height() / 2); }
|
||||||
|
|
||||||
|
void DiffView::moveHalfPageUp() { moveRelative(-height() / 2); }
|
||||||
|
|
||||||
|
void DiffView::moveRelative(int pixelsDown) {
|
||||||
|
int oldPosition = verticalScrollBar()->sliderPosition();
|
||||||
|
int newPosition = oldPosition + pixelsDown;
|
||||||
|
verticalScrollBar()->setSliderPosition(newPosition);
|
||||||
|
}
|
||||||
|
@ -103,6 +103,9 @@ public:
|
|||||||
void diffTreeModelDataChanged(const QModelIndex &topLeft,
|
void diffTreeModelDataChanged(const QModelIndex &topLeft,
|
||||||
const QModelIndex &bottomRight,
|
const QModelIndex &bottomRight,
|
||||||
const QVector<int> &roles);
|
const QVector<int> &roles);
|
||||||
|
void moveHalfPageDown();
|
||||||
|
void moveHalfPageUp();
|
||||||
|
void moveRelative(int pixelsDown);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void diagnosticAdded(TextEditor::DiagnosticKind kind);
|
void diagnosticAdded(TextEditor::DiagnosticKind kind);
|
||||||
|
Loading…
Reference in New Issue
Block a user