Commit ef926c63 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

WelcomeModeLabel: Make usable in Designer as a normal 'styled' label.

Remove HTML-formatting and replace by properties set in constructor.
Use in forms.
parent 3a9e7530
......@@ -45,26 +45,24 @@ enum { leftContentsMargin = 2,
namespace Utils {
WelcomeModeLabel::WelcomeModeLabel(QWidget *parent) :
QLabel(parent)
QLabel(parent), m_unused(0)
{
// Bold/enlarged font slightly gray. Force color on by stylesheet as it is used
// as a child of widgets that have stylesheets.
QFont f = font();
#ifndef Q_OS_WIN
f.setWeight(QFont::DemiBold);
#endif
f.setPointSizeF(f.pointSizeF() * 1.2);
setFont(f);
setStyleSheet(QLatin1String("color : rgb(85, 85, 85);"));
setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
}
WelcomeModeLabel::~WelcomeModeLabel()
{
}
void WelcomeModeLabel::setStyledText(const QString &text)
{
QString rc = QLatin1String(
"<html><head><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head>"
"<body style=\" font-weight:500; 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:large; color:#555555;\">");
rc += text;
rc += QLatin1String("</span></p></body></html>");
setText(rc);
}
// NewsLabel for the WelcomeModeTreeWidget:
// Shows a news article as "Bold Title!\nElided Start of article...."
// Adapts the eliding when resizing.
......
......@@ -38,9 +38,9 @@
namespace Utils {
struct WelcomeModeTreeWidgetPrivate;
struct WelcomeModeLabelPrivate;
class WelcomeModeItemWidget;
// Label usable for headers of a Welcome page.
class QTCREATOR_UTILS_EXPORT WelcomeModeLabel : public QLabel
{
Q_OBJECT
......@@ -48,10 +48,8 @@ public:
explicit WelcomeModeLabel(QWidget *parent = 0);
virtual ~WelcomeModeLabel();
void setStyledText(const QString &text);
private:
WelcomeModeLabelPrivate *m_d;
void *m_unused;
};
// WelcomeModeTreeWidget: Show an itemized list with arrows and emits a signal on click.
......
......@@ -78,8 +78,6 @@ ProjectWelcomePageWidget::ProjectWelcomePageWidget(QWidget *parent) :
ui(new Ui::ProjectWelcomePageWidget)
{
ui->setupUi(this);
ui->projTitleLabel->setStyledText(tr("Recent Projects"));
ui->recentSessionsTitleLabel->setStyledText(tr("Resume Session"));
updateWelcomePage(WelcomePageData());
connect(ui->sessTreeWidget, SIGNAL(activated(QString)), SLOT(slotSessionClicked(QString)));
......
......@@ -2,14 +2,6 @@
<ui version="4.0">
<class>ProjectExplorer::Internal::ProjectWelcomePageWidget</class>
<widget class="QWidget" name="ProjectExplorer::Internal::ProjectWelcomePageWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>639</width>
<height>322</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
......@@ -28,9 +20,6 @@
</property>
<item>
<widget class="QFrame" name="contentframe">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
......@@ -42,33 +31,23 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QFrame" name="recentProjectsFrame">
<property name="styleSheet">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<property name="rightMargin">
<number>9</number>
</property>
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>3</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<item row="3" column="0" colspan="3">
<widget class="Utils::WelcomeModeTreeWidget" name="projTreeWidget">
</widget>
<widget class="Utils::WelcomeModeTreeWidget" name="projTreeWidget"/>
</item>
<item row="1" column="0" colspan="3">
<widget class="Utils::WelcomeModeLabel" name="projTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<property name="text">
<string>Recent Projects</string>
</property>
</widget>
</item>
......@@ -89,9 +68,6 @@
<height>130</height>
</size>
</property>
<property name="styleSheet">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="horizontalSpacing">
<number>0</number>
......@@ -107,14 +83,16 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Resume Session</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="Utils::WelcomeModeTreeWidget" name="sessTreeWidget">
</widget>
<widget class="Utils::WelcomeModeTreeWidget" name="sessTreeWidget"/>
</item>
</layout>
</widget>
......@@ -189,12 +167,12 @@
<customwidget>
<class>Utils::WelcomeModeTreeWidget</class>
<extends>QWidget</extends>
<header>utils/welcomemodetreewidget.h</header>
<header location="global">utils/welcomemodetreewidget.h</header>
</customwidget>
<customwidget>
<class>Utils::WelcomeModeLabel</class>
<extends>QLabel</extends>
<header>utils/welcomemodetreewidget.h</header>
<header location="global">utils/welcomemodetreewidget.h</header>
</customwidget>
</customwidgets>
<resources>
......
......@@ -64,10 +64,7 @@ GettingStartedWelcomePageWidget::GettingStartedWelcomePageWidget(QWidget *parent
ui(new Ui::GettingStartedWelcomePageWidget)
{
ui->setupUi(this);
ui->tutorialsTitleLabel->setStyledText(tr("Tutorials"));
ui->demoTitleLabel->setStyledText(tr("Explore Qt Examples"));
ui->didYouKnowTextBrowser->viewport()->setAutoFillBackground(false);
ui->didYouKnowTitleLabel->setStyledText(tr("Did You Know?"));
connect(ui->tutorialTreeWidget, SIGNAL(activated(QString)), SLOT(slotOpenHelpPage(const QString&)));
......
......@@ -57,20 +57,13 @@
</property>
<item row="0" column="0">
<widget class="Utils::WelcomeModeLabel" name="tutorialsTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<property name="text">
<string>Tutorials</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Utils::WelcomeModeTreeWidget" name="tutorialTreeWidget">
</widget>
<widget class="Utils::WelcomeModeTreeWidget" name="tutorialTreeWidget"/>
</item>
</layout>
</widget>
......@@ -101,8 +94,8 @@
</property>
<item row="1" column="0">
<widget class="Utils::WelcomeModeLabel" name="demoTitleLabel">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<property name="text">
<string>Explore Qt Examples</string>
</property>
</widget>
</item>
......@@ -155,19 +148,6 @@
<property name="verticalSpacing">
<number>12</number>
</property>
<item row="0" column="0">
<widget class="Utils::WelcomeModeLabel" name="didYouKnowTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_10">
<property name="spacing">
......@@ -273,6 +253,37 @@
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Utils::WelcomeModeLabel" name="didYouKnowTitleLabel">
<property name="text">
<string>Did You Know?</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
......@@ -330,12 +341,12 @@
<customwidget>
<class>Utils::WelcomeModeTreeWidget</class>
<extends>QWidget</extends>
<header>utils/welcomemodetreewidget.h</header>
<header location="global">utils/welcomemodetreewidget.h</header>
</customwidget>
<customwidget>
<class>Utils::WelcomeModeLabel</class>
<extends>QLabel</extends>
<header>utils/welcomemodetreewidget.h</header>
<header location="global">utils/welcomemodetreewidget.h</header>
</customwidget>
</customwidgets>
<resources>
......
......@@ -84,9 +84,6 @@ CommunityWelcomePageWidget::CommunityWelcomePageWidget(QWidget *parent) :
ui(new Ui::CommunityWelcomePageWidget)
{
ui->setupUi(this);
ui->labsTitleLabel->setStyledText(tr("News From the Qt Labs"));
ui->supportSitesTitleLabel->setStyledText(tr("Qt Support Sites"));
ui->miscSitesTitleLabel->setStyledText(tr("Qt Links"));
connect(ui->newsTreeWidget, SIGNAL(activated(QString)), SLOT(slotUrlClicked(QString)));
connect(ui->miscSitesTreeWidget, SIGNAL(activated(QString)), SLOT(slotUrlClicked(QString)));
......
......@@ -54,20 +54,13 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="Utils::WelcomeModeLabel" name="labsTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<property name="text">
<string>News From the Qt Labs</string>
</property>
</widget>
</item>
<item>
<widget class="Utils::WelcomeModeTreeWidget" name="newsTreeWidget">
</widget>
<widget class="Utils::WelcomeModeTreeWidget" name="newsTreeWidget"/>
</item>
</layout>
</widget>
......@@ -83,37 +76,23 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="Utils::WelcomeModeLabel" name="supportSitesTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<property name="text">
<string>Qt Support Sites</string>
</property>
</widget>
</item>
<item>
<widget class="Utils::WelcomeModeTreeWidget" name="supportSitesTreeWidget">
</widget>
<widget class="Utils::WelcomeModeTreeWidget" name="supportSitesTreeWidget"/>
</item>
<item>
<widget class="Utils::WelcomeModeLabel" name="miscSitesTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<property name="text">
<string>Qt Links</string>
</property>
</widget>
</item>
<item>
<widget class="Utils::WelcomeModeTreeWidget" name="miscSitesTreeWidget">
</widget>
<widget class="Utils::WelcomeModeTreeWidget" name="miscSitesTreeWidget"/>
</item>
</layout>
</widget>
......@@ -127,12 +106,12 @@
<customwidget>
<class>Utils::WelcomeModeTreeWidget</class>
<extends>QWidget</extends>
<header>utils/welcomemodetreewidget.h</header>
<header location="global">utils/welcomemodetreewidget.h</header>
</customwidget>
<customwidget>
<class>Utils::WelcomeModeLabel</class>
<extends>QLabel</extends>
<header>utils/welcomemodetreewidget.h</header>
<header location="global">utils/welcomemodetreewidget.h</header>
</customwidget>
</customwidgets>
<resources/>
......
......@@ -244,6 +244,17 @@ QWidget *WelcomePageWidget_CW::createWidget(QWidget *parent)
return rc;
}
WelcomeModeLabel_CW::WelcomeModeLabel_CW(QObject *parent) :
QObject(parent),
CustomWidget<Utils::WelcomeModeLabel>
(QLatin1String("<utils/welcomemodetreewidget.h>"),
false,
QLatin1String(groupC),
QIcon(),
QLatin1String("Welcome page header label"))
{
}
DetailsWidget_CW::DetailsWidget_CW(QObject *parent) :
QObject(parent),
CustomWidget<Utils::DetailsWidget>
......@@ -370,6 +381,7 @@ WidgetCollection::WidgetCollection(QObject *parent) :
m_plugins.push_back(new StyledSeparator_CW(this));
m_plugins.push_back(new Wizard_CW(this));
m_plugins.push_back(new WelcomePageWidget_CW(this));
m_plugins.push_back(new WelcomeModeLabel_CW(this));
}
QList<QDesignerCustomWidgetInterface*> WidgetCollection::customWidgets() const
......
......@@ -235,6 +235,17 @@ public:
virtual QWidget *createWidget(QWidget *parent);
};
class WelcomeModeLabel_CW :
public QObject,
public CustomWidget<Utils::WelcomeModeLabel>
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
explicit WelcomeModeLabel_CW(QObject *parent = 0);
};
// Details Widget: plugin + simple, hacky container extension that
// accepts only one page.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment