added keyboard behaviour like scrolling, etc.
This commit is contained in:
parent
56ef57b112
commit
c474db9a0c
5 changed files with 61 additions and 8 deletions
37
Content.qml
37
Content.qml
|
@ -7,23 +7,54 @@ ScrollView {
|
||||||
property Post post
|
property Post post
|
||||||
property int headLinefontSize: 23
|
property int headLinefontSize: 23
|
||||||
property int textfontSize: 14
|
property int textfontSize: 14
|
||||||
|
property int scrollJump: 48
|
||||||
|
property int pageJump: parent.height
|
||||||
|
|
||||||
style: ScrollViewStyle {
|
style: ScrollViewStyle {
|
||||||
transientScrollBars: true
|
transientScrollBars: true
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollDown() {
|
function scrollDown(jump) {
|
||||||
flickableItem.contentY += 30
|
smoothScrolling.enabled = true
|
||||||
|
|
||||||
|
var top = Math.max(contentItem.height - parent.height, 0);
|
||||||
|
|
||||||
|
if(jump && flickableItem.contentY < top - jump) {
|
||||||
|
flickableItem.contentY += jump
|
||||||
|
} else {
|
||||||
|
flickableItem.contentY = top
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollUp() {
|
function scrollUp(jump) {
|
||||||
|
smoothScrolling.enabled = true
|
||||||
|
if(jump && flickableItem.contentY >= jump) {
|
||||||
|
flickableItem.contentY -= jump;
|
||||||
|
} else {
|
||||||
|
flickableItem.contentY = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on flickableItem.contentY {
|
||||||
|
id: smoothScrolling
|
||||||
|
enabled: false
|
||||||
|
NumberAnimation {
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
height: column.height + 50
|
height: column.height + 50
|
||||||
width: parent.parent.width
|
width: parent.parent.width
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
onWheel: {
|
||||||
|
wheel.accepted = false
|
||||||
|
smoothScrolling.enabled = false
|
||||||
|
}
|
||||||
|
anchors.fill: parent
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
|
@ -7,7 +7,10 @@ SOURCES += main.cpp \
|
||||||
tinytinyrsslogin.cpp \
|
tinytinyrsslogin.cpp \
|
||||||
post.cpp
|
post.cpp
|
||||||
|
|
||||||
RESOURCES += qml.qrc
|
RESOURCES += qml.qrc \
|
||||||
|
images.qrc
|
||||||
|
|
||||||
|
RC_FILE = Icon.icns
|
||||||
|
|
||||||
# Needed for bringing browser from background to foreground using QDesktopServices: http://bugreports.qt-project.org/browse/QTBUG-8336
|
# Needed for bringing browser from background to foreground using QDesktopServices: http://bugreports.qt-project.org/browse/QTBUG-8336
|
||||||
TARGET.CAPABILITY += SwEvent
|
TARGET.CAPABILITY += SwEvent
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
<RCC/>
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>feedthemonkey.xpm</file>
|
||||||
|
<file>Icon.icns</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
|
|
1
main.cpp
1
main.cpp
|
@ -3,6 +3,7 @@
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QtQml>
|
#include <QtQml>
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
#include "tinytinyrsslogin.h"
|
#include "tinytinyrsslogin.h"
|
||||||
#include "tinytinyrss.h"
|
#include "tinytinyrss.h"
|
||||||
|
|
18
main.qml
18
main.qml
|
@ -50,8 +50,22 @@ ApplicationWindow {
|
||||||
|
|
||||||
Keys.onRightPressed: sidebar.next()
|
Keys.onRightPressed: sidebar.next()
|
||||||
Keys.onLeftPressed: sidebar.previous()
|
Keys.onLeftPressed: sidebar.previous()
|
||||||
Keys.onDownPressed: content.scrollDown()
|
Keys.onDownPressed: content.scrollDown(content.scrollJump)
|
||||||
Keys.onUpPressed: content.scrollUp()
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Login {
|
Login {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue