Skip to content

Commit

Permalink
Showing 3 changed files with 34 additions and 3 deletions.
12 changes: 12 additions & 0 deletions client/chatroomwidget.cpp
Original file line number Diff line number Diff line change
@@ -706,6 +706,18 @@ void ChatRoomWidget::resizeEvent(QResizeEvent*)
m_chatEdit->setMaximumHeight(height() / 3);
}

void ChatRoomWidget::keyPressEvent(QKeyEvent* event)
{
switch(event->key()) {
case Qt::Key_PageUp:
emit pageUpPressed();
break;
case Qt::Key_PageDown:
emit pageDownPressed();
break;
}
}

void ChatRoomWidget::markShownAsRead()
{
// FIXME: a case when a single message doesn't fit on the screen.
9 changes: 6 additions & 3 deletions client/chatroomwidget.h
Original file line number Diff line number Diff line change
@@ -60,6 +60,8 @@ class ChatRoomWidget: public QWidget
void showStatusMessage(const QString& message, int timeout = 0) const;
void readMarkerMoved();
void readMarkerCandidateMoved();
void pageUpPressed();
void pageDownPressed();

public slots:
void setRoom(QuaternionRoom* room);
@@ -73,9 +75,6 @@ class ChatRoomWidget: public QWidget
void markShownAsRead();
void saveFileAs(QString eventId);

protected:
void timerEvent(QTimerEvent* event) override;
void resizeEvent(QResizeEvent*) override;

private slots:
void sendInput();
@@ -112,4 +111,8 @@ class ChatRoomWidget: public QWidget

void reStartShownTimer();
QString doSendInput();

void timerEvent(QTimerEvent* event) override;
void resizeEvent(QResizeEvent*) override;
void keyPressEvent(QKeyEvent*) override;
};
16 changes: 16 additions & 0 deletions client/qml/Timeline.qml
Original file line number Diff line number Diff line change
@@ -117,6 +117,13 @@ Rectangle {
console.log("QML view loaded")
model.modelAboutToBeReset.connect(onModelAboutToReset)
model.modelReset.connect(onModelReset)
controller.pageUpPressed.connect(function() {
contentY = Math.max(originY, contentY - height)
})
controller.pageDownPressed.connect(function() {
contentY = Math.min(originY + contentHeight - height,
contentY + height)
})
}

onMovementEnded: saveViewport()
@@ -135,6 +142,15 @@ Rectangle {

onRunningChanged: { if (!running) chatView.saveViewport() }
}}
Keys.onUpPressed: {
contentY = Math.max(originY, contentY - height / 5)
event.accepted = true
}
Keys.onDownPressed: {
contentY = Math.min(originY + contentHeight - height,
contentY + height / 5)
event.accepted = true
}

// itemAt is a function, not a property so is not bound to new items
// showing up underneath; contentHeight is used for that instead.

0 comments on commit 3f9aeaf

Please sign in to comment.