welcome screen: improve aldgnment, extend getting started section.

Introduce integrated 'Did you know' section, prevent scrollbars.
This commit is contained in:
Daniel Molkentin
2009-05-12 19:47:54 +02:00
parent 5123f48b0a
commit c111e2b10f
4 changed files with 717 additions and 764 deletions

View File

@@ -74,18 +74,17 @@ void RSSFetcher::parseXml()
while (!m_xml.atEnd()) { while (!m_xml.atEnd()) {
m_xml.readNext(); m_xml.readNext();
if (m_xml.isStartElement()) { if (m_xml.isStartElement()) {
if (m_xml.name() == "item") if (m_xml.name() == "item") {
m_linkString = m_xml.attributes().value("rss:about").toString(); m_titleString.clear();
m_linkString.clear();
}
m_currentTag = m_xml.name().toString(); m_currentTag = m_xml.name().toString();
} else if (m_xml.isEndElement()) { } else if (m_xml.isEndElement()) {
if (m_xml.name() == "item") { if (m_xml.name() == "item") {
m_items++; m_items++;
if (m_items > m_maxItems) if (m_items > m_maxItems)
return; return;
emit newsItemReady(m_titleString, m_linkString); emit newsItemReady(m_titleString, m_linkString);
m_titleString.clear();
m_linkString.clear();
} }
} else if (m_xml.isCharacters() && !m_xml.isWhitespace()) { } else if (m_xml.isCharacters() && !m_xml.isWhitespace()) {

View File

@@ -38,12 +38,15 @@
#include <QtGui/QDesktopServices> #include <QtGui/QDesktopServices>
#include <QtGui/QMouseEvent> #include <QtGui/QMouseEvent>
#include <QtCore/QDateTime>
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QUrl> #include <QtCore/QUrl>
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <cstdlib>
#include "ui_welcomemode.h" #include "ui_welcomemode.h"
namespace Core { namespace Core {
@@ -101,7 +104,8 @@ WelcomeMode::WelcomeMode() :
l->setMargin(0); l->setMargin(0);
l->setSpacing(0); l->setSpacing(0);
l->addWidget(new QToolBar(m_d->m_widget)); l->addWidget(new QToolBar(m_d->m_widget));
m_d->rssFetcher = new RSSFetcher(6, this); // limit to 7 items to avoid scrollbars
m_d->rssFetcher = new RSSFetcher(7, this);
m_d->m_welcomePage = new QWidget(m_d->m_widget); m_d->m_welcomePage = new QWidget(m_d->m_widget);
m_d->ui.setupUi(m_d->m_welcomePage); m_d->ui.setupUi(m_d->m_welcomePage);
m_d->ui.sessTreeWidget->viewport()->setAutoFillBackground(false); m_d->ui.sessTreeWidget->viewport()->setAutoFillBackground(false);
@@ -109,6 +113,7 @@ WelcomeMode::WelcomeMode() :
m_d->ui.newsTreeWidget->viewport()->setAutoFillBackground(false); m_d->ui.newsTreeWidget->viewport()->setAutoFillBackground(false);
m_d->ui.sitesTreeWidget->viewport()->setAutoFillBackground(false); m_d->ui.sitesTreeWidget->viewport()->setAutoFillBackground(false);
m_d->ui.tutorialTreeWidget->viewport()->setAutoFillBackground(false); m_d->ui.tutorialTreeWidget->viewport()->setAutoFillBackground(false);
m_d->ui.didYouKnowTextBrowser->viewport()->setAutoFillBackground(false);
l->addWidget(m_d->m_welcomePage); l->addWidget(m_d->m_welcomePage);
updateWelcomePage(WelcomePageData()); updateWelcomePage(WelcomePageData());
@@ -120,7 +125,6 @@ WelcomeMode::WelcomeMode() :
connect(m_d->btnGrp, SIGNAL(buttonClicked(int)), m_d->ui.stackedWidget, SLOT(setCurrentIndex(int))); connect(m_d->btnGrp, SIGNAL(buttonClicked(int)), m_d->ui.stackedWidget, SLOT(setCurrentIndex(int)));
connect(m_d->ui.gettingStartedButton, SIGNAL(clicked()), SIGNAL(requestHelp()));
connect(m_d->ui.feedbackButton, SIGNAL(clicked()), SLOT(slotFeedback())); connect(m_d->ui.feedbackButton, SIGNAL(clicked()), SLOT(slotFeedback()));
connect(m_d->ui.restoreSessionButton, SIGNAL(clicked()), SLOT(slotRestoreLastSession())); connect(m_d->ui.restoreSessionButton, SIGNAL(clicked()), SLOT(slotRestoreLastSession()));
connect(m_d->ui.sessTreeWidget, SIGNAL(activated(QString)), SLOT(slotSessionClicked(QString))); connect(m_d->ui.sessTreeWidget, SIGNAL(activated(QString)), SLOT(slotSessionClicked(QString)));
@@ -141,9 +145,9 @@ WelcomeMode::WelcomeMode() :
m_d->ui.sitesTreeWidget->addItem(tr("Qt Centre"), QLatin1String("http://www.qtcentre.org")); m_d->ui.sitesTreeWidget->addItem(tr("Qt Centre"), QLatin1String("http://www.qtcentre.org"));
m_d->ui.sitesTreeWidget->addItem(tr("Qt/S60 at Forum Nokia"), QLatin1String("http://discussion.forum.nokia.com/forum/forumdisplay.php?f=196")); m_d->ui.sitesTreeWidget->addItem(tr("Qt/S60 at Forum Nokia"), QLatin1String("http://discussion.forum.nokia.com/forum/forumdisplay.php?f=196"));
m_d->ui.tutorialTreeWidget->addItem(tr("Using Qt Creator"), 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)); 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"), m_d->ui.tutorialTreeWidget->addItem(tr("Understanding widgets"),
QLatin1String("qthelp://com.trolltech.qt/qdoc/widgets-tutorial.html")); QLatin1String("qthelp://com.trolltech.qt/qdoc/widgets-tutorial.html"));
m_d->ui.tutorialTreeWidget->addItem(tr("Creating an address book"), m_d->ui.tutorialTreeWidget->addItem(tr("Creating an address book"),
QLatin1String("qthelp://com.trolltech.qt/qdoc/tutorials-addressbook.html")); QLatin1String("qthelp://com.trolltech.qt/qdoc/tutorials-addressbook.html"));
@@ -152,6 +156,7 @@ WelcomeMode::WelcomeMode() :
m_d->ui.tutorialTreeWidget->addItem(tr("Writing test cases"), m_d->ui.tutorialTreeWidget->addItem(tr("Writing test cases"),
QLatin1String("qthelp://com.trolltech.qt/qdoc/qtestlib-tutorial.html")); QLatin1String("qthelp://com.trolltech.qt/qdoc/qtestlib-tutorial.html"));
m_d->ui.didYouKnowTextBrowser->setText(getTipOfTheDay());
QSettings *settings = ICore::instance()->settings(); QSettings *settings = ICore::instance()->settings();
int id = settings->value("General/WelcomeTab", 0).toInt(); int id = settings->value("General/WelcomeTab", 0).toInt();
m_d->btnGrp->button(id)->setChecked(true); m_d->btnGrp->button(id)->setChecked(true);
@@ -210,7 +215,8 @@ void WelcomeMode::updateWelcomePage(const WelcomePageData &welcomePageData)
m_d->ui.projTreeWidget->clear(); m_d->ui.projTreeWidget->clear();
if (welcomePageData.sessionList.count() > 1) { if (welcomePageData.sessionList.count() > 1) {
foreach (const QString &s, welcomePageData.sessionList) { // limit list to 7 displayed entries to avoid a scrollbar
foreach (const QString &s, welcomePageData.sessionList.mid(0, 6)) {
QString str = s; QString str = s;
if (s == welcomePageData.previousSession) if (s == welcomePageData.previousSession)
str = tr("%1 (last session)").arg(s); str = tr("%1 (last session)").arg(s);
@@ -223,7 +229,8 @@ void WelcomeMode::updateWelcomePage(const WelcomePageData &welcomePageData)
} }
typedef QPair<QString, QString> QStringPair; typedef QPair<QString, QString> QStringPair;
foreach (const QStringPair &it, welcomePageData.projectList) { // limit list to 8 displayed entries to avoid a scrollbar
foreach (const QStringPair &it, welcomePageData.projectList.mid(0, 7)) {
QTreeWidgetItem *item = m_d->ui.projTreeWidget->addItem(it.second, it.first); QTreeWidgetItem *item = m_d->ui.projTreeWidget->addItem(it.second, it.first);
const QFileInfo fi(it.first); const QFileInfo fi(it.first);
item->setToolTip(1, QDir::toNativeSeparators(fi.absolutePath())); item->setToolTip(1, QDir::toNativeSeparators(fi.absolutePath()));
@@ -275,6 +282,27 @@ void WelcomeMode::slotFeedback()
"http://www.qtsoftware.com/forms/feedback-forms/qt-creator-user-feedback/view"))); "http://www.qtsoftware.com/forms/feedback-forms/qt-creator-user-feedback/view")));
} }
QString WelcomeMode::getTipOfTheDay()
{
static QStringList tips;
if (tips.isEmpty()) {
tips.append(tr("You can switch between Qt Creator's modes using <tt>Ctrl+number</tt>:"
"<ol><li> - Welcome</li><li> - Edit</li><li>- Debug</li><li>- Projects</li><li>- Help</li>"
"<li></li><li>- Output</li></ol>"));
tips.append(tr("You can show and hide the side bar using <tt>Alt+0<tt>."));
tips.append(tr("You can fine tune the <tt>Find</tt> function by selecting &quot;Whole Words&quot; "
"or &quot;Case Sensitive&quot;. Simply click on the icons on the right end of the line edit."));
tips.append(tr("If you add a <a href=\"qthelp://com.nokia.qtcreator/doc/creator-external-library-handling.html\""
">external libraries</a>, Qt Creator will automatically offer syntax highlighting "
"and code completion."));
}
srand(QDateTime::currentDateTime().toTime_t());
return tips.at(rand()%tips.count());
}
// --- WelcomeModeButton // --- WelcomeModeButton
WelcomeModeButton::WelcomeModeButton(QWidget *parent) : WelcomeModeButton::WelcomeModeButton(QWidget *parent) :

View File

@@ -79,7 +79,6 @@ signals:
void requestProject(const QString &project); void requestProject(const QString &project);
void requestSession(const QString &session); void requestSession(const QString &session);
void openHelpPage(const QString&); void openHelpPage(const QString&);
void requestHelp();
private slots: private slots:
void slotFeedback(); void slotFeedback();
@@ -90,6 +89,7 @@ private slots:
private: private:
void activateEditMode(); void activateEditMode();
QString getTipOfTheDay();
WelcomeModePrivate *m_d; WelcomeModePrivate *m_d;
}; };

File diff suppressed because it is too large Load Diff