1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

Bug 418406: Qt4 and Qt5 specific HelloWorld project wizards

This replaces the QtQuick2 project wizard with Qt4 and Qt5 wizards that
include the old content as well as:

1) Make targets to build and clean the project
2) Sample interaction between C++ and QML
3) A Qt header path provider so that paths from the Qt installation are
properly resolved in the project.

Item 3 is particularly important for using the 'New Class' wizard with
QObject as the base class.  Unless the Qt paths are pre-populated the
QObject base class will not be found and the New Class wizard's Finish
button will be disabled.

The Qt headers are resolved by running `qmake -query QT_INSTALL_HEADERS`
and then creating IncludePath entries for all sub-folders.  This list of
include paths is persisted with other shared language settings into a
file in the workspace metadata area.

The persisted data is reloaded when any of the following change:
- the modification time of the qmake binary
- the modification time of the reported QT_INSTALL_HEADERS folder

The persisted node is ignored when the target qmake binary no longer
exists.  The node is removed from the persisted form the next time that
the shared settings are persisted.

Change-Id: Ic82fdb147e6a69060f93e2e9aed2e919139a0ae9
Signed-off-by: Andrew Eidsness <eclipse@jfront.com>
Reviewed-on: https://git.eclipse.org/r/16909
Reviewed-by: Doug Schaefer <dschaefer@qnx.com>
IP-Clean: Doug Schaefer <dschaefer@qnx.com>
Tested-by: Doug Schaefer <dschaefer@qnx.com>
This commit is contained in:
Andrew Eidsness 2013-10-23 07:12:25 -04:00 committed by Doug Schaefer
parent 778e234e67
commit 45c388b77e
27 changed files with 968 additions and 157 deletions

View file

@ -1,3 +1,10 @@
# Copyright (c) 2013 QNX Software Systems and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
qtProjectFile.name = Qt Project File
qmlFile.name = QML File
qmakeEnvProvider.name = QMake Environment Provider
QtInstallHeaders.pathProvider.name = Qt Installed Headers

View file

@ -7,22 +7,33 @@
point="org.eclipse.cdt.core.templates">
<template
filterPattern=".*g\+\+"
id="org.eclipse.cdt.qt.core.template.helloWorld.qtQuick2"
location="templates/project/helloWorld/qtQuick2/template.xml"
projectType="org.eclipse.cdt.build.makefile.projectType">
</template>
id="org.eclipse.cdt.qt.core.template.helloWorld.Qt4"
location="templates/project/Qt4/template.xml"
projectType="org.eclipse.cdt.build.makefile.projectType"/>
<template
filterPattern=".*g\+\+"
id="org.eclipse.cdt.qt.core.template.helloWorld.Qt5"
location="templates/project/Qt5/template.xml"
projectType="org.eclipse.cdt.build.makefile.projectType"/>
</extension>
<extension
point="org.eclipse.cdt.core.templateAssociations">
<template id="org.eclipse.cdt.qt.core.template.helloWorld.qtQuick2">
<template id="org.eclipse.cdt.qt.core.template.helloWorld.Qt4">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.solaris.base"/>
<toolChain id="cdt.managedbuild.toolchain.llvm.clang.macosx.base">
</toolChain>
<toolChain id="cdt.managedbuild.toolchain.llvm.clang.macosx.base"/>
</template>
<template id="org.eclipse.cdt.qt.core.template.helloWorld.Qt5">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.solaris.base"/>
<toolChain id="cdt.managedbuild.toolchain.llvm.clang.macosx.base"/>
</template>
</extension>
<extension
@ -71,4 +82,13 @@
id="Qt"
class="org.eclipse.cdt.qt.internal.core.pdom.PDOMQtLinkageFactory"/>
</extension>
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider
class="org.eclipse.cdt.qt.internal.core.QtIncludePathsProvider"
id="org.eclipse.cdt.qt.core.QtPathsProvider"
name="%QtInstallHeaders.pathProvider.name"
prefer-non-shared="false">
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</plugin>

View file

@ -7,6 +7,7 @@
*/
package org.eclipse.cdt.qt.core;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.QualifiedName;
@ -51,22 +52,29 @@ public class QtPlugin extends Plugin {
return new Status(IStatus.ERROR, ID, msg, e);
}
public static IStatus log(String e) {
return log(IStatus.INFO, e, null);
public static void log(String e) {
log(IStatus.INFO, e, null);
}
public static IStatus log(Throwable e) {
String msg = e.getMessage();
return msg == null ? log("Error", e) : log("Error: " + msg, e);
public static void log(Throwable e) {
String msg= e.getMessage();
if (msg == null) {
log("Error", e); //$NON-NLS-1$
} else {
log("Error: " + msg, e); //$NON-NLS-1$
}
}
public static IStatus log(String message, Throwable e) {
return log(IStatus.ERROR, message, e);
public static void log(String message, Throwable e) {
Throwable nestedException;
if (e instanceof CModelException
&& (nestedException = ((CModelException)e).getException()) != null) {
e = nestedException;
}
log(IStatus.ERROR, message, e);
}
public static IStatus log(int code, String msg, Throwable e) {
IStatus status = new Status(code, ID, msg, e);
instance.getLog().log(status);
return status;
public static void log(int code, String msg, Throwable e) {
getDefault().getLog().log(new Status(code, ID, msg, e));
}
}

View file

@ -0,0 +1,282 @@
/*
* Copyright (c) 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.cdt.qt.internal.core;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.qt.core.QtPlugin;
import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.eclipse.core.resources.IResource;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
/**
* Discovers and persists the list of Qt include paths for a particular installation of
* Qt. The Qt installation is described by the path to qmake.
* <p>
* Qt uses a tool called qmake to generate makefiles for Qt projects. The tool has a
* query mode that can be used to discover information about the Qt installation. Here
* qmake is used to build a list of all installed Qt include paths.
* <p>
* These paths are persisted into a file called language-settings.xml in the workspace
* metadata area.
*
* @see QtIncludePathsProvider
*/
public class QtIncludePaths extends LanguageSettingsSerializableProvider {
/**
* The path to the qmake executable uniquely identifies this installation.
*/
private final String qmakePath;
/**
* The cached data is reloaded when the qmake executable is modified.
*/
private long qmakeModTime;
/**
* The cached data is reloaded when the folder holding the include paths
* is removed.
*/
private String qtInstallHeadersPath;
/**
* The cached data is reloaded when the folder containing the include folders is
* modified.
*/
private long qtInstallHeadersModTime;
private static final String ATTR_QMAKE = "qmake";
private static final String ATTR_QMAKE_MOD = "qmakeModification";
private static final String ATTR_QT_INSTALL_HEADERS = "QT_INSTALL_HEADERS";
private static final String ATTR_QT_INSTALL_HEADERS_MOD = "qtInstallHeadersModification";
/**
* Create a new instance of the include path wrapper for the Qt installation for
* the given qmake binary.
*/
public QtIncludePaths(String qmakePath) {
this.qmakePath = qmakePath;
}
/**
* Create and load an instance of QtIncludePaths from data that was serialized into the
* given XML element. Return null if an instance cannot be loaded or if the installation
* is no longer valid.
*/
public static QtIncludePaths loadFrom(Node node) {
if (node.getNodeType() != Node.ELEMENT_NODE)
return null;
Element element = (Element) node;
String qmakePath = element.getAttribute(ATTR_QMAKE);
if (qmakePath == null
|| qmakePath.isEmpty())
return null;
QtIncludePaths qtIncludePaths = new QtIncludePaths(qmakePath);
qtIncludePaths.load(element);
return qtIncludePaths;
}
public String getQMakePath() {
return qmakePath;
}
/**
* Return true if the receiver points to a valid Qt installation and false otherwise.
* The installation is considered valid if an executable qmake binary exists at the
* expected location.
*/
public boolean isValid() {
if (qmakePath == null
|| qmakePath.isEmpty())
return false;
File qmake = new File(qmakePath);
return qmake.exists()
&& qmake.canExecute();
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof QtIncludePaths))
return super.equals(obj);
// Include paths are equivalent when they point to the same qmake binary. All other
// values are reloaded from that binary and do not need to be directly compared.
QtIncludePaths other = (QtIncludePaths) obj;
return qmakePath == null ? other.qmakePath == null : qmakePath.equals(other.qmakePath);
}
@Override
public int hashCode() {
return qmakePath == null ? 0 : qmakePath.hashCode();
}
/**
* Return a current list of the include paths for this Qt installation. Return null if
* no such paths can be found.
* <p>
* Updates the cached results if needed. If the settings are updated then the new list
* will be serialized into the workspace metadata area.
*/
@Override
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription configDesc, IResource rc, String languageId) {
List<ICLanguageSettingEntry> entries = null;
File qmake = new File(qmakePath);
if (!qmake.exists()
|| qmakeModTime != qmake.lastModified())
entries = reload();
else {
File qtInstallHeadersDir = new File(qtInstallHeadersPath);
if (!qtInstallHeadersDir.exists()
|| qtInstallHeadersModTime != qtInstallHeadersDir.lastModified())
entries = reload();
}
// If the cache was not reloaded, then return the previously discovered entries.
if (entries == null)
return super.getSettingEntries(configDesc, rc, languageId);
// Otherwise store, persist, and return the newly discovered values.
setSettingEntries(configDesc, rc, languageId, entries);
serializeLanguageSettingsInBackground(null);
return entries;
}
@Override
public Element serializeAttributes(Element parentElement) {
parentElement.setAttribute(ATTR_QMAKE, qmakePath);
parentElement.setAttribute(ATTR_QMAKE_MOD, Long.toString(qmakeModTime));
parentElement.setAttribute(ATTR_QT_INSTALL_HEADERS, qtInstallHeadersPath);
parentElement.setAttribute(ATTR_QT_INSTALL_HEADERS_MOD, Long.toString(qtInstallHeadersModTime));
// The parent implementation tries to create a new child node (provider) that is used
// as the part for later entries. This isn't needed in this case, we just want to
// use the part that serializes the languages.
return parentElement;
}
@Override
public void loadAttributes(Element element) {
qmakeModTime = getLongAttribute(element, ATTR_QMAKE_MOD);
qtInstallHeadersPath = element.getAttribute(ATTR_QT_INSTALL_HEADERS);
qtInstallHeadersModTime = getLongAttribute(element, ATTR_QT_INSTALL_HEADERS_MOD);
// The parent implementation tries to create a new child node (provider) that is used
// as the part for later entries. This isn't needed in this case, we just want to
// use the part that serializes the languages.
}
/**
* Parse and return the given attribute as a long. Return 0 if the attribute does
* not have a valid value.
*/
private static long getLongAttribute(Element element, String attr) {
String value = element.getAttribute(attr);
if (value == null
|| value.isEmpty())
return 0;
try {
return Long.parseLong(value);
} catch(NumberFormatException e) {
QtPlugin.log("attribute name:" + attr + " value:" + value, e);
return 0;
}
}
/**
* Reload and return the entries if possible, return null otherwise.
*/
private List<ICLanguageSettingEntry> reload() {
// All keys are reset and then updated as their values are discovered. This allows partial
// success to skip over previously calculated values.
qmakeModTime = 0;
qtInstallHeadersPath = null;
qtInstallHeadersModTime = 0;
File qmake = new File(qmakePath);
if (!qmake.exists()
|| !qmake.canExecute())
return Collections.emptyList();
qmakeModTime = qmake.lastModified();
// Run `qmake -query QT_INSTALL_HEADERS` to get output like "/opt/qt-5.0.0/include".
BufferedReader reader = null;
Process process = null;
try {
process = ProcessFactory.getFactory().exec(new String[]{ qmakePath, "-query", "QT_INSTALL_HEADERS" });
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
qtInstallHeadersPath = reader.readLine();
} catch(IOException e) {
QtPlugin.log(e);
} finally {
try {
if (reader != null)
reader.close();
} catch(IOException e) {
/* ignore */
} finally {
if (process != null)
process.destroy();
}
}
if (qtInstallHeadersPath == null)
return Collections.emptyList();
File qtInstallHeadersDir = new File(qtInstallHeadersPath);
qtInstallHeadersModTime = qtInstallHeadersDir.lastModified();
if (!qtInstallHeadersDir.exists()
|| !qtInstallHeadersDir.canRead()
|| !qtInstallHeadersDir.isDirectory())
return Collections.emptyList();
// Create an include path entry for all sub-folders in the QT_INSTALL_HEADERS location, including
// the QT_INSTALL_HEADERS folder itself.
File[] files = qtInstallHeadersDir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.exists() && pathname.isDirectory();
}
});
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(files.length + 1);
safeAdd(entries, qtInstallHeadersDir);
for(File file : files)
safeAdd(entries, file);
return entries;
}
private static void safeAdd(List<ICLanguageSettingEntry> entries, File file) {
try {
entries.add(new CIncludePathEntry(file.getCanonicalPath(), ICSettingEntry.READONLY | ICSettingEntry.RESOLVED));
} catch(IOException e) {
QtPlugin.log(e);
}
}
}

View file

@ -0,0 +1,133 @@
/*
* Copyright (c) 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.cdt.qt.internal.core;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.core.resources.IResource;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* This provider uses persistent cache to store the include paths for different
* Qt installations. A Qt installation is uniquely identified by the path to
* the qmake binary within the installation.
* <p>
* This result is shared among all Build Configurations that use the provider
* with the same value for the QMAKE environment variable.
*/
public class QtIncludePathsProvider extends LanguageSettingsSerializableProvider {
/**
* The provider identifies Qt installations by the absolute path to the qmake binary. The
* include paths relevant to the installations are computed and persisted in {@link QtIncludePaths}.
*/
private final Map<String, QtIncludePaths> qtInstallHeaders = new HashMap<String, QtIncludePaths>();
/**
* The build configuration stores the path to the qmake binary as an environment variable.
*/
private static final String ENVVAR_QMAKE = "QMAKE";
private static final String ELEMENT_QMAKE = "qmake";
@Override
public boolean equals(Object obj) {
if (!(obj instanceof QtIncludePathsProvider))
return super.equals(obj);
/**
* Providers are equal when they have the same cached values.
*/
QtIncludePathsProvider other = (QtIncludePathsProvider) obj;
if (qtInstallHeaders == null)
return other.qtInstallHeaders == null;
return qtInstallHeaders.equals(other.qtInstallHeaders);
}
@Override
public int hashCode() {
return qtInstallHeaders == null ? 0 : qtInstallHeaders.hashCode();
}
@Override
public void loadEntries(Element providerNode) {
super.loadEntries(providerNode);
// Find and load all qmake child nodes. There will be one node for each Qt
// installation that has been used. Qt installations that are no longer valid
// are not loaded. This means they will be removed from the file the next time
// that the language setting providers are serialized.
NodeList children = providerNode.getChildNodes();
for (int i = 0; i < children.getLength(); ++i) {
Node child = children.item(i);
if (ELEMENT_QMAKE.equals(child.getNodeName())) {
QtIncludePaths qtIncludePaths = QtIncludePaths.loadFrom(child);
if (qtIncludePaths != null
&& qtIncludePaths.isValid())
qtInstallHeaders.put(qtIncludePaths.getQMakePath(), qtIncludePaths);
}
}
}
@Override
public void serializeEntries(Element parent) {
// NOTE: This creates its own XML structure where children of the provider node are qmake nodes.
// Within each qmake node is a list of include paths for that installation. Calling the
// base #serializeEntries here would try to write this instance's (empty) list of settings
// to the file.
// Each value is serialized into a new element in the XML document.
Document document = parent instanceof Document ? (Document)parent : parent.getOwnerDocument();
for(QtIncludePaths qtIncludePaths : qtInstallHeaders.values()) {
Element child = document.createElement(ELEMENT_QMAKE);
qtIncludePaths.serialize(child);
parent.appendChild(child);
}
}
/**
* The given build configuration's QMAKE environment variable is used to identify the appropriate
* Qt installation. The language settings are then either returned from the previously persisted
* data or loaded, serialized, and returned.
*/
@Override
public synchronized List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription configDesc, IResource rc, String languageId) {
// Make sure the requested language is in scope for this provider.
if (!getLanguageScope().contains(languageId))
return null;
// The value of the build configuration's QMAKE environment variable is used to select the
// right version of qmake.
IEnvironmentVariable qmake_var = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENVVAR_QMAKE, configDesc, true);
if (qmake_var == null)
return null;
String qmake = qmake_var.getValue();
if (qmake == null)
return null;
// The path to qmake is used as the key into the in-memory cache of header paths.
QtIncludePaths paths = qtInstallHeaders.get(qmake);
if (paths == null) {
paths = new QtIncludePaths(qmake);
qtInstallHeaders.put(qmake, paths);
}
return paths.getSettingEntries(configDesc, null, languageId);
}
}

View file

@ -0,0 +1,17 @@
#include "DateTime.hh"
#include <QDateTime>
DateTime::DateTime()
{
startTimer( 500 );
}
DateTime::~DateTime()
{
}
void DateTime::timerEvent( QTimerEvent * )
{
emit changed( QDateTime::currentDateTime().toString( "yyyy-MM-dd hh:mm:ss" ) );
}

View file

@ -0,0 +1,22 @@
#ifndef DATETIME_H
#define DATETIME_H
#include <QObject>
class DateTime : public QObject
{
Q_OBJECT
public:
DateTime();
virtual ~DateTime();
protected:
virtual void timerEvent( QTimerEvent * );
private:
Q_SIGNAL void changed( QString now );
};
#endif

View file

@ -0,0 +1,29 @@
PRO = {{baseName}}.pro
QMAKE = {{qmake.Qt4}}
all: debug release
clean: clean-debug clean-release
build-debug/Makefile: $(PRO)
@mkdir -p $(dir $@)
$(QMAKE) -o $@ $(PRO) CONFIG+=debug
debug: build-debug/Makefile
$(MAKE) -wC build-debug all
clean-debug:
rm -fr build-debug
build-release/Makefile: $(PRO)
@mkdir -p $(dir $@)
$(QMAKE) -o $@ $(PRO) CONFIG+=release
release: build-release/Makefile
$(MAKE) -wC build-release
clean-release:
rm -fr build-release
.PHONY: all clean debug clean-debug release clean-release

View file

@ -0,0 +1,22 @@
#include "DateTime.hh"
#include <QtDeclarative/QDeclarativeContext>
#include <QtDeclarative/QDeclarativeEngine>
#include <QtDeclarative/QDeclarativeView>
#include <QtGui/QApplication>
int main( int argc, char * argv[] )
{
QApplication app( argc, argv );
DateTime datetime;
QDeclarativeView view;
view.rootContext()->setContextProperty( "datetimeModel", &datetime );
view.setSource( QUrl::fromLocalFile( "$(baseName).qml" ) );
app.connect( view.engine(), SIGNAL( quit() ), SLOT( quit() ) );
view.show();
return app.exec();
}

View file

@ -0,0 +1,7 @@
QT += declarative
HEADERS = DateTime.hh
SOURCES = DateTime.cpp {{baseName}}.cpp
RESOURCES =
sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro

View file

@ -0,0 +1,38 @@
import QtQuick 1.0
Rectangle {
width: 480
height: 320
color: "lightgreen"
MouseArea {
anchors.fill: parent
onClicked: Qt.quit()
}
Text {
id: title
text: "Hello World from Qt4"
font.family: "Helvetica"
font.pointSize: 24
anchors.centerIn: parent
}
Text {
id: datetime
objectName: "datetime"
font.family: "Helvetica"
font.pointSize: 16
anchors {
horizontalCenter: title.horizontalCenter
top: title.bottom
}
Connections {
target: datetimeModel
onChanged: {
datetime.text = now
}
}
}
}

View file

@ -0,0 +1,14 @@
###############################################################################
# Copyright (c) 2013 QNX Software Systems and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html"
###############################################################################
Qt4HelloWorld.label=Qt4 Hello World Project
Qt4HelloWorld.description=A sample Qt4 declarative project
Qt4HelloWorld.basics.label=Basic Settings
Qt4HelloWorld.basics.description=Basic properties of a project
Qt4HelloWorld.qmake.label=Qt4 qmake location
Qt4HelloWorld.qmake.description=Location of the qmake executable

View file

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<template type="ProjTempl" version="1.0" supplier="Eclipse.org" revision="1.0"
copyright="Copyright (c) 2013 QNX Software Systems and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html"
id="Qt4HelloWorldProject" label="%Qt4HelloWorld.label" description="%Qt4HelloWorld.description" help="help.html">
<property-group id="basics" label="%Qt4HelloWorld.basics.label" description="%Qt4HelloWorld.basics.description" type="PAGES-ONLY" help="help.html">
<property id="qmake.Qt4"
label="%Qt4HelloWorld.qmake.label"
description="%Qt4HelloWorld.qmake.description"
type="browse"
pattern=".*"
default="qmake"
hidden="false"
persist="true"/>
</property-group>
<process type="org.eclipse.cdt.managedbuilder.core.AddLanguageSettingsProvider">
<simple name="projectName" value="$(projectName)"/>
<simple-array name="languageSettingsProviderIds">
<element value="org.eclipse.cdt.qt.core.QtPathsProvider"/>
</simple-array>
</process>
<process type="org.eclipse.cdt.core.SetEnvironmentVariable">
<simple name="projectName" value="$(projectName)"/>
<complex-array name="variables">
<element>
<simple name="name" value="QMAKE"/>
<simple name="value" value="$(qmake.Qt4)"/>
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.core.AddFiles">
<simple name="projectName" value="$(projectName)"/>
<complex-array name="files">
<element>
<simple name="source" value="baseName.cpp"/>
<simple name="target" value="$(projectName).cpp"/>
<simple name="replaceable" value="true"/>
</element>
<element>
<simple name="source" value="baseName.qml"/>
<simple name="target" value="$(projectName).qml"/>
<simple name="replaceable" value="true"/>
</element>
<element>
<simple name="source" value="DateTime.hh"/>
<simple name="target" value="DateTime.hh"/>
<simple name="replaceable" value="true"/>
</element>
<element>
<simple name="source" value="DateTime.cpp"/>
<simple name="target" value="DateTime.cpp"/>
<simple name="replaceable" value="true"/>
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.core.AddFiles2">
<simple name="projectName" value="$(projectName)"/>
<simple name="startPattern" value="{{"/>
<simple name="endPattern" value="}}"/>
<complex-array name="files">
<element>
<simple name="source" value="baseName.pro"/>
<simple name="target" value="$(projectName).pro"/>
<simple name="replaceable" value="true"/>
</element>
<element>
<simple name="source" value="Makefile"/>
<simple name="target" value="Makefile"/>
<simple name="replaceable" value="true"/>
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.ui.OpenFiles">
<simple name="projectName" value="$(projectName)"/>
<complex-array name="files">
<element>
<simple name="target" value="$(projectName).cpp"/>
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.core.AddNature">
<simple name="projectName" value="$(projectName)"/>
<simple name="natureId" value="org.eclipse.cdt.qt.core.qtNature"/>
</process>
<process type="org.eclipse.cdt.make.core.AddMakeTarget">
<simple name="projectName" value="$(projectName)"/>
<simple name="targetName" value="clean-debug"/>
</process>
<process type="org.eclipse.cdt.make.core.AddMakeTarget">
<simple name="projectName" value="$(projectName)"/>
<simple name="targetName" value="build-debug"/>
<simple name="makeTarget" value="debug"/>
</process>
</template>

View file

@ -0,0 +1,17 @@
#include "DateTime.hh"
#include <QDateTime>
DateTime::DateTime()
{
startTimer( 500 );
}
DateTime::~DateTime()
{
}
void DateTime::timerEvent( QTimerEvent * )
{
emit changed( QDateTime::currentDateTime().toString( "yyyy-MM-dd hh:mm:ss" ) );
}

View file

@ -0,0 +1,22 @@
#ifndef DATETIME_H
#define DATETIME_H
#include <QObject>
class DateTime : public QObject
{
Q_OBJECT
public:
DateTime();
virtual ~DateTime();
protected:
virtual void timerEvent( QTimerEvent * );
signals:
void changed( QString now );
};
#endif

View file

@ -0,0 +1,29 @@
PRO = {{baseName}}.pro
QMAKE = {{qmake.Qt5}}
all: debug release
clean: clean-debug clean-release
build-debug/Makefile: $(PRO)
@mkdir -p $(dir $@)
$(QMAKE) -o $@ $(PRO) CONFIG+=debug
debug: build-debug/Makefile
$(MAKE) -wC build-debug all
clean-debug:
rm -fr build-debug
build-release/Makefile: $(PRO)
@mkdir -p $(dir $@)
$(QMAKE) -o $@ $(PRO) CONFIG+=release
release: build-release/Makefile
$(MAKE) -wC build-release
clean-release:
rm -fr build-release
.PHONY: all clean debug clean-debug release clean-release

View file

@ -0,0 +1,20 @@
#include "DateTime.hh"
#include <QGuiApplication>
#include <QtQuick>
int main( int argc, char * argv[] )
{
QGuiApplication app(argc, argv);
DateTime datetime;
QQuickView view;
view.rootContext()->setContextProperty( "datetimeModel", &datetime );
view.setSource( QStringLiteral( "$(baseName).qml" ) );
view.show();
app.connect( view.engine(), SIGNAL( quit() ), SLOT( quit() ) );
return app.exec();
}

View file

@ -0,0 +1,5 @@
QT += qml quick
HEADERS = DateTime.hh
SOURCES = DateTime.cpp {{baseName}}.cpp
RESOURCES =

View file

@ -0,0 +1,38 @@
import QtQuick 2.0
Rectangle {
width: 480
height: 320
color: "lightblue"
MouseArea {
anchors.fill: parent
onClicked: Qt.quit()
}
Text {
id: title
text: "Hello World from Qt5"
font.family: "Helvetica"
font.pointSize: 24
anchors.centerIn: parent
}
Text {
id: datetime
objectName: "datetime"
font.family: "Helvetica"
font.pointSize: 16
anchors {
horizontalCenter: title.horizontalCenter
top: title.bottom
}
Connections {
target: datetimeModel
onChanged: {
datetime.text = now
}
}
}
}

View file

@ -0,0 +1,14 @@
###############################################################################
# Copyright (c) 2013 QNX Software Systems and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html"
###############################################################################
Qt5HelloWorld.label=Qt5 Hello World Project
Qt5HelloWorld.description=A sample Qt5 QtQuick2 project
Qt5HelloWorld.basics.label=Basic Settings
Qt5HelloWorld.basics.description=Basic properties of a project
Qt5HelloWorld.qmake.label=Qt5 qmake location
Qt5HelloWorld.qmake.description=Location of the qmake executable

View file

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<template type="ProjTempl" version="1.0" supplier="Eclipse.org" revision="1.0"
copyright="Copyright (c) 2013 QNX Software Systems and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html"
id="Qt5HelloWorldProject" label="%Qt5HelloWorld.label" description="%Qt5HelloWorld.description" help="help.html">
<property-group id="basics" label="%Qt5HelloWorld.basics.label" description="%Qt5HelloWorld.basics.description" type="PAGES-ONLY" help="help.html">
<property id="qmake.Qt5"
label="%Qt5HelloWorld.qmake.label"
description="%Qt5HelloWorld.qmake.description"
type="browse"
pattern=".*"
default="qmake"
hidden="false"
persist="true"/>
</property-group>
<process type="org.eclipse.cdt.managedbuilder.core.AddLanguageSettingsProvider">
<simple name="projectName" value="$(projectName)"/>
<simple-array name="languageSettingsProviderIds">
<element value="org.eclipse.cdt.qt.core.QtPathsProvider"/>
</simple-array>
</process>
<process type="org.eclipse.cdt.core.SetEnvironmentVariable">
<simple name="projectName" value="$(projectName)"/>
<complex-array name="variables">
<element>
<simple name="name" value="QMAKE"/>
<simple name="value" value="$(qmake.Qt5)"/>
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.core.AddFiles">
<simple name="projectName" value="$(projectName)"/>
<complex-array name="files">
<element>
<simple name="source" value="baseName.cpp"/>
<simple name="target" value="$(projectName).cpp"/>
<simple name="replaceable" value="true"/>
</element>
<element>
<simple name="source" value="baseName.qml"/>
<simple name="target" value="$(projectName).qml"/>
<simple name="replaceable" value="true"/>
</element>
<element>
<simple name="source" value="DateTime.hh"/>
<simple name="target" value="DateTime.hh"/>
<simple name="replaceable" value="true"/>
</element>
<element>
<simple name="source" value="DateTime.cpp"/>
<simple name="target" value="DateTime.cpp"/>
<simple name="replaceable" value="true"/>
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.core.AddFiles2">
<simple name="projectName" value="$(projectName)"/>
<simple name="startPattern" value="{{"/>
<simple name="endPattern" value="}}"/>
<complex-array name="files">
<element>
<simple name="source" value="baseName.pro"/>
<simple name="target" value="$(projectName).pro"/>
<simple name="replaceable" value="true"/>
</element>
<element>
<simple name="source" value="Makefile"/>
<simple name="target" value="Makefile"/>
<simple name="replaceable" value="true"/>
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.ui.OpenFiles">
<simple name="projectName" value="$(projectName)"/>
<complex-array name="files">
<element>
<simple name="target" value="$(projectName).cpp"/>
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.core.AddNature">
<simple name="projectName" value="$(projectName)"/>
<simple name="natureId" value="org.eclipse.cdt.qt.core.qtNature"/>
</process>
<process type="org.eclipse.cdt.make.core.AddMakeTarget">
<simple name="projectName" value="$(projectName)"/>
<simple name="targetName" value="clean-debug"/>
</process>
<process type="org.eclipse.cdt.make.core.AddMakeTarget">
<simple name="projectName" value="$(projectName)"/>
<simple name="targetName" value="build-debug"/>
<simple name="makeTarget" value="debug"/>
</process>
</template>

View file

@ -1,12 +0,0 @@
#include <QGuiApplication>
#include <QQuickView>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQuickView viewer(QStringLiteral("$(baseName).qml"));
viewer.show();
return app.exec();
}

View file

@ -1,3 +0,0 @@
QT += qml quick
SOURCES += {{baseName}}.cpp

View file

@ -1,16 +0,0 @@
import QtQuick 2.0
Rectangle {
width: 360
height: 360
Text {
text: qsTr("Hello World from $(baseName)")
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
}

View file

@ -1,25 +0,0 @@
QMAKE = {{qmake}}
all: debug release
clean: clean-debug clean-release
build-debug/Makefile:
@mkdir -p $(dir $@)
$(QMAKE) -o $@ {{baseName}}.pro CONFIG+=debug
debug: build-debug/Makefile
$(MAKE) -w -C build-debug
clean-debug:
rm -fr build-debug
build-release/Makefile:
@mkdir -p $(dir $@)
$(QMAKE) -o $@ {{baseName}}.pro CONFIG+=release
release: build-release/Makefile
$(MAKE) -w -C build-release
clean-release:
rm -fr build-release

View file

@ -1,18 +0,0 @@
###############################################################################
# Copyright (c) 2007 Symbian Software Private Ltd. and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Bala Torati (Symbian) - initial API and implementation
###############################################################################
#Template Default Values
QtHelloWorld.label=Hello World QtQuick2 Project
QtHelloWorld.description=A Hello World QtQuick2 Project
QtHelloWorld.basics.label=Basic Settings
QtHelloWorld.basics.description=Basic properties of a project
QtHelloWorld.qmake.label=qmake location
QtHelloWorld.qmake.description=Location of the qmake executable

View file

@ -1,65 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<template type="ProjTempl" version="1.0" supplier="Eclipse.org" revision="1.0" author="Doug Schaefer"
copyright="Copyright (c) 2013 QNX Software Systems and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html"
id="QtHelloWorldProject" label="%QtHelloWorld.label" description="%QtHelloWorld.description" help="help.html">
<property-group id="basics" label="%QtHelloWorld.basics.label" description="%QtHelloWorld.basics.description" type="PAGES-ONLY" help="help.html">
<property id="qmake"
label="%QtHelloWorld.qmake.label"
description="%QtHelloWorld.qmake.description"
type="browse"
pattern=".*"
default="qmake"
hidden="false"
persist="true"/>
</property-group>
<process type="org.eclipse.cdt.core.AddFiles">
<simple name="projectName" value="$(projectName)"/>
<complex-array name="files">
<element>
<simple name="source" value="Basename.cpp"/>
<simple name="target" value="$(projectName).cpp"/>
<simple name="replaceable" value="true"/>
</element>
<element>
<simple name="source" value="Basename.qml"/>
<simple name="target" value="$(projectName).qml"/>
<simple name="replaceable" value="true"/>
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.core.AddFiles2">
<simple name="projectName" value="$(projectName)"/>
<simple name="startPattern" value="{{"/>
<simple name="endPattern" value="}}"/>
<complex-array name="files">
<element>
<simple name="source" value="Basename.pro"/>
<simple name="target" value="$(projectName).pro"/>
<simple name="replaceable" value="true"/>
</element>
<element>
<simple name="source" value="Makefile"/>
<simple name="target" value="Makefile"/>
<simple name="replaceable" value="true"/>
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.ui.OpenFiles">
<simple name="projectName" value="$(projectName)"/>
<complex-array name="files">
<element>
<simple name="target" value="$(projectName).cpp"/>
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.core.AddNature">
<simple name="projectName" value="$(projectName)"/>
<simple name="natureId" value="org.eclipse.cdt.qt.core.qtNature"/>
</process>
</template>