From 541f5f6400524661128a1423d25d67e133daa3c6 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin <daniel.molkentin@nokia.com> Date: Wed, 13 May 2009 16:28:03 +0200 Subject: [PATCH] welcome screen: add next/prev tip button, styling --- src/plugins/coreplugin/welcomemode.cpp | 43 +++++++-- src/plugins/coreplugin/welcomemode.h | 4 +- src/plugins/coreplugin/welcomemode.ui | 127 +++++++++++++++++-------- 3 files changed, 127 insertions(+), 47 deletions(-) diff --git a/src/plugins/coreplugin/welcomemode.cpp b/src/plugins/coreplugin/welcomemode.cpp index a03241d2dbc..7b6ff8bd124 100644 --- a/src/plugins/coreplugin/welcomemode.cpp +++ b/src/plugins/coreplugin/welcomemode.cpp @@ -52,6 +52,13 @@ namespace Core { namespace Internal { +namespace { + QString htmlSkel = "<html><head><style type=\"text/css\">" + "a:link { color: #ccc;}" + "a:hover { color: black; text-decoration:underline;} " + "</style></head><body>%1</body></html>>"; +} + struct WelcomeModePrivate { WelcomeModePrivate(); @@ -62,6 +69,7 @@ struct WelcomeModePrivate Ui::WelcomePage ui; RSSFetcher *rssFetcher; WelcomeMode::WelcomePageData lastData; + int currentTip; }; WelcomeModePrivate::WelcomeModePrivate() @@ -156,7 +164,18 @@ WelcomeMode::WelcomeMode() : m_d->ui.tutorialTreeWidget->addItem(tr("Writing test cases"), QLatin1String("qthelp://com.trolltech.qt/qdoc/qtestlib-tutorial.html")); - m_d->ui.didYouKnowTextBrowser->setText(getTipOfTheDay()); + srand(QDateTime::currentDateTime().toTime_t()); + QStringList tips = tipsOfTheDay(); + m_d->currentTip = rand()%tips.count(); + + QTextDocument *doc = m_d->ui.didYouKnowTextBrowser->document(); + doc->setDefaultStyleSheet("a:link {color:black;}"); + m_d->ui.didYouKnowTextBrowser->setDocument(doc); + m_d->ui.didYouKnowTextBrowser->setText(tips.at(m_d->currentTip)); + + connect(m_d->ui.nextTipBtn, SIGNAL(clicked()), this, SLOT(slotNextTip())); + connect(m_d->ui.prevTipBtn, SIGNAL(clicked()), this, SLOT(slotPrevTip())); + QSettings *settings = ICore::instance()->settings(); int id = settings->value("General/WelcomeTab", 0).toInt(); m_d->btnGrp->button(id)->setChecked(true); @@ -282,7 +301,19 @@ void WelcomeMode::slotFeedback() "http://www.qtsoftware.com/forms/feedback-forms/qt-creator-user-feedback/view"))); } -QString WelcomeMode::getTipOfTheDay() +void WelcomeMode::slotNextTip() +{ + QStringList tips = tipsOfTheDay(); + m_d->ui.didYouKnowTextBrowser->setText(tips.at((++m_d->currentTip)%tips.count())); +} + +void WelcomeMode::slotPrevTip() +{ + QStringList tips = tipsOfTheDay(); + m_d->ui.didYouKnowTextBrowser->setText(tips.at((--m_d->currentTip)%tips.count())); +} + +QStringList WelcomeMode::tipsOfTheDay() { static QStringList tips; if (tips.isEmpty()) { @@ -292,17 +323,13 @@ QString WelcomeMode::getTipOfTheDay() 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 "Whole Words" " "or "Case Sensitive". 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\"" + tips.append(tr("If you add <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()); + return tips; } - - // --- WelcomeModeButton WelcomeModeButton::WelcomeModeButton(QWidget *parent) : diff --git a/src/plugins/coreplugin/welcomemode.h b/src/plugins/coreplugin/welcomemode.h index ecdf2cbe50b..49306df611b 100644 --- a/src/plugins/coreplugin/welcomemode.h +++ b/src/plugins/coreplugin/welcomemode.h @@ -86,10 +86,12 @@ private slots: void slotSessionClicked(const QString &data); void slotProjectClicked(const QString &data); void slotUrlClicked(const QString &data); + void slotNextTip(); + void slotPrevTip(); private: void activateEditMode(); - QString getTipOfTheDay(); + QStringList tipsOfTheDay(); WelcomeModePrivate *m_d; }; diff --git a/src/plugins/coreplugin/welcomemode.ui b/src/plugins/coreplugin/welcomemode.ui index f477411bbde..b1e6fcce539 100644 --- a/src/plugins/coreplugin/welcomemode.ui +++ b/src/plugins/coreplugin/welcomemode.ui @@ -15,11 +15,14 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(215, 215, 215, 255)); }</string> </property> - <layout class="QGridLayout" name="gridLayout_4"> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <property name="spacing"> + <number>0</number> + </property> <property name="margin"> <number>0</number> </property> - <item row="0" column="0"> + <item> <widget class="QWidget" name="gradientWidget" native="true"> <property name="styleSheet"> <string>#gradientWidget { @@ -27,6 +30,12 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 }</string> </property> <layout class="QGridLayout" name="gridLayout"> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> <item row="0" column="1"> <spacer name="verticalSpacer_3"> <property name="orientation"> @@ -137,7 +146,7 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 <bool>false</bool> </property> <property name="styleSheet"> - <string>#navFrame QToolButton { + <string notr="true">#navFrame QToolButton { border: none; font-size: 10pt; color: grey; @@ -147,9 +156,9 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 color: black; } -#navFrame QToolButton:checked { +#navFrame QToolButton:checked { color: black; - border-bottom: 1px solid palette(Text); + border-bottom: 1px solid ; }</string> </property> <property name="frameShape"> @@ -210,7 +219,7 @@ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 <item> <widget class="QStackedWidget" name="stackedWidget"> <property name="currentIndex"> - <number>2</number> + <number>0</number> </property> <widget class="QWidget" name="page"> <widget class="QFrame" name="recentProjectsFrame_2"> @@ -332,42 +341,84 @@ p, li { white-space: pre-wrap; } <property name="styleSheet"> <string/> </property> - <layout class="QGridLayout" name="gridLayout_7"> - <item row="0" column="0"> - <widget class="QLabel" name="projTitleLabel_3"> - <property name="text"> - <string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + <widget class="QLabel" name="projTitleLabel_3"> + <property name="geometry"> + <rect> + <x>10</x> + <y>10</y> + <width>251</width> + <height>36</height> + </rect> + </property> + <property name="text"> + <string notr="true"><!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <p style=" margin-top:16px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:x-large; color:#555555;">Did you know?</span></p> <hr /></body></html></string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QTextBrowser" name="didYouKnowTextBrowser"> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> - <property name="verticalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - <property name="horizontalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - <property name="openExternalLinks"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + <widget class="QTextBrowser" name="didYouKnowTextBrowser"> + <property name="geometry"> + <rect> + <x>9</x> + <y>51</y> + <width>256</width> + <height>131</height> + </rect> + </property> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Plain</enum> + </property> + <property name="verticalScrollBarPolicy"> + <enum>Qt::ScrollBarAlwaysOff</enum> + </property> + <property name="horizontalScrollBarPolicy"> + <enum>Qt::ScrollBarAlwaysOff</enum> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + <widget class="QWidget" name=""> + <property name="geometry"> + <rect> + <x>210</x> + <y>14</y> + <width>51</width> + <height>20</height> + </rect> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QToolButton" name="prevTipBtn"> + <property name="text"> + <string><</string> + </property> + <property name="arrowType"> + <enum>Qt::LeftArrow</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="nextTipBtn"> + <property name="text"> + <string>></string> + </property> + <property name="arrowType"> + <enum>Qt::RightArrow</enum> + </property> + </widget> + </item> + </layout> + </widget> </widget> <widget class="QFrame" name="recentProjectsFrame_4"> <property name="geometry"> @@ -401,7 +452,7 @@ p, li { white-space: pre-wrap; } <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:16px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:x-large; color:#555555;">Explore Demos and Examples</span></p> +<p style=" margin-top:16px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:x-large; color:#555555;">Demos and Examples</span></p> <hr /></body></html></string> </property> <property name="alignment"> -- GitLab