Skip to content

Commit a14322b

Browse files
Added about page
Also bugfixed the large image source implemetation. Fixes SfietKonstantin#21
1 parent a80cc2d commit a14322b

11 files changed

+192
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ build
22
*.pro.*
33
CMakeLists.txt.*
44
src/lib/twitter-secrets.h
5+
src/bin/version.h
56
report
67
doc

rpm/harbour-twablet.spec

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ A Twitter application for big screens
2222
%prep
2323
%setup -q -n %{name}-%{version}
2424
cp -p %{SOURCE1} src/lib
25+
cat > src/bin/version.h << EOL
26+
#ifndef VERSION_H
27+
#define VERSION_H
28+
29+
static const char *Version = "${RPM_PACKAGE_VERSION}";
30+
31+
#endif // VERSION_H
32+
EOL
2533

2634
%build
2735
cmake -DCMAKE_INSTALL_PREFIX=/usr .

src/bin/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ include_directories(
2929
)
3030

3131
set(${PROJECT_NAME}_SRCS
32+
version.h
3233
main.cpp
3334
)
3435

@@ -53,6 +54,7 @@ set(${PROJECT_NAME}_Qml_SRCS
5354
qml/pages/TweetPage.qml
5455
qml/pages/StatusUpdater.qml
5556
qml/pages/ProgressIconButton.qml
57+
qml/pages/AboutPage.qml
5658
qml/pages/LinkHandler.js
5759
)
5860

@@ -63,6 +65,7 @@ set(${PROJECT_NAME}_Data_SRCS
6365
data/search.svg
6466
data/me.svg
6567
data/background.png
68+
data/logo.png
6669
)
6770

6871
add_executable(${PROJECT_NAME}

src/bin/data/logo.png

12.8 KB
Loading

src/bin/main.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,36 @@
5757
#include "qml/tweetqueryitem.h"
5858
#include "qml/retweetqueryitem.h"
5959
#include "qml/favoritequeryitem.h"
60+
#include "version.h"
61+
62+
static const char *PAYPAL_DONATE = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&"
63+
"hosted_button_id=R6AJV4U2G33XG";
64+
static const char *FLATTR_DONATE = "https://flattr.com/profile/sfiet_konstantin";
65+
66+
class Info: public QObject
67+
{
68+
Q_OBJECT
69+
Q_PROPERTY(QString version READ version CONSTANT)
70+
Q_PROPERTY(QString paypal READ paypal CONSTANT)
71+
Q_PROPERTY(QString flattr READ flattr CONSTANT)
72+
public:
73+
explicit Info(QObject *parent = 0)
74+
: QObject(parent)
75+
{
76+
}
77+
QString version() const
78+
{
79+
return QLatin1String(Version);
80+
}
81+
QString paypal() const
82+
{
83+
return QLatin1String(PAYPAL_DONATE);
84+
}
85+
QString flattr() const
86+
{
87+
return QLatin1String(FLATTR_DONATE);
88+
}
89+
};
6090

6191
int main(int argc, char *argv[])
6292
{
@@ -70,6 +100,7 @@ int main(int argc, char *argv[])
70100
qmlRegisterUncreatableType<qml::MediaObject>("harbour.twablet", 1, 0, "Media", QLatin1String("Uncreatable"));
71101
qmlRegisterUncreatableType<qml::MediaModel>("harbour.twablet", 1, 0, "MediaModel", QLatin1String("Uncreatable"));
72102
qmlRegisterUncreatableType<qml::AbstractQueryItem>("harbour.twablet", 1, 0, "QueryItem", QLatin1String("Uncreatable"));
103+
qmlRegisterUncreatableType<Info>("harbour.twablet", 1, 0, "InfoObject", QLatin1String("Uncreatable"));
73104
qmlRegisterType<qml::TwitterAuthentification>("harbour.twablet", 1, 0, "TwitterAuthentification");
74105
qmlRegisterType<qml::AccountModel>("harbour.twablet", 1, 0, "AccountModel");
75106
qmlRegisterType<qml::AccountSelectionModel>("harbour.twablet", 1, 0, "AccountSelectionModel");
@@ -88,6 +119,10 @@ int main(int argc, char *argv[])
88119
[](QQmlEngine *e, QJSEngine *) -> QObject * {
89120
return new qml::DataRepositoryObject(e);
90121
});
122+
qmlRegisterSingletonType<Info>("harbour.twablet", 1, 0, "Info",
123+
[](QQmlEngine *e, QJSEngine *) -> QObject * {
124+
return new Info(e);
125+
});
91126

92127
#ifndef DESKTOP
93128
return SailfishApp::main(argc, argv);
@@ -100,3 +135,5 @@ int main(int argc, char *argv[])
100135
return app.exec();
101136
#endif
102137
}
138+
139+
#include "main.moc"

src/bin/qml/pages/AboutPage.qml

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
* Copyright (C) 2013 Lucien XU <[email protected]>
3+
*
4+
* You may use this file under the terms of the BSD license as follows:
5+
*
6+
* "Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are
8+
* met:
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
* * Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in
13+
* the documentation and/or other materials provided with the
14+
* distribution.
15+
* * The names of its contributors may not be used to endorse or promote
16+
* products derived from this software without specific prior written
17+
* permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
30+
*/
31+
32+
import QtQuick 2.0
33+
import Sailfish.Silica 1.0
34+
import harbour.twablet 1.0
35+
36+
Page {
37+
id: container
38+
property RightPanel rightPanel
39+
allowedOrientations: app.defaultAllowedOrientations
40+
41+
SilicaFlickable {
42+
anchors.fill: parent
43+
contentHeight: mainColumn.height + Theme.paddingLarge + buttonsColumn.height
44+
Column {
45+
id: mainColumn
46+
spacing: Theme.paddingMedium
47+
anchors.left: parent.left; anchors.right: parent.right
48+
PageHeader {
49+
title: qsTr("About")
50+
}
51+
52+
Image {
53+
anchors.horizontalCenter: parent.horizontalCenter
54+
source: "../../data/logo.png"
55+
}
56+
57+
Column {
58+
anchors.left: parent.left; anchors.leftMargin: Theme.horizontalPageMargin
59+
anchors.right: parent.right; anchors.rightMargin: Theme.horizontalPageMargin
60+
spacing: Theme.paddingSmall
61+
62+
Label {
63+
anchors.horizontalCenter: parent.horizontalCenter
64+
color: Theme.highlightColor
65+
font.pixelSize: Theme.fontSizeHuge
66+
text: qsTr("Twablet")
67+
}
68+
69+
Label {
70+
anchors.horizontalCenter: parent.horizontalCenter
71+
font.pixelSize: Theme.fontSizeExtraSmall
72+
color: Theme.highlightColor
73+
wrapMode: Text.WordWrap
74+
text: qsTr("By Lucien Xu")
75+
}
76+
77+
Label {
78+
anchors.horizontalCenter: parent.horizontalCenter
79+
font.pixelSize: Theme.fontSizeExtraSmall
80+
color: Theme.secondaryHighlightColor
81+
wrapMode: Text.WordWrap
82+
text: qsTr("Version %1").arg(Info.version)
83+
}
84+
}
85+
86+
Label {
87+
wrapMode: Text.WordWrap
88+
anchors.left: parent.left; anchors.leftMargin: Theme.horizontalPageMargin
89+
anchors.right: parent.right; anchors.rightMargin: Theme.horizontalPageMargin
90+
font.pixelSize: Theme.fontSizeSmall
91+
text: qsTr("Twablet is a Twitter client designed for bigger screens. It is an Open Source software, meaning that it can be modified and enhanced by anybody. If you like Friends, please consider a donation. It will help improving the software, while keeping it free and Open Source.")
92+
}
93+
}
94+
95+
Column {
96+
id: buttonsColumn
97+
anchors.top: mainColumn.bottom; anchors.topMargin: Theme.paddingLarge
98+
anchors.left: parent.left; anchors.right: parent.right
99+
MiniButton {
100+
anchors.left: parent.left; anchors.right: parent.right
101+
text: qsTr("Donate via Paypal")
102+
onClicked: Qt.openUrlExternally(Info.paypal)
103+
}
104+
MiniButton {
105+
anchors.left: parent.left; anchors.right: parent.right
106+
text: qsTr("Flattr me")
107+
onClicked: Qt.openUrlExternally(Info.flattr)
108+
}
109+
MiniButton {
110+
AccountSelectionModel {
111+
id: accountSelectionModel
112+
repository: Repository
113+
Component.onCompleted: {
114+
accountSelectionModel.index = 0
115+
}
116+
}
117+
118+
anchors.left: parent.left; anchors.right: parent.right
119+
text: qsTr("Follow me on Twitter")
120+
onClicked: {
121+
pageStack.pop()
122+
container.rightPanel.openUser("361931860", accountSelectionModel.selection, false)
123+
}
124+
}
125+
}
126+
127+
VerticalScrollDecorator {}
128+
}
129+
}

src/bin/qml/pages/MainPage.qml

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Page {
9898

9999
MenuItem {
100100
text: qsTr("About")
101-
enabled: false
101+
onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"), {rightPanel: panel})
102102
}
103103
}
104104

src/bin/qml/pages/TwitterImage.qml

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Item {
3636
id: container
3737
property alias source: image.source
3838
property alias image: image
39+
property alias progress: image.progress
40+
property alias status: image.status
3941

4042
Rectangle {
4143
id: background

src/bin/res.qrc

+2
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@
3030
<file>qml/pages/TweetPage.qml</file>
3131
<file>qml/pages/StatusUpdater.qml</file>
3232
<file>qml/pages/ProgressIconButton.qml</file>
33+
<file>qml/pages/AboutPage.qml</file>
34+
<file>data/logo.png</file>
3335
</qresource>
3436
</RCC>

src/lib/mediaentity.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ QString MediaEntity::mediaUrl() const
9999

100100
QString MediaEntity::mediaUrlLarge() const
101101
{
102+
if (m_mediaUrl.isEmpty()) {
103+
return QString();
104+
}
102105
return m_mediaUrl + QLatin1String(":large");
103106
}
104107

src/lib/user.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ QString User::imageUrl() const
143143

144144
QString User::imageUrlLarge() const
145145
{
146+
if (m_imageUrl.isEmpty()) {
147+
return QString();
148+
}
146149
QString returned {m_imageUrl};
147150
return returned.replace(QLatin1String("_normal"), QLatin1String("_bigger"));
148151
}
@@ -154,6 +157,9 @@ QString User::bannerUrl() const
154157

155158
QString User::bannerUrlLarge() const
156159
{
160+
if (m_bannerUrl.isEmpty()) {
161+
return QString();
162+
}
157163
return m_bannerUrl + QLatin1String("/ipad_retina");
158164
}
159165

0 commit comments

Comments
 (0)