summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Molkentin <daniel.molkentin@nokia.com>2010-04-29 14:08:09 +0200
committerDaniel Molkentin <daniel.molkentin@nokia.com>2010-04-29 14:39:26 +0200
commitc397a3c9e7443f050d700ef0956dbdff36c090fc (patch)
tree82c7db90572018a82ea12269767c5d5d29b17de2 /src
parent68cab5077481ab414a59b01785a4f0eeefdf0c13 (diff)
downloadqt-creator-c397a3c9e7443f050d700ef0956dbdff36c090fc.tar.gz
Add QML examples to welcome page
Reviewed-By: Jens Bache-Wiig
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp73
-rw-r--r--src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.h4
-rw-r--r--src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.ui491
3 files changed, 331 insertions, 237 deletions
diff --git a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp
index 8fc897abbf..816408cbe6 100644
--- a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp
+++ b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp
@@ -94,25 +94,20 @@ GettingStartedWelcomePageWidget::~GettingStartedWelcomePageWidget()
delete ui;
}
-void GettingStartedWelcomePageWidget::updateExamples(const QString &examplePath,
- const QString &demosPath,
- const QString &sourcePath)
+void GettingStartedWelcomePageWidget::updateCppExamples(const QString &examplePath,
+ const QString &sourcePath,
+ const QString &demoXml)
{
- QString demoxml = demosPath + "/qtdemo/xml/examples.xml";
- if (!QFile::exists(demoxml)) {
- demoxml = sourcePath + "/demos/qtdemo/xml/examples.xml";
- if (!QFile::exists(demoxml))
- return;
- }
- QFile description(demoxml);
+ QFile description(demoXml);
if (!description.open(QFile::ReadOnly))
return;
- ui->examplesButton->setEnabled(true);
- ui->examplesButton->setText(tr("Choose an example..."));
- QMenu *menu = new QMenu;
- ui->examplesButton->setMenu(menu);
+ ui->cppExamplesButton->setEnabled(true);;
+ ui->cppExamplesButton->setText(tr("Choose an example..."));
+
+ QMenu *menu = new QMenu(ui->cppExamplesButton);
+ ui->cppExamplesButton->setMenu(menu);
QMenu *subMenu = 0;
bool inExamples = false;
@@ -159,6 +154,48 @@ void GettingStartedWelcomePageWidget::updateExamples(const QString &examplePath,
}
}
+void GettingStartedWelcomePageWidget::updateQmlExamples(const QString &examplePath)
+{
+ QDir declarativeDir(examplePath + "/declarative");
+
+ if (!declarativeDir.exists())
+ return;
+
+ ui->qmlExamplesButton->setEnabled(true);;
+ ui->qmlExamplesButton->setText(tr("Choose an example..."));
+
+ QList<QFileInfo> examples = declarativeDir.entryInfoList(QStringList(), QDir::AllDirs|QDir::NoDotAndDotDot, QDir::Name);
+
+ QMenu *menu = new QMenu(ui->qmlExamplesButton);
+ ui->qmlExamplesButton->setMenu(menu);
+
+ foreach(const QFileInfo &example, examples) {
+ const QString exampleProject = example.absoluteFilePath()+'/'+example.fileName()+QLatin1String(".qmlproject");
+ if (QFile::exists(exampleProject)) {
+ QAction *exampleAction = menu->addAction(example.fileName());
+ connect(exampleAction, SIGNAL(triggered()), SLOT(slotOpenExample()));
+ exampleAction->setProperty(ExamplePathPropertyName, exampleProject);
+ // FIXME once we have help for QML examples
+ // exampleAction->setProperty(HelpPathPropertyName, helpPath);
+ }
+ }
+
+}
+
+void GettingStartedWelcomePageWidget::updateExamples(const QString &examplePath,
+ const QString &demosPath,
+ const QString &sourcePath)
+{
+ QString demoxml = demosPath + "/qtdemo/xml/examples.xml";
+ if (!QFile::exists(demoxml)) {
+ demoxml = sourcePath + "/demos/qtdemo/xml/examples.xml";
+ if (!QFile::exists(demoxml))
+ return;
+ }
+ updateCppExamples(examplePath, sourcePath, demoxml);
+ updateQmlExamples(examplePath);
+}
+
namespace {
void copyRecursive(const QDir& from, const QDir& to, const QString& dir)
@@ -250,10 +287,16 @@ void GettingStartedWelcomePageWidget::slotOpenExample()
files << proFile;
if(!QFile::exists(tryFile))
tryFile = proFileInfo.path() + '/' + proFileInfo.baseName() + ".cpp";
+ // maybe it's a QML project?
+ if(!QFile::exists(tryFile))
+ tryFile = proFileInfo.path() + '/' + "/main.qml";
+ if(!QFile::exists(tryFile))
+ tryFile = proFileInfo.path() + '/' + proFileInfo.baseName() + ".qml";
if(QFile::exists(tryFile))
files << tryFile;
Core::ICore::instance()->openFiles(files);
- slotOpenContextHelpPage(helpFile);
+ if (!helpFile.isEmpty())
+ slotOpenContextHelpPage(helpFile);
}
void GettingStartedWelcomePageWidget::slotOpenHelpPage(const QString& url)
diff --git a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.h b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.h
index d3b59b6254..872fc52f46 100644
--- a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.h
+++ b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.h
@@ -61,6 +61,10 @@ private slots:
private:
QStringList tipsOfTheDay();
+ void updateCppExamples(const QString &examplePath,
+ const QString &sourcePath,
+ const QString &demoXml);
+ void updateQmlExamples(const QString &examplePath);
Ui::GettingStartedWelcomePageWidget *ui;
int m_currentTip;
diff --git a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.ui b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.ui
index c62a653e6f..6cf9b13450 100644
--- a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.ui
+++ b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.ui
@@ -37,259 +37,305 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0">
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" rowspan="2">
- <widget class="QFrame" name="tutorialsFrame">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="styleSheet">
- <string/>
- </property>
- <layout class="QGridLayout" name="gridLayout_6">
- <property name="verticalSpacing">
- <number>12</number>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" rowspan="3">
+ <widget class="QFrame" name="tutorialsFrame">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="styleSheet">
+ <string/>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_6">
+ <property name="verticalSpacing">
+ <number>12</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="Utils::WelcomeModeLabel" name="tutorialsTitleLabel">
+ <property name="text">
+ <string>Tutorials</string>
</property>
- <item row="0" column="0">
- <widget class="Utils::WelcomeModeLabel" name="tutorialsTitleLabel">
- <property name="text">
- <string>Tutorials</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="Utils::WelcomeModeTreeWidget" name="tutorialTreeWidget"/>
- </item>
- </layout>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QFrame" name="demosExamplesFrame">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>400</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="styleSheet">
- <string/>
- </property>
- <layout class="QGridLayout" name="gridLayout_8">
- <property name="rightMargin">
- <number>8</number>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="Utils::WelcomeModeTreeWidget" name="tutorialTreeWidget" native="true"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QFrame" name="demosExamplesFrame">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>400</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string/>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="Utils::WelcomeModeLabel" name="demoTitleLabel">
+ <property name="text">
+ <string>Explore Qt C++ Examples</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cppExamplesButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>30</height>
+ </size>
</property>
- <property name="horizontalSpacing">
+ <property name="text">
+ <string>Examples not installed...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QFrame" name="demosExamplesFrame_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>400</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string/>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="Utils::WelcomeModeLabel" name="demoTitleLabel_2">
+ <property name="text">
+ <string>Explore Qt Quick Examples</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="qmlExamplesButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Examples not installed...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QFrame" name="didyouKnowFrame">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>400</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string/>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_11">
+ <property name="verticalSpacing">
+ <number>12</number>
+ </property>
+ <property name="rightMargin">
+ <number>9</number>
+ </property>
+ <item row="0" column="1">
+ <layout class="QGridLayout" name="gridLayout_10">
+ <property name="spacing">
<number>0</number>
</property>
- <item row="1" column="0">
- <widget class="Utils::WelcomeModeLabel" name="demoTitleLabel">
- <property name="text">
- <string>Explore Qt Examples</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QPushButton" name="examplesButton">
- <property name="enabled">
- <bool>false</bool>
+ <item row="0" column="0" colspan="2">
+ <spacer name="verticalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
</property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <property name="sizeType">
+ <enum>QSizePolicy::Preferred</enum>
</property>
- <property name="minimumSize">
+ <property name="sizeHint" stdset="0">
<size>
- <width>0</width>
- <height>30</height>
+ <width>20</width>
+ <height>13</height>
</size>
</property>
- <property name="text">
- <string>Examples not installed...</string>
- </property>
- </widget>
+ </spacer>
</item>
- </layout>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QFrame" name="didyouKnowFrame">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>400</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="styleSheet">
- <string/>
- </property>
- <layout class="QGridLayout" name="gridLayout_11">
- <property name="rightMargin">
- <number>9</number>
- </property>
- <property name="verticalSpacing">
- <number>12</number>
- </property>
- <item row="0" column="1">
- <layout class="QGridLayout" name="gridLayout_10">
- <property name="spacing">
- <number>0</number>
- </property>
- <item row="0" column="0" colspan="2">
- <spacer name="verticalSpacer_4">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Preferred</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>13</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="1">
- <widget class="QToolButton" name="nextTipBtn">
- <property name="styleSheet">
- <string notr="true">QToolButton{
+ <item row="1" column="1">
+ <widget class="QToolButton" name="nextTipBtn">
+ <property name="styleSheet">
+ <string notr="true">QToolButton{
border-left:solid 0 px;
height:16px;
width:12px;
}
</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../welcome/welcome.qrc">
- <normaloff>:/welcome/images/arrow-right.png</normaloff>:/welcome/images/arrow-right.png</iconset>
- </property>
- <property name="arrowType">
- <enum>Qt::NoArrow</enum>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QToolButton" name="prevTipBtn">
- <property name="styleSheet">
- <string notr="true">QToolButton{
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../welcome/welcome.qrc">
+ <normaloff>:/welcome/images/arrow-right.png</normaloff>:/welcome/images/arrow-right.png</iconset>
+ </property>
+ <property name="arrowType">
+ <enum>Qt::NoArrow</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QToolButton" name="prevTipBtn">
+ <property name="styleSheet">
+ <string notr="true">QToolButton{
border-right:solid 0 px;
height:16px;
width:12px;
}
</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../welcome/welcome.qrc">
- <normaloff>:/welcome/images/arrow-left.png</normaloff>:/welcome/images/arrow-left.png</iconset>
- </property>
- <property name="arrowType">
- <enum>Qt::NoArrow</enum>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="2">
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>13</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QTextBrowser" name="didYouKnowTextBrowser">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
</property>
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../welcome/welcome.qrc">
+ <normaloff>:/welcome/images/arrow-left.png</normaloff>:/welcome/images/arrow-left.png</iconset>
+ </property>
+ <property name="arrowType">
+ <enum>Qt::NoArrow</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
</property>
- <property name="frameShadow">
- <enum>QFrame::Plain</enum>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>13</height>
+ </size>
</property>
- <property name="verticalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QTextBrowser" name="didYouKnowTextBrowser">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </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>
+ </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="horizontalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
</property>
- <property name="openExternalLinks">
- <bool>true</bool>
+ </spacer>
+ </item>
+ <item>
+ <widget class="Utils::WelcomeModeLabel" name="didYouKnowTitleLabel">
+ <property name="text">
+ <string>Did You Know?</string>
</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>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
</item>
</layout>
- </widget>
- </item>
- </layout>
+ </item>
+ </layout>
+ </widget>
</item>
- <item row="1" column="0">
+ <item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>6</number>
@@ -342,6 +388,7 @@
<class>Utils::WelcomeModeTreeWidget</class>
<extends>QWidget</extends>
<header location="global">utils/welcomemodetreewidget.h</header>
+ <container>1</container>
</customwidget>
<customwidget>
<class>Utils::WelcomeModeLabel</class>