From a41b3b83b996086762232666fe1f1d9a08ef4f27 Mon Sep 17 00:00:00 2001 From: Niels Weber Date: Mon, 15 Sep 2014 13:02:22 +0200 Subject: HomeScreen Layout changes Add some missing Tweet parts Change-Id: I7f3402ea1590283cab10b308d9a389f92b982c5c Reviewed-by: Caroline Chao --- qml/components/HomeScreen.qml | 124 +++++++++++++++++++++++++++++++------- qml/components/images/Twitter.svg | 17 ++++++ qml/main.qml | 2 +- resource.qrc | 1 + src/theme.cpp | 7 ++- 5 files changed, 124 insertions(+), 27 deletions(-) create mode 100644 qml/components/images/Twitter.svg diff --git a/qml/components/HomeScreen.qml b/qml/components/HomeScreen.qml index 1459009..857b539 100644 --- a/qml/components/HomeScreen.qml +++ b/qml/components/HomeScreen.qml @@ -40,7 +40,6 @@ import QtQuick 2.2 import QtQuick.Layouts 1.1 -import QtQuick.XmlListModel 2.0 import TalkSchedule 1.0 Rectangle { @@ -56,12 +55,15 @@ Rectangle { function linkForEntity(entity) { - return (entity.url ? entity.url : entity.expanded_url) + return (entity.url ? entity.url : + (entity.screen_name ? 'https://twitter.com/' + entity.screen_name : + 'https://twitter.com/search?q=%23' + entity.text)) } function textForEntity(entity) { - return (entity.display_url ? entity.display_url : entity.expanded_url) + return (entity.display_url ? entity.display_url : + (entity.screen_name ? entity.screen_name : entity.text)) } function insertLinks(text, entities) @@ -72,8 +74,12 @@ Rectangle { if (!entities) return text; + if (entities.retweeted_status) + return ""; + var links = [] - links = entities.media ? entities.urls.concat(entities.media) : entities.urls + entities.urls = entities.media ? entities.urls.concat(entities.media) : entities.urls + links = entities.urls.concat(entities.hashtags, entities.user_mentions) links.sort(function(a, b) { return b.indices[0] - a.indices[0] }) @@ -152,7 +158,7 @@ Rectangle { upcomingItem.visibleDate = Qt.formatDate(sortModelNextEvents.get(0, "start"), upcomingItem.formatDate) } } - spacing: Theme.margins.ten + spacing: Theme.margins.twenty delegate: RowLayout { id: upcomingEventDelegate width: parent.width @@ -209,7 +215,7 @@ Rectangle { } } Item { - // news + // twitter news width: window.width height: (homeScreenWindow.height - homeScreenWindow.usefulItemHeight)/2 @@ -217,21 +223,36 @@ Rectangle { id: tweetModel } - Text { + Rectangle { id: labelNews - z: 1 - text: Theme.text.news width: parent.width height: Theme.sizes.homeTitleHeight - font.pointSize: Theme.fonts.seven_pt - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.capitalization: Font.AllUppercase - Rectangle { - anchors.fill: parent - z: -1 - color: Theme.colors.smokewhite + color: Theme.colors.smokewhite + + Text { + id: labelNewsText + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + + text: Theme.text.news + font.pointSize: Theme.fonts.seven_pt + font.capitalization: Font.AllUppercase + } + + Image { + source: Theme.images.twitter + sourceSize.height: labelNewsText.height + sourceSize.width: labelNewsText.height + anchors.right: labelNewsText.left + anchors.rightMargin: Theme.margins.five + anchors.verticalCenter: parent.verticalCenter + + MouseArea { + anchors.fill: parent + onClicked: Qt.openUrlExternally(Theme.text.twitterLink) + } } + Image { id: reloadNews anchors.verticalCenter: parent.verticalCenter @@ -251,7 +272,7 @@ Rectangle { id: tweetDelegate Rectangle { - color: Theme.colors.smokewhite + color: Theme.colors.white height: Math.max(tweetArea.height, Theme.sizes.twitterAvatarSize) width: window.width @@ -271,20 +292,69 @@ Rectangle { source: model.user.profile_image_url sourceSize.height: Theme.sizes.twitterAvatarSize sourceSize.width: Theme.sizes.twitterAvatarSize + + MouseArea { + anchors.fill: parent + onClicked: Qt.openUrlExternally(Theme.text.twitterLink + model.user.screen_name) + } } Column { id: tweetArea - width: parent.width - placeHolder.width + width: parent.width - placeHolder.width - Theme.margins.twenty height: userName.implicitHeight + tweetContent.implicitHeight anchors.left: placeHolder.right anchors.leftMargin: Theme.margins.ten anchors.rightMargin: Theme.margins.ten - Text { - id: userName + Item { width: parent.width - text: Theme.text.tweet_title.arg(model.user.name).arg(model.user.screen_name) + height: userName.implicitHeight + Text { + id: userName + anchors.left: parent.left + text: model.user.name + font.pointSize: Theme.fonts.eight_pt + color: Theme.colors.black + textFormat: Text.StyledText + MouseArea { + anchors.fill: parent + onClicked: Qt.openUrlExternally(Theme.text.twitterLink + + model.user.screen_name) + } + } + + Text { + id: screenName + anchors.left: userName.right + anchors.leftMargin: Theme.margins.ten + anchors.bottom: parent.bottom + text: "@" + model.user.screen_name + font.pointSize: Theme.fonts.seven_pt + color: Theme.colors.gray + textFormat: Text.StyledText + MouseArea { + anchors.fill: parent + onClicked: Qt.openUrlExternally(Theme.text.twitterLink + + model.user.screen_name) + } + } + Text { + id: timeStamp + anchors.right: parent.right + anchors.rightMargin: Theme.margins.ten + anchors.bottom: parent.bottom + text: model.created_at + font.pointSize: Theme.fonts.seven_pt + color: Theme.colors.gray + textFormat: Text.StyledText + MouseArea { + anchors.fill: parent + onClicked: Qt.openUrlExternally(Theme.text.twitterLink + + model.user.screen_name + + "/status/" + model.id_str) + } + } } Text { @@ -293,7 +363,15 @@ Rectangle { text: insertLinks(model.text, model.entities) wrapMode: Text.WordWrap textFormat: Text.RichText + font.pointSize: Theme.fonts.seven_pt + color: Theme.colors.gray onLinkActivated: Qt.openUrlExternally(link) + MouseArea { + anchors.fill: parent + onClicked: Qt.openUrlExternally(Theme.text.twitterLink + + model.user.screen_name + + "/status/" + model.id_str) + } } } } @@ -307,7 +385,7 @@ Rectangle { anchors.bottom: parent.bottom anchors.margins: Theme.margins.ten clip: true - spacing: Theme.margins.fifteen + spacing: Theme.margins.twenty model: tweetModel.model delegate: tweetDelegate } diff --git a/qml/components/images/Twitter.svg b/qml/components/images/Twitter.svg new file mode 100644 index 0000000..449d7b4 --- /dev/null +++ b/qml/components/images/Twitter.svg @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/qml/main.qml b/qml/main.qml index cea2476..6997bf7 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -47,7 +47,7 @@ import "components" ApplicationWindow { id: window visible: true - height: 800 + height: 1080 width: 1080 property bool busy diff --git a/resource.qrc b/resource.qrc index e8528b9..324c947 100644 --- a/resource.qrc +++ b/resource.qrc @@ -31,5 +31,6 @@ qml/components/images/Btn_Restaurants.svg qml/components/images/Btn_VenueMap.svg qml/components/images/Location.svg + qml/components/images/Twitter.svg diff --git a/src/theme.cpp b/src/theme.cpp index 0e69d2d..feaa503 100644 --- a/src/theme.cpp +++ b/src/theme.cpp @@ -77,13 +77,13 @@ Theme::Theme(QObject *parent) m_text->insert(QLatin1String("favorites"), tr("Favorites")); m_text->insert(QLatin1String("feedback"), tr("Send Feedback")); m_text->insert(QLatin1String("upcoming"), tr("Upcoming: %1 %2")); - m_text->insert(QLatin1String("news"), tr("News")); + m_text->insert(QLatin1String("news"), tr("Tweets")); m_text->insert(QLatin1String("info"), tr("Useful Information")); m_text->insert(QLatin1String("writeYourCommentHere"), tr("Write your comments here")); m_text->insert(QLatin1String("by"), tr("by %1")); m_text->insert(QLatin1String("room"), tr("Room %1")); m_text->insert(QLatin1String("room_space"), tr(" - Room %1")); - m_text->insert(QLatin1String("tweet_title"), "%1 @%2"); + m_text->insert(QLatin1String("twitterLink"), tr("https://twitter.com/")); m_colors = new QQmlPropertyMap(this); m_colors->insert(QLatin1String("white"), QVariant("#ffffff")); @@ -113,7 +113,7 @@ Theme::Theme(QObject *parent) m_sizes->insert(QLatin1String("menuWidth"), QVariant(applyRatio(78))); m_sizes->insert(QLatin1String("dayLabelHeight"), QVariant(applyRatio(70))); m_sizes->insert(QLatin1String("upcomingEventHeight"), QVariant(applyRatio(90))); - m_sizes->insert(QLatin1String("homeTitleHeight"), QVariant(applyRatio(50))); + m_sizes->insert(QLatin1String("homeTitleHeight"), QVariant(applyRatio(100))); m_sizes->insert(QLatin1String("upcomingEventTimeWidth"), QVariant(applyRatio(200))); m_sizes->insert(QLatin1String("trackFieldHeight"), QVariant(applyRatio(50))); m_sizes->insert(QLatin1String("buttonHeight"), QVariant(applyRatio(78))); @@ -137,6 +137,7 @@ Theme::Theme(QObject *parent) m_images->insert(QLatin1String("btnRestaurants"), QVariant("qrc:/images/Btn_Restaurants.svg")); m_images->insert(QLatin1String("btnVenueMap"), QVariant("qrc:/images/Btn_VenueMap.svg")); m_images->insert(QLatin1String("location"), QVariant("qrc:/images/Location.svg")); + m_images->insert(QLatin1String("twitter"), QVariant("qrc:/images/Twitter.svg")); m_fonts = new QQmlPropertyMap(this); m_fonts->insert(QLatin1String("six_pt"), QVariant(applyFontRatio(8))); -- cgit v1.2.3