simplified key presses

This commit is contained in:
Jeena 2015-02-09 00:00:24 +01:00
parent 9279db22f5
commit 74d5236408
2 changed files with 42 additions and 38 deletions

View file

@ -78,25 +78,7 @@ ScrollView {
}
onPostChanged: setPost()
Keys.onRightPressed: app.sidebar.next()
Keys.onLeftPressed: app.sidebar.previous()
Keys.onDownPressed: content.scrollDown(content.scrollJump)
Keys.onUpPressed: content.scrollUp(content.scrollJump)
Keys.onSpacePressed: content.scrollDown(content.pageJump)
Keys.onEnterPressed: Qt.openUrlExternally(content.post.link)
Keys.onReturnPressed: Qt.openUrlExternally(content.post.link)
Keys.onPressed: {
if(event.key === Qt.Key_Home) {
content.scrollUp();
} else if (event.key === Qt.Key_End) {
content.scrollDown();
} else if (event.key === Qt.Key_PageUp) {
content.scrollUp(content.pageJump)
} else if (event.key === Qt.Key_PageDown) {
content.scrollDown(content.pageJump)
}
}
Keys.onPressed: app.keyPressed(event)
}
}

View file

@ -29,6 +29,46 @@ ApplicationWindow {
server.initialize(serverLogin.serverUrl, serverLogin.sessionId);
}
function keyPressed(event) {
switch (event.key) {
case Qt.Key_Right:
case Qt.Key_J:
case Qt.Key_j:
sidebar.next()
break
case Qt.Key_Left:
case Qt.Key_K:
case Qt.Key_k:
sidebar.previous()
break
case Qt.Key_Home:
content.scrollUp()
break
case Qt.Key_End:
content.scrollDown()
break
case Qt.Key_PageUp:
content.scrollUp(content.pageJump)
break
case Qt.Key_PageDown:
case Qt.Key_Space:
content.scrollDown(content.pageJump)
break
case Qt.Key_Down:
content.scrollDown(content.scrollJump)
break
case Qt.Key_Up:
content.scrollUp(content.scrollJump)
break
case Qt.Key_Enter:
case Qt.Key_Return:
Qt.openUrlExternally(content.post.link)
break
default:
break
}
}
SplitView {
anchors.fill: parent
orientation: Qt.Horizontal
@ -52,25 +92,7 @@ ApplicationWindow {
implicitWidth: 624
}
Keys.onRightPressed: sidebar.next()
Keys.onLeftPressed: sidebar.previous()
Keys.onDownPressed: content.scrollDown(content.scrollJump)
Keys.onUpPressed: content.scrollUp(content.scrollJump)
Keys.onSpacePressed: content.scrollDown(content.pageJump)
Keys.onEnterPressed: Qt.openUrlExternally(content.post.link)
Keys.onReturnPressed: Qt.openUrlExternally(content.post.link)
Keys.onPressed: {
if(event.key === Qt.Key_Home) {
content.scrollUp();
} else if (event.key === Qt.Key_End) {
content.scrollDown();
} else if (event.key === Qt.Key_PageUp) {
content.scrollUp(content.pageJump)
} else if (event.key === Qt.Key_PageDown) {
content.scrollDown(content.pageJump)
}
}
Keys.onPressed: keyPressed(event)
}
Login {