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