1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #include "communitywelcomepagewidget.h"
34 #include "ui_communitywelcomepagewidget.h"
36 #include <coreplugin/rssfetcher.h>
38 #include <QtCore/QMap>
39 #include <QtCore/QUrl>
40 #include <QtGui/QDesktopServices>
41 #include <QtGui/QTreeWidgetItem>
44 const char *description;
48 static const Site supportSites[] = {
49 { QT_TRANSLATE_NOOP("Welcome::Internal::CommunityWelcomePageWidget",
50 "<b>Forum Nokia</b><br /><font color='gray'>Mobile application support</font>"),
51 "http://www.forum.nokia.com/Support/"},
52 { QT_TRANSLATE_NOOP("Welcome::Internal::CommunityWelcomePageWidget",
53 "<b>Qt LGPL Support</b><br /><font color='gray'>Buy commercial Qt support</font>"),
54 "http://shop.qt.nokia.com/en/support.html"},
55 { QT_TRANSLATE_NOOP("Welcome::Internal::CommunityWelcomePageWidget",
56 "<b>Qt DevNet</b><br /><font color='gray'>Qt Developer Resources</font>"),
57 "http://developer.qt.nokia.com" }
60 static const Site sites[] = {
61 { QT_TRANSLATE_NOOP("Welcome::Internal::CommunityWelcomePageWidget",
62 "<b>Qt Home</b><br /><font color='gray'>Qt by Nokia on the web</font>"),
63 "http://qt.nokia.com" },
64 { QT_TRANSLATE_NOOP("Welcome::Internal::CommunityWelcomePageWidget",
65 "<b>Qt Git Hosting</b><br /><font color='gray'>Participate in Qt development</font>"),
66 "http://qt.gitorious.org"},
67 { QT_TRANSLATE_NOOP("Welcome::Internal::CommunityWelcomePageWidget",
68 "<b>Qt Apps</b><br /><font color='gray'>Find free Qt-based apps</font>"),
69 "http://www.qt-apps.org"}
75 static inline void populateWelcomeTreeWidget(const Site *sites, int count, Utils::WelcomeModeTreeWidget *wt)
77 for (int s = 0; s < count; s++) {
78 const QString description = CommunityWelcomePageWidget::tr(sites[s].description);
79 const QString url = QLatin1String(sites[s].url);
80 wt->addItem(description, url, url);
84 CommunityWelcomePageWidget::CommunityWelcomePageWidget(QWidget *parent) :
86 m_rssFetcher(new Core::RssFetcher(7)),
87 ui(new Ui::CommunityWelcomePageWidget)
91 connect(ui->newsTreeWidget, SIGNAL(activated(QString)), SLOT(slotUrlClicked(QString)));
92 connect(ui->miscSitesTreeWidget, SIGNAL(activated(QString)), SLOT(slotUrlClicked(QString)));
93 connect(ui->supportSitesTreeWidget, SIGNAL(activated(QString)), SLOT(slotUrlClicked(QString)));
95 connect(m_rssFetcher, SIGNAL(newsItemReady(QString, QString, QString)),
96 ui->newsTreeWidget, SLOT(addNewsItem(QString, QString, QString)), Qt::QueuedConnection);
97 connect(this, SIGNAL(startRssFetching(QUrl)), m_rssFetcher, SLOT(fetch(QUrl)), Qt::QueuedConnection);
99 m_rssFetcher->start(QThread::LowestPriority);
100 //: Add localized feed here only if one exists
101 emit startRssFetching(QUrl(tr("http://labs.trolltech.com/blogs/feed")));
103 populateWelcomeTreeWidget(supportSites, sizeof(supportSites)/sizeof(Site), ui->supportSitesTreeWidget);
104 populateWelcomeTreeWidget(sites, sizeof(sites)/sizeof(Site), ui->miscSitesTreeWidget);
107 CommunityWelcomePageWidget::~CommunityWelcomePageWidget()
109 m_rssFetcher->exit();
110 m_rssFetcher->wait();
115 void CommunityWelcomePageWidget::slotUrlClicked(const QString &data)
117 QDesktopServices::openUrl(QUrl(data));
120 } // namespace Internal
121 } // namespace Welcome