Add EnterKey action when adding an article

pull/1/head
Grégory Oestreicher 2016-12-20 17:39:14 +01:00
parent 1854aeae1b
commit c5c6630b8a
1 changed files with 20 additions and 13 deletions

View File

@ -64,6 +64,23 @@ Page {
hideErrorWidgetTimer.start() hideErrorWidgetTimer.start()
} }
function doAddArticle( url ) {
articlesModel.loaded = false
serverPage.server.uploadArticle(
addArticleUrl.text,
function( success ) {
if ( success ) {
addArticleUrl.text = ""
hideAddArticleContainer.start()
serverPage.updateArticlesList()
}
else {
articlesModel.loaded = true;
}
}
)
}
Component.onCompleted: { Component.onCompleted: {
updateArticlesList() updateArticlesList()
} }
@ -134,7 +151,7 @@ Page {
id: busyContainer id: busyContainer
visible: !articlesModel.loaded visible: !articlesModel.loaded
anchors.fill: parent anchors.fill: parent
z: 5 z: 10
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
@ -204,6 +221,7 @@ Page {
anchors.topMargin: Theme.horizontalPageMargin anchors.topMargin: Theme.horizontalPageMargin
placeholderText: qsTr( "Article URL" ) placeholderText: qsTr( "Article URL" )
inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhUrlCharactersOnly inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhUrlCharactersOnly
EnterKey.onClicked: doAddArticle( addArticleUrl.text )
} }
Row { Row {
@ -226,18 +244,7 @@ Page {
IconButton { IconButton {
id: addArticleConfirm id: addArticleConfirm
icon.source: "image://theme/icon-m-acknowledge" icon.source: "image://theme/icon-m-acknowledge"
onClicked: doAddArticle( addArticleUrl.text )
onClicked: {
serverPage.server.uploadArticle(
addArticleUrl.text,
function( success ) {
if ( success ) {
addArticleUrl.text = ""
hideAddArticleContainer.start()
}
}
)
}
} }
} }
} }