Skip to content

Commit 881d836

Browse files
committed
Add feed parser for the qgis.org blog
1 parent bb69f16 commit 881d836

File tree

5 files changed

+117
-6
lines changed

5 files changed

+117
-6
lines changed

doc/whatsnew.html

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
html {
6+
font-family: "Open Sans", "Helvetica Neue", Ubuntu, Arial, sans-serif;
7+
}
8+
a {
9+
text-decoration: none;
10+
color: #08c;
11+
}
12+
13+
.feed-element {
14+
margin: 1em;
15+
background-color: #eee;
16+
border-radius: 9px;
17+
padding: 1em;
18+
border: 1px solid #999;
19+
overflow: auto;
20+
}
21+
22+
.description {
23+
}
24+
25+
.date {
26+
font-size: 70%;
27+
font-style: italic;
28+
margin-bottom: 1em;
29+
color: #666;
30+
}
31+
32+
.feed-element .content-image {
33+
float: left;
34+
margin-right: 1em;
35+
}
36+
</style>
37+
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
38+
<script type="text/javascript">
39+
40+
google.load("feeds", "1");
41+
42+
function initialize() {
43+
var feed = new google.feeds.Feed('http://blog.qgis.org/feed/');
44+
feed.load(function(result) {
45+
if (!result.error) {
46+
var container = document.getElementById("feed");
47+
result.feed.entries.forEach(
48+
function(entry) {
49+
var div = document.createElement("div");
50+
div.setAttribute('class', 'feed-element')
51+
52+
var link = document.createElement("a");
53+
link.setAttribute('href', entry.link);
54+
55+
var title = document.createElement("h2");
56+
title.appendChild(document.createTextNode(entry.title));
57+
link.appendChild(title);
58+
div.appendChild(link);
59+
60+
var date = document.createElement("div");
61+
date.setAttribute('class', 'date');
62+
date.appendChild(document.createTextNode(entry.publishedDate));
63+
div.appendChild(date);
64+
65+
var img = document.createElement("img");
66+
img.setAttribute('src', entry.mediaGroups[0].contents[0].url);
67+
img.setAttribute('class', 'content-image');
68+
div.appendChild(img);
69+
70+
var description = document.createElement("div");
71+
description.setAttribute('class', 'description');
72+
description.innerHTML=entry.contentSnippet;
73+
div.appendChild(description);
74+
75+
container.appendChild(div);
76+
}
77+
)
78+
}
79+
});
80+
}
81+
google.setOnLoadCallback(initialize);
82+
83+
</script>
84+
</head>
85+
<body>
86+
<h1>QGIS News</h1>
87+
<div id="feed"></div>
88+
</body>
89+
</html>

src/app/qgswelcomepage.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
#include "qgsproject.h"
1818
#include "qgisapp.h"
1919
#include "qgsversioninfo.h"
20+
#include "qgsapplication.h"
2021

2122
#include <QHBoxLayout>
2223
#include <QVBoxLayout>
2324
#include <QListView>
2425
#include <QSettings>
26+
#include <QDesktopServices>
2527

2628
QgsWelcomePage::QgsWelcomePage( QWidget* parent )
2729
: QWidget( parent )
@@ -38,25 +40,30 @@ QgsWelcomePage::QgsWelcomePage( QWidget* parent )
3840
QListView* welcomeScreenListView = new QListView();
3941
mModel = new QgsWelcomePageItemsModel();
4042
welcomeScreenListView->setModel( mModel );
43+
welcomeScreenListView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
4144
layout->addWidget( welcomeScreenListView );
4245
welcomeScreenListView->setStyleSheet( "QListView::item {"
4346
" margin-top: 5px;"
4447
" margin-bottom: 5px;"
4548
" margin-left: 15px;"
4649
" margin-right: 15px;"
4750
" border-width: 1px;"
48-
" border-color: #535353;"
51+
" border-color: #999;"
4952
" border-radius: 9px;"
50-
" background: #cccccc;"
53+
" background: #eee;"
5154
" padding: 10px;"
5255
"}"
5356
"QListView::item:selected:active {"
5457
" background: #aaaaaa;"
5558
"}");
5659

57-
QgsWebView* webView = new QgsWebView();
58-
webView->setUrl( QUrl( "http://blog.qgis.org" ) );
59-
layout->addWidget( webView );
60+
QgsWebView* whatsNewPage = new QgsWebView();
61+
whatsNewPage->setUrl( QUrl::fromLocalFile( QgsApplication::whatsNewFilePath() ) );
62+
whatsNewPage->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
63+
whatsNewPage->setContextMenuPolicy( Qt::NoContextMenu );
64+
whatsNewPage->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
65+
layout->addWidget( whatsNewPage );
66+
connect( whatsNewPage, SIGNAL(linkClicked(QUrl)), this, SLOT(whatsNewLinkClicked(QUrl)));
6067

6168
mVersionInformation = new QLabel;
6269
mainLayout->addWidget( mVersionInformation );
@@ -84,7 +91,7 @@ void QgsWelcomePage::versionInfoReceived()
8491
QgsVersionInfo* versionInfo = qobject_cast<QgsVersionInfo*>( sender() );
8592
Q_ASSERT( versionInfo );
8693

87-
if ( versionInfo->isDevelopmentVersion() )
94+
if ( versionInfo->newVersionAvailable() )
8895
{
8996
mVersionInformation->setVisible( true );
9097
mVersionInformation->setText( QString( "<b>%1</b>: %2")
@@ -96,3 +103,8 @@ void QgsWelcomePage::versionInfoReceived()
96103
"}");
97104
}
98105
}
106+
107+
void QgsWelcomePage::whatsNewLinkClicked(const QUrl& url)
108+
{
109+
QDesktopServices::openUrl( url );
110+
}

src/app/qgswelcomepage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class QgsWelcomePage : public QWidget
3333
private slots:
3434
void itemDoubleClicked(const QModelIndex& index );
3535
void versionInfoReceived();
36+
void whatsNewLinkClicked(const QUrl& url );
3637

3738
private:
3839
QgsWelcomePageItemsModel* mModel;

src/core/qgsapplication.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,11 @@ const QString QgsApplication::developersMapFilePath()
447447
{
448448
return ABISYM( mPkgDataPath ) + QString( "/doc/developersmap.html" );
449449
}
450+
451+
const QString QgsApplication::whatsNewFilePath()
452+
{
453+
return ABISYM( mPkgDataPath ) + QString( "/doc/whatsnew.html" );
454+
}
450455
/*!
451456
Returns the path to the sponsors file.
452457
*/

src/core/qgsapplication.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ class CORE_EXPORT QgsApplication : public QApplication
9090
* @note this function was added in version 2.7 */
9191
static const QString developersMapFilePath();
9292

93+
/** Returns the path to the whats new html page
94+
* @note this function was added in version 2.11 */
95+
static const QString whatsNewFilePath();
96+
9397
/** Returns the path to the sponsors file. */
9498
static const QString sponsorsFilePath();
9599

0 commit comments

Comments
 (0)