summaryrefslogtreecommitdiff
path: root/src/plugins/welcome
diff options
context:
space:
mode:
authorDaniel Molkentin <daniel.molkentin@nokia.com>2009-07-23 20:01:35 +0200
committerDaniel Molkentin <daniel.molkentin@nokia.com>2009-07-28 12:05:27 +0200
commitc8be3a3ea2ffe569515691a43251839e283c9325 (patch)
treec72df6c9e9f0fba88696d667db09f75f4c5f7832 /src/plugins/welcome
parent4f5ce66d50cb6d71693d56d8186d7b0e86aab802 (diff)
downloadqt-creator-c8be3a3ea2ffe569515691a43251839e283c9325.tar.gz
Preparation for plugifying the welcome screen.
Move WelcomeModeTreeWidget to utils, add d-ptr.
Diffstat (limited to 'src/plugins/welcome')
-rw-r--r--src/plugins/welcome/welcome.pro15
-rw-r--r--src/plugins/welcome/welcomemode.cpp104
-rw-r--r--src/plugins/welcome/welcomemode.ui16
-rw-r--r--src/plugins/welcome/welcomemode_p.h89
4 files changed, 14 insertions, 210 deletions
diff --git a/src/plugins/welcome/welcome.pro b/src/plugins/welcome/welcome.pro
index 51e66a573f..11d48e82bc 100644
--- a/src/plugins/welcome/welcome.pro
+++ b/src/plugins/welcome/welcome.pro
@@ -3,20 +3,13 @@ TARGET = Welcome
QT += network
include(../../qtcreatorplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
-
HEADERS += welcomeplugin.h \
- welcomemode.h \
- welcomemode_p.h \
- rssfetcher.h
-
+ welcomemode.h \
+ rssfetcher.h
SOURCES += welcomeplugin.cpp \
- welcomemode.cpp \
- rssfetcher.cpp
-
+ welcomemode.cpp \
+ rssfetcher.cpp
FORMS += welcomemode.ui
-
RESOURCES += welcome.qrc
-
DEFINES += WELCOME_LIBRARY
-
OTHER_FILES += Welcome.pluginspec
diff --git a/src/plugins/welcome/welcomemode.cpp b/src/plugins/welcome/welcomemode.cpp
index 0035fefe7b..bc6a876828 100644
--- a/src/plugins/welcome/welcomemode.cpp
+++ b/src/plugins/welcome/welcomemode.cpp
@@ -39,10 +39,12 @@
#include <coreplugin/dialogs/newdialog.h>
#include <utils/styledbar.h>
+#include <utils/welcomemodetreewidget.h>
#include <QtGui/QDesktopServices>
#include <QtGui/QMouseEvent>
#include <QtGui/QScrollArea>
+#include <QtGui/QButtonGroup>
#include <QtCore/QDateTime>
#include <QtCore/QDir>
@@ -469,106 +471,4 @@ QStringList WelcomeMode::tipsOfTheDay()
return tips;
}
-// --- WelcomeModeButton
-
-WelcomeModeButton::WelcomeModeButton(QWidget *parent) :
- QLabel(parent),
- m_isPressed(false),
- m_isInited(false)
-{
- setCursor(QCursor(Qt::PointingHandCursor));
-}
-
-void WelcomeModeButton::mousePressEvent(QMouseEvent *event)
-{
- if (event->button() == Qt::LeftButton)
- m_isPressed = true;
-}
-
-void WelcomeModeButton::mouseReleaseEvent(QMouseEvent *event)
-{
- if (event->button() == Qt::LeftButton && m_isPressed) {
- m_isPressed = false;
- if (rect().contains(event->pos()))
- emit clicked();
- }
-}
-
-void WelcomeModeButton::enterEvent(QEvent *)
-{
- if (!m_isInited) {
- m_isInited = true;
- m_text = text();
- m_hoverText = m_text;
- m_hoverText.replace(QLatin1String(".png"), QLatin1String("_hover.png"));
- if (m_text == m_hoverText) {
- m_text.clear();
- m_hoverText.clear();
- }
- }
- if (!m_hoverText.isEmpty())
- setText(m_hoverText);
-}
-
-void WelcomeModeButton::leaveEvent(QEvent *)
-{
- if (!m_text.isEmpty())
- setText(m_text);
-}
-
-// --- WelcomeModeTreeWidget
-
-WelcomeModeTreeWidget::WelcomeModeTreeWidget(QWidget *parent) :
- QTreeWidget(parent),
- m_bullet(QLatin1String(":/welcome/images/list_bullet_arrow.png"))
-{
- connect(this, SIGNAL(itemClicked(QTreeWidgetItem *, int)),
- SLOT(slotItemClicked(QTreeWidgetItem *)));
-}
-
-QSize WelcomeModeTreeWidget::minimumSizeHint() const
-{
- return QSize();
-}
-
-QSize WelcomeModeTreeWidget::sizeHint() const
-{
- return QSize(QTreeWidget::sizeHint().width(), 30 * topLevelItemCount());
-}
-
-QTreeWidgetItem *WelcomeModeTreeWidget::addItem(const QString &label, const QString &data)
-{
- QTreeWidgetItem *item = new QTreeWidgetItem(this);
- item->setIcon(0, m_bullet);
- item->setSizeHint(0, QSize(24, 30));
- QLabel *lbl = new QLabel(label);
- lbl->setTextInteractionFlags(Qt::NoTextInteraction);
- lbl->setCursor(QCursor(Qt::PointingHandCursor));
- lbl->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- QBoxLayout *lay = new QVBoxLayout;
- lay->setContentsMargins(3, 2, 0, 0);
- lay->addWidget(lbl);
- QWidget *wdg = new QWidget;
- wdg->setLayout(lay);
- setItemWidget(item, 1, wdg);
- item->setData(0, Qt::UserRole, data);
- return item;
-}
-
-void WelcomeModeTreeWidget::slotAddNewsItem(const QString &title, const QString &description, const QString &link)
-{
- 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("<b>%1</b><br />%2").arg(elidedTitle).arg(elidedText);
- addTopLevelItem(addItem(data,link));
-}
-
-void WelcomeModeTreeWidget::slotItemClicked(QTreeWidgetItem *item)
-{
- emit activated(item->data(0, Qt::UserRole).toString());
-}
-
} // namespace Welcome
diff --git a/src/plugins/welcome/welcomemode.ui b/src/plugins/welcome/welcomemode.ui
index 8a70b233ea..c70aabbafa 100644
--- a/src/plugins/welcome/welcomemode.ui
+++ b/src/plugins/welcome/welcomemode.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Welcome::WelcomePage</class>
- <widget class="QWidget" name="Welcome::WelcomePage">
+ <widget class="QWidget" name="Core::Utils::WelcomePage">
<property name="geometry">
<rect>
<x>0</x>
@@ -417,7 +417,7 @@ QToolButton:pressed {
</widget>
</item>
<item row="1" column="0">
- <widget class="Welcome::WelcomeModeTreeWidget" name="tutorialTreeWidget">
+ <widget class="Core::Utils::WelcomeModeTreeWidget" name="tutorialTreeWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -746,7 +746,7 @@ QToolButton:pressed {
</widget>
</item>
<item row="1" column="0" colspan="3">
- <widget class="Welcome::WelcomeModeTreeWidget" name="sessTreeWidget">
+ <widget class="Core::Utils::WelcomeModeTreeWidget" name="sessTreeWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -853,7 +853,7 @@ QToolButton:pressed {
</widget>
</item>
<item row="1" column="0" colspan="3">
- <widget class="Welcome::WelcomeModeTreeWidget" name="projTreeWidget">
+ <widget class="Core::Utils::WelcomeModeTreeWidget" name="projTreeWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -967,7 +967,7 @@ QToolButton:pressed {
</widget>
</item>
<item>
- <widget class="Welcome::WelcomeModeTreeWidget" name="newsTreeWidget">
+ <widget class="Core::Utils::WelcomeModeTreeWidget" name="newsTreeWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -1051,7 +1051,7 @@ QToolButton:pressed {
</widget>
</item>
<item>
- <widget class="Welcome::WelcomeModeTreeWidget" name="sitesTreeWidget">
+ <widget class="Core::Utils::WelcomeModeTreeWidget" name="sitesTreeWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -1221,9 +1221,9 @@ QToolButton:pressed {
</widget>
<customwidgets>
<customwidget>
- <class>Welcome::WelcomeModeTreeWidget</class>
+ <class>Core::Utils::WelcomeModeTreeWidget</class>
<extends>QTreeWidget</extends>
- <header>welcomemode_p.h</header>
+ <header>utils/welcomemodetreewidget.h</header>
</customwidget>
</customwidgets>
<resources>
diff --git a/src/plugins/welcome/welcomemode_p.h b/src/plugins/welcome/welcomemode_p.h
deleted file mode 100644
index efe80b3685..0000000000
--- a/src/plugins/welcome/welcomemode_p.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-**
-**************************************************************************/
-
-#ifndef WELCOMEMODE_P_H
-#define WELCOMEMODE_P_H
-
-#include <QtGui/QIcon>
-#include <QtGui/QLabel>
-#include <QtGui/QTreeWidget>
-
-namespace Welcome {
-
-class WelcomeModeButton : public QLabel
-{
- Q_OBJECT
-
-public:
- WelcomeModeButton(QWidget *parent = 0);
-
-signals:
- void clicked();
-
-protected:
- virtual void mousePressEvent(QMouseEvent *event);
- virtual void mouseReleaseEvent(QMouseEvent *event);
- virtual void enterEvent(QEvent *event);
- virtual void leaveEvent(QEvent *event);
-
-private:
- bool m_isPressed;
- bool m_isInited;
- QString m_text;
- QString m_hoverText;
-};
-
-class WelcomeModeTreeWidget : public QTreeWidget
-{
- Q_OBJECT
-
-public:
- WelcomeModeTreeWidget(QWidget *parent = 0);
- QTreeWidgetItem *addItem(const QString &label, const QString &data);
-
-public slots:
- void slotAddNewsItem(const QString &title, const QString &description, const QString &link);
-
-signals:
- void activated(const QString &data);
-
-protected:
- virtual QSize minimumSizeHint() const;
- virtual QSize sizeHint() const;
-
-private slots:
- void slotItemClicked(QTreeWidgetItem *item);
-
-private:
- QIcon m_bullet;
-};
-
-}
-
-#endif // WELCOMEMODE_P_H