From 32557b0b39915cf77ec87dd55432bdfa242896ce Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Thu, 28 May 2009 13:47:15 +0200 Subject: [PATCH] welcome screen: preview in news feed, Buttons added, resizing sanatized Manage Sessions replaces "Restore last session" (which can be done by clicking the "(last session)" session anyway. Also, added a "Create New Project" button. Ensured that the welcome screen is only as high as needed (will orient on the amount of items in the contained treewidgets). Scrolling is still last resort. --- src/plugins/coreplugin/rssfetcher.cpp | 86 ++++++- src/plugins/coreplugin/rssfetcher.h | 3 +- src/plugins/coreplugin/welcomemode.cpp | 45 ++-- src/plugins/coreplugin/welcomemode.h | 3 +- src/plugins/coreplugin/welcomemode.ui | 234 ++++++++++++++---- src/plugins/coreplugin/welcomemode_p.h | 2 +- src/plugins/help/helpplugin.cpp | 2 +- .../projectexplorer/projectexplorer.cpp | 5 + src/plugins/projectexplorer/sessiondialog.cpp | 1 + src/plugins/projectexplorer/sessiondialog.ui | 7 + 10 files changed, 320 insertions(+), 68 deletions(-) diff --git a/src/plugins/coreplugin/rssfetcher.cpp b/src/plugins/coreplugin/rssfetcher.cpp index f9005b9887d..7eaadff46eb 100644 --- a/src/plugins/coreplugin/rssfetcher.cpp +++ b/src/plugins/coreplugin/rssfetcher.cpp @@ -28,14 +28,85 @@ **************************************************************************/ #include +#include +#include #include #include #include +#include + #include "rssfetcher.h" +#ifdef Q_OS_UNIX +#include +#endif + using namespace Core::Internal; +static const QString getOsString() +{ + QString osString; +#if defined(Q_OS_WIN) + switch (QSysInfo::WindowsVersion) { + case (QSysInfo::WV_4_0): + osString += QLatin1String("WinNT4.0"); + break; + case (QSysInfo::WV_5_0): + osString += QLatin1String("Windows NT 5.0"); + break; + case (QSysInfo::WV_5_1): + osString += QLatin1String("Windows NT 5.1"); + break; + case (QSysInfo::WV_5_2): + osString += QLatin1String("Windows NT 5.2"); + break; + case (QSysInfo::WV_6_0): + osString += QLatin1String("Windows NT 6.0"); + break; + case (QSysInfo::WV_6_1): + osString += QLatin1String("Windows NT 6.1"); + break; + default: + osString += QLatin1String("Windows NT (Unknown)"); + break; + } +#elif defined (Q_OS_MAC) + if (QSysInfo::ByteOrder == QSysInfo::BigEndian) + osString += QLatin1String("PPC "); + else + osString += QLatin1String("Intel "); + osString += QLatin1String("Mac OS X "); + switch (QSysInfo::MacintoshVersion) { + case (QSysInfo::MV_10_3): + osString += QLatin1String("10_3"); + break; + case (QSysInfo::MV_10_4): + osString += QLatin1String("10_4"); + break; + case (QSysInfo::MV_10_5): + osString += QLatin1String("10_5"); + break; + case (QSysInfo::MV_10_6): + osString += QLatin1String("10_6"); + break; + default: + osString += QLatin1String("(Unknown)"); + break; + } +#elif defined (Q_OS_UNIX) + struct utsname uts; + if (uname(&uts) == 0) + osString += QString("%1 %2").arg(QLatin1String(uts.sysname)) + .arg(QLatin1String(uts.release)); + else + osString += QLatin1String("Unix (Unknown)"); +#else + ossttring = QLatin1String("Unknown OS"); +#endif + return osString; +} + RSSFetcher::RSSFetcher(int maxItems, QObject *parent) : QObject(parent), m_items(0), m_maxItems(maxItems) { @@ -49,7 +120,15 @@ RSSFetcher::RSSFetcher(int maxItems, QObject *parent) void RSSFetcher::fetch(const QUrl &url) { m_http.setHost(url.host()); - m_connectionId = m_http.get(url.path()); + QString agentStr = QString("Qt-Creator/%1 (QHttp %2; %3; %4; %5 bit)") + .arg(Core::Constants::IDE_VERSION_LONG).arg(qVersion()) + .arg(getOsString()).arg(QLocale::system().name()) + .arg(QSysInfo::WordSize); + QHttpRequestHeader header("GET", url.path()); + qDebug() << agentStr; + header.setValue("User-Agent", agentStr); + header.setValue("Host", url.host()); + m_connectionId = m_http.request(header); } void RSSFetcher::readData(const QHttpResponseHeader &resp) @@ -76,6 +155,7 @@ void RSSFetcher::parseXml() if (m_xml.isStartElement()) { if (m_xml.name() == "item") { m_titleString.clear(); + m_descriptionString.clear(); m_linkString.clear(); } m_currentTag = m_xml.name().toString(); @@ -84,12 +164,14 @@ void RSSFetcher::parseXml() m_items++; if (m_items > m_maxItems) return; - emit newsItemReady(m_titleString, m_linkString); + emit newsItemReady(m_titleString, m_descriptionString, m_linkString); } } else if (m_xml.isCharacters() && !m_xml.isWhitespace()) { if (m_currentTag == "title") m_titleString += m_xml.text().toString(); + else if (m_currentTag == "description") + m_descriptionString += m_xml.text().toString(); else if (m_currentTag == "link") m_linkString += m_xml.text().toString(); } diff --git a/src/plugins/coreplugin/rssfetcher.h b/src/plugins/coreplugin/rssfetcher.h index 7479e0e363c..51b368f436c 100644 --- a/src/plugins/coreplugin/rssfetcher.h +++ b/src/plugins/coreplugin/rssfetcher.h @@ -44,7 +44,7 @@ public: RSSFetcher(int maxItems, QObject *parent = 0); signals: - void newsItemReady(const QString& title, const QString& url); + void newsItemReady(const QString& title, const QString& desciption, const QString& url); public slots: void fetch(const QUrl &url); @@ -60,6 +60,7 @@ private: QXmlStreamReader m_xml; QString m_currentTag; QString m_linkString; + QString m_descriptionString; QString m_titleString; QHttp m_http; diff --git a/src/plugins/coreplugin/welcomemode.cpp b/src/plugins/coreplugin/welcomemode.cpp index 558cedbff36..b4843bf8396 100644 --- a/src/plugins/coreplugin/welcomemode.cpp +++ b/src/plugins/coreplugin/welcomemode.cpp @@ -29,9 +29,11 @@ #include "welcomemode.h" #include "icore.h" +#include "iwizard.h" #include "coreconstants.h" #include "uniqueidmanager.h" #include "modemanager.h" +#include "newdialog.h" #include "rssfetcher.h" #include @@ -118,7 +120,7 @@ WelcomeMode::WelcomeMode() : l->setMargin(0); l->setSpacing(0); l->addWidget(new QToolBar(m_d->m_widget)); - m_d->rssFetcher = new RSSFetcher(8, this); + m_d->rssFetcher = new RSSFetcher(7, this); m_d->m_welcomePage = new QWidget(m_d->m_widget); m_d->ui.setupUi(m_d->m_welcomePage); m_d->ui.projTitleLabel->setText(titleLabel(tr("Projects"))); @@ -146,26 +148,27 @@ WelcomeMode::WelcomeMode() : connect(m_d->btnGrp, SIGNAL(buttonClicked(int)), m_d->ui.stackedWidget, SLOT(setCurrentIndex(int))); connect(m_d->ui.feedbackButton, SIGNAL(clicked()), SLOT(slotFeedback())); - connect(m_d->ui.restoreSessionButton, SIGNAL(clicked()), SLOT(slotRestoreLastSession())); + connect(m_d->ui.manageSessionsButton, SIGNAL(clicked()), SIGNAL(manageSessions())); + connect(m_d->ui.createNewProjectButton, SIGNAL(clicked()), SLOT(slotCreateNewProject())); connect(m_d->ui.sessTreeWidget, SIGNAL(activated(QString)), SLOT(slotSessionClicked(QString))); connect(m_d->ui.projTreeWidget, SIGNAL(activated(QString)), SLOT(slotProjectClicked(QString))); connect(m_d->ui.newsTreeWidget, SIGNAL(activated(QString)), SLOT(slotUrlClicked(QString))); connect(m_d->ui.sitesTreeWidget, SIGNAL(activated(QString)), SLOT(slotUrlClicked(QString))); connect(m_d->ui.tutorialTreeWidget, SIGNAL(activated(QString)), SIGNAL(openHelpPage(const QString&))); - connect(m_d->rssFetcher, SIGNAL(newsItemReady(QString, QString)), - m_d->ui.newsTreeWidget, SLOT(slotAddItem(QString, QString))); + connect(m_d->rssFetcher, SIGNAL(newsItemReady(QString, QString, QString)), + m_d->ui.newsTreeWidget, SLOT(slotAddNewsItem(QString, QString, QString))); //: Add localized feed here only if one exists m_d->rssFetcher->fetch(QUrl(tr("http://labs.trolltech.com/blogs/feed"))); - m_d->ui.sitesTreeWidget->addItem(tr("Qt Software"), QLatin1String("http://www.qtsoftware.com")); - m_d->ui.sitesTreeWidget->addItem(tr("Qt Labs"), QLatin1String("http://labs.qtsoftware.com")); + m_d->ui.sitesTreeWidget->addItem(tr("Qt Software"), QLatin1String("http://www.trolltech.com")); + m_d->ui.sitesTreeWidget->addItem(tr("Qt Labs"), QLatin1String("http://labs.trolltech.com")); m_d->ui.sitesTreeWidget->addItem(tr("Qt Git Hosting"), QLatin1String("http://qt.gitorious.org")); m_d->ui.sitesTreeWidget->addItem(tr("Qt Centre"), QLatin1String("http://www.qtcentre.org")); m_d->ui.sitesTreeWidget->addItem(tr("Qt for S60 at Forum Nokia"), QLatin1String("http://discussion.forum.nokia.com/forum/forumdisplay.php?f=196")); - m_d->ui.tutorialTreeWidget->addItem(tr("Qt Creator - A quick tour"), + m_d->ui.tutorialTreeWidget->addItem(tr("Qt Creator - A quick tour"), QString("qthelp://com.nokia.qtcreator.%1%2/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)); m_d->ui.tutorialTreeWidget->addItem(tr("Understanding widgets"), QLatin1String("qthelp://com.trolltech.qt/qdoc/widgets-tutorial.html")); @@ -299,16 +302,17 @@ void WelcomeMode::slotUrlClicked(const QString &data) QDesktopServices::openUrl(QUrl(data)); } -void WelcomeMode::slotRestoreLastSession() -{ - emit requestSession(m_d->lastData.previousSession); - activateEditMode(); -} - void WelcomeMode::slotFeedback() { QDesktopServices::openUrl(QUrl(QLatin1String( - "http://www.qtsoftware.com/forms/feedback-forms/qt-creator-user-feedback/view"))); + "http://www.trolltech.com/forms/feedback-forms/qt-creator-user-feedback/view"))); +} + +void WelcomeMode::slotCreateNewProject() +{ + Core::Internal::NewDialog dlg(widget()); + dlg.setWizards(Core::IWizard::wizardsOfKind(Core::IWizard::ProjectWizard)); + dlg.showDialog(); } void WelcomeMode::slotNextTip() @@ -409,7 +413,8 @@ QTreeWidgetItem *WelcomeModeTreeWidget::addItem(const QString &label, const QStr QTreeWidgetItem *item = new QTreeWidgetItem(this); item->setIcon(0, m_bullet); item->setSizeHint(0, QSize(24, 30)); - QWidget *lbl = new QLabel(label); + QLabel *lbl = new QLabel(label); + lbl->setTextInteractionFlags(Qt::NoTextInteraction); lbl->setCursor(QCursor(Qt::PointingHandCursor)); lbl->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); QBoxLayout *lay = new QVBoxLayout; @@ -422,9 +427,15 @@ QTreeWidgetItem *WelcomeModeTreeWidget::addItem(const QString &label, const QStr return item; } -void WelcomeModeTreeWidget::slotAddItem(const QString &label, const QString &data) +void WelcomeModeTreeWidget::slotAddNewsItem(const QString &title, const QString &description, const QString &link) { - addTopLevelItem(addItem(label,data)); + int itemWidth = width()-header()->sectionSize(0); + QFont f = font(); + QString elidedText = QFontMetrics(f).elidedText(description, Qt::ElideRight, itemWidth); + f.setBold(true); + QString elidedTitle = QFontMetrics(f).elidedText(title, Qt::ElideRight, itemWidth); + QString data = QString::fromLatin1("%1
%2").arg(elidedTitle).arg(elidedText); + addTopLevelItem(addItem(data,link)); } void WelcomeModeTreeWidget::slotItemClicked(QTreeWidgetItem *item) diff --git a/src/plugins/coreplugin/welcomemode.h b/src/plugins/coreplugin/welcomemode.h index 49306df611b..453c3d66e9a 100644 --- a/src/plugins/coreplugin/welcomemode.h +++ b/src/plugins/coreplugin/welcomemode.h @@ -79,13 +79,14 @@ signals: void requestProject(const QString &project); void requestSession(const QString &session); void openHelpPage(const QString&); + void manageSessions(); private slots: void slotFeedback(); - void slotRestoreLastSession(); void slotSessionClicked(const QString &data); void slotProjectClicked(const QString &data); void slotUrlClicked(const QString &data); + void slotCreateNewProject(); void slotNextTip(); void slotPrevTip(); diff --git a/src/plugins/coreplugin/welcomemode.ui b/src/plugins/coreplugin/welcomemode.ui index 8bdb10eb536..c48d35cf5a3 100644 --- a/src/plugins/coreplugin/welcomemode.ui +++ b/src/plugins/coreplugin/welcomemode.ui @@ -6,8 +6,8 @@ 0 0 - 742 - 637 + 864 + 690 @@ -202,7 +202,7 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 - 2 + 0 @@ -232,6 +232,12 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 + + + 0 + 0 + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -240,7 +246,7 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 - + 0 0 @@ -361,11 +367,11 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 - + - + 0 0 @@ -375,8 +381,70 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 - + + + + 0 + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 20 + 2 + + + + + + + + < + + + Qt::LeftArrow + + + + + + + > + + + Qt::RightArrow + + + + + + + Qt::Vertical + + + + 20 + 2 + + + + + + + + + + 0 + 0 + + QFrame::NoFrame @@ -394,30 +462,6 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 - - - - - - < - - - Qt::LeftArrow - - - - - - - > - - - Qt::RightArrow - - - - - @@ -449,17 +493,23 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 - + + + + 0 + 0 + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - + - + 0 0 @@ -509,8 +559,8 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 - - + + 0 @@ -534,17 +584,21 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 - <qt>Restore Last Session &gt;&gt; + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'lucida sans'; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Manage Sessions...</p></body></html> - + Qt::Horizontal - QSizePolicy::Preferred + QSizePolicy::Expanding @@ -554,6 +608,22 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 53 + + + + @@ -563,17 +633,23 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 - + + + + 0 + 0 + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - + - + 0 0 @@ -623,6 +699,68 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 + + + + + 0 + 0 + + + + * { + border-image: url(:/core/images/welcomemode/btn_26.png) 7; + border-width: 7; + padding: -2px 0; + font-size: 12px; + font-family: lucida sans, dejavu sans, sans serif; + color: black; +} + +*:hover { + border-image: url(:/core/images/welcomemode/btn_26_hover.png) 7; + color: white; +} + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'lucida sans'; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Create New Project...</p></body></html> + + + + + + + Qt::Horizontal + + + + 157 + 20 + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + @@ -660,6 +798,12 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 + + + 0 + 0 + + 360 @@ -802,7 +946,7 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 15 - 17 + 15 @@ -873,7 +1017,7 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 Qt::Vertical - QSizePolicy::Maximum + QSizePolicy::Expanding @@ -889,7 +1033,7 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 Qt::Vertical - QSizePolicy::Maximum + QSizePolicy::Expanding diff --git a/src/plugins/coreplugin/welcomemode_p.h b/src/plugins/coreplugin/welcomemode_p.h index 929f9bd8212..86932298934 100644 --- a/src/plugins/coreplugin/welcomemode_p.h +++ b/src/plugins/coreplugin/welcomemode_p.h @@ -69,7 +69,7 @@ public: QTreeWidgetItem *addItem(const QString &label, const QString &data); public slots: - void slotAddItem(const QString &label, const QString &data); + void slotAddNewsItem(const QString &title, const QString &description, const QString &link); signals: void activated(const QString &data); diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 6440d483422..e885b65058a 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -736,7 +736,7 @@ void HelpPlugin::openHelpPage(const QString& url) else { QString page = url.mid(url.lastIndexOf('/')+1); qDebug() << url << page << url.lastIndexOf('/'); - QDesktopServices::openUrl(QLatin1String("http://doc.qtsoftware.com/latest/")+page); + QDesktopServices::openUrl(QLatin1String("http://doc.trolltech.com/latest/")+page); } } diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index dae289ae232..676a351a6f8 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -78,6 +78,7 @@ #include #include #include +#include #include #include #include @@ -669,6 +670,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er m_projectExplorerSettings.saveBeforeBuild = s->value("ProjectExplorer/Settings/SaveBeforeBuild", false).toBool(); } + if (Core::Internal::WelcomeMode *welcomeMode = qobject_cast + (Core::ICore::instance()->modeManager()->mode(Core::Constants::MODE_WELCOME))) { + connect(welcomeMode, SIGNAL(manageSessions()), this, SLOT(showSessionManager())); + } connect(m_sessionManagerAction, SIGNAL(triggered()), this, SLOT(showSessionManager())); connect(m_newAction, SIGNAL(triggered()), this, SLOT(newProject())); #if 0 diff --git a/src/plugins/projectexplorer/sessiondialog.cpp b/src/plugins/projectexplorer/sessiondialog.cpp index f36a028f9a2..1285bf171d3 100644 --- a/src/plugins/projectexplorer/sessiondialog.cpp +++ b/src/plugins/projectexplorer/sessiondialog.cpp @@ -124,6 +124,7 @@ SessionDialog::SessionDialog(SessionManager *sessionManager, const QString &last connect(m_ui.sessionList, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(updateActions())); + m_ui.whatsASessionLabel->setOpenExternalLinks(true); QStringList sessions = sessionManager->sessions(); foreach (const QString &session, sessions) { m_ui.sessionList->addItem(session); diff --git a/src/plugins/projectexplorer/sessiondialog.ui b/src/plugins/projectexplorer/sessiondialog.ui index 942116e35e8..ab2f4b08a0c 100644 --- a/src/plugins/projectexplorer/sessiondialog.ui +++ b/src/plugins/projectexplorer/sessiondialog.ui @@ -62,6 +62,13 @@ + + + + <a href="qthelp://com.nokia.qtcreator/doc/creator-quick-tour.html#session-management-in-qt-creator">What is a Session?</a> + + +