Add chat history keyboard scrolling and remove unused PTT setting
This commit is contained in:
1 parent
5870efdf04
commit
4f6808156f
10 files changed
+81
-31
No files matched your search
@@ -208,7 +208,32 @@ void ChatView::mouseReleaseEvent(QMouseEvent *event) {
|
||||
QListView::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
bool ChatView::scrollWithKey(QKeyEvent *event) {
|
||||
if (event->modifiers() != Qt::NoModifier) return false;
|
||||
QAbstractSlider::SliderAction action;
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Up: action = QAbstractSlider::SliderSingleStepSub; break;
|
||||
case Qt::Key_Down: action = QAbstractSlider::SliderSingleStepAdd; break;
|
||||
case Qt::Key_PageUp: action = QAbstractSlider::SliderPageStepSub; break;
|
||||
case Qt::Key_PageDown: action = QAbstractSlider::SliderPageStepAdd; break;
|
||||
default: return false;
|
||||
}
|
||||
auto* bar = verticalScrollBar();
|
||||
const int before = bar->value();
|
||||
bar->triggerAction(action);
|
||||
GUI_DEBUG("history keyboard scroll: key=%d action=%d position=%d->%d range=%d..%d",
|
||||
event->key(), int(action), before, bar->value(), bar->minimum(), bar->maximum());
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatView::eventFilter(QObject *object, QEvent *event) {
|
||||
if (event->type() == QEvent::KeyPress && isVisible() && isEnabled() && scrollWithKey(static_cast<QKeyEvent*>(event))) return true;
|
||||
return QListView::eventFilter(object, event);
|
||||
}
|
||||
|
||||
void ChatView::keyPressEvent(QKeyEvent *event) {
|
||||
if (scrollWithKey(event)) return;
|
||||
if (event == QKeySequence::Copy) {
|
||||
copySelection();
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user