Remove usage of external dependencies from the RSS News demo

Examples in qtdeclarative shouldn't depend on Qt Quick Controls,
Layouts, or add on modules like Qt Graphical Effects.

Change-Id: Ic069ed3223a4cfebde5263e846ae394aebed0b33
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: Niels Weber <niels.weber@digia.com>
This commit is contained in:
Topi Reinio 2014-06-27 10:00:24 +02:00 committed by Topi Reiniö
parent 2e75be5f64
commit 217f07d2f2
2 changed files with 23 additions and 58 deletions

View File

@ -39,7 +39,6 @@
****************************************************************************/
import QtQuick 2.2
import QtGraphicalEffects 1.0
Rectangle {
id: delegate
@ -54,10 +53,6 @@ Rectangle {
source: image
}
Item {
id: title
anchors.fill: parent
Text {
id: titleText
@ -66,44 +61,13 @@ Rectangle {
right: parent.right; rightMargin: 20
top: parent.top; topMargin: 20
}
font { pixelSize: 18; bold: true }
text: name
color: selected ? "#ffffff" : "#ebebdd"
scale: selected ? 1.15 : 1.0
Behavior on color { ColorAnimation { duration: 150 } }
}
DropShadow {
source: titleText
anchors.fill: titleText
horizontalOffset: selected ? 3 : 1
verticalOffset: selected ? 3 : 1
radius: 4
color: "#2f1000"
samples: 8
Behavior on horizontalOffset { NumberAnimation { duration: 300 } }
Behavior on verticalOffset { NumberAnimation { duration: 300 } }
}
states: [
State {
name: "selected"
when: selected
PropertyChanges { target: title; scale: "1.1" }
}]
transitions: [
Transition {
to: "selected"
SequentialAnimation {
id: titleAnimation
PropertyAnimation { target: title; property: "scale"; duration: 300 }
}
},
Transition {
to: ""
animations: titleAnimation
}]
Behavior on scale { PropertyAnimation { duration: 300 } }
}
BusyIndicator {

View File

@ -39,11 +39,11 @@
****************************************************************************/
import QtQuick 2.2
import QtQuick.Layouts 1.1
ColumnLayout {
Column {
id: delegate
width: delegate.ListView.view.width
spacing: 8
// Returns a string representing how long ago an event occurred
function timeSinceEvent(pubDate) {
@ -77,13 +77,15 @@ ColumnLayout {
return result;
}
RowLayout {
Layout.maximumWidth: parent.width
Item { height: 8; width: delegate.width }
ColumnLayout {
Layout.alignment: Qt.AlignTop
Row {
width: parent.width
spacing: 8
Column {
Item {
width: 4
height: titleText.font.pixelSize / 4
}
@ -97,7 +99,7 @@ ColumnLayout {
id: titleText
text: title
Layout.maximumWidth: delegate.width - titleImage.width
width: delegate.width - titleImage.width
wrapMode: Text.WordWrap
font.pixelSize: 26
font.bold: true
@ -105,11 +107,10 @@ ColumnLayout {
}
Text {
Layout.maximumWidth: delegate.width
width: delegate.width
font.pixelSize: 12
textFormat: Text.RichText
font.italic: true
Layout.alignment: Qt.AlignLeft
text: timeSinceEvent(pubDate) + " (<a href=\"" + link + "\">Link</a>)"
onLinkActivated: {
Qt.openUrlExternally(link)
@ -120,7 +121,7 @@ ColumnLayout {
id: descriptionText
text: description
Layout.maximumWidth: parent.width
width: parent.width
wrapMode: Text.WordWrap
font.pixelSize: 14
textFormat: Text.StyledText