Commit a8c524d4 authored by Eike Ziller's avatar Eike Ziller

Merge remote-tracking branch 'origin/2.6'

Conflicts:
	src/plugins/qt4projectmanager/wizards/qtquickapp.cpp

Change-Id: I6ece61c73bc32e93912ad1b489871c597ab60d5b
parents 4f0c97d0 948abf10
# Add more folders to ship with the application, here
# DEPLOYMENTFOLDERS #
folder_01.source = qml/app
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01
# DEPLOYMENTFOLDERS_END #
# Additional import path used to resolve QML modules in Creator's code model
# QML_IMPORT_PATH #
QML_IMPORT_PATH =
# If your application uses the Qt Mobility libraries, uncomment the following
# lines and add the respective components to the MOBILITY variable.
# CONFIG += mobility
# MOBILITY +=
# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp
# Please do not modify the following two lines. Required for deployment.
include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
# REMOVE_NEXT_LINE (wizard will remove the include and append deployment.pri to qmlapplicationviewer.pri, instead) #
include(../shared/deployment.pri)
qtcAddDeployment()
#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QtQuick2ApplicationViewer viewer;
viewer.setMainQmlFile(QStringLiteral("qml/app/qtquick20/main.qml")); // MAINQML
viewer.showExpanded();
return app.exec();
}
import QtQuick 2.0
Rectangle {
width: 360
height: 360
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
}
/*
This file was generated by the Qt Quick 2 Application wizard of Qt Creator.
QtQuick2ApplicationViewer is a convenience class containing mobile device specific
code such as screen orientation handling. Also QML paths and debugging are
handled here.
It is recommended not to modify this file, since newer versions of Qt Creator
may offer an updated version of it.
*/
#include "qtquick2applicationviewer.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
#include <QtQml/QQmlEngine>
class QtQuick2ApplicationViewerPrivate
{
QString mainQmlFile;
friend class QtQuick2ApplicationViewer;
static QString adjustPath(const QString &path);
};
QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path)
{
#ifdef Q_OS_UNIX
#ifdef Q_OS_MAC
if (!QDir::isAbsolutePath(path))
return QString::fromLatin1("%1/../Resources/%2")
.arg(QCoreApplication::applicationDirPath(), path);
#elif !defined(Q_OS_ANDROID)
const QString pathInInstallDir =
QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
if (QFileInfo(pathInInstallDir).exists())
return pathInInstallDir;
#endif
#endif
return path;
}
QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent)
: QQuickView(parent)
, d(new QtQuick2ApplicationViewerPrivate())
{
connect(engine(), SIGNAL(quit()), SLOT(close()));
setResizeMode(QQuickView::SizeRootObjectToView);
#ifdef Q_OS_ANDROID
engine()->setBaseUrl(QUrl::fromLocalFile("/"));
#endif
}
QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer()
{
delete d;
}
void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file)
{
d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file);
setSource(QUrl::fromLocalFile(d->mainQmlFile));
}
void QtQuick2ApplicationViewer::addImportPath(const QString &path)
{
engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path));
}
void QtQuick2ApplicationViewer::showExpanded()
{
#if defined(Q_WS_SIMULATOR)
showFullScreen();
#else
show();
#endif
}
/*
This file was generated by the Qt Quick 2 Application wizard of Qt Creator.
QtQuick2ApplicationViewer is a convenience class containing mobile device specific
code such as screen orientation handling. Also QML paths and debugging are
handled here.
It is recommended not to modify this file, since newer versions of Qt Creator
may offer an updated version of it.
*/
#ifndef QTQUICK2APPLICATIONVIEWER_H
#define QTQUICK2APPLICATIONVIEWER_H
#include <QtQuick/QQuickView>
class QtQuick2ApplicationViewer : public QQuickView
{
Q_OBJECT
public:
explicit QtQuick2ApplicationViewer(QWindow *parent = 0);
virtual ~QtQuick2ApplicationViewer();
void setMainQmlFile(const QString &file);
void addImportPath(const QString &path);
void showExpanded();
private:
class QtQuick2ApplicationViewerPrivate *d;
};
#endif // QTQUICK2APPLICATIONVIEWER_H
# This file was generated by the Qt Quick 2 Application wizard of Qt Creator.
# The code below adds the QtQuick2ApplicationViewer to the project and handles
# the activation of QML debugging.
# It is recommended not to modify this file, since newer versions of Qt Creator
# may offer an updated version of it.
QT += qml quick
SOURCES += $$PWD/qtquick2applicationviewer.cpp
HEADERS += $$PWD/qtquick2applicationviewer.h
INCLUDEPATH += $$PWD
#include <QWindow>
#include <QtDeclarative>
#include <QGuiApplication>
#include <QQuickView>
#include <QQmlEngine>
int main( int argc, char** argv )
{
QGuiApplication app( argc, argv );
QWindow *window = 0;
int exitCode = 0;
QQuickView view;
view.setResizeMode( QQuickView::SizeRootObjectToView );
view.setSource( QUrl( "app/native/qml/main.qml" ) );
QQuickView* view = new QQuickView();
view->setResizeMode( QQuickView::SizeRootObjectToView );
view->setSource( QUrl( "app/native/qml/main.qml" ) );
QObject::connect( view.engine(), SIGNAL( quit() ),
QCoreApplication::instance(), SLOT( quit() ) );
view.show();
QDeclarativeEngine* engine = view->engine();
QObject::connect( engine, SIGNAL(quit()),
QCoreApplication::instance(), SLOT(quit()) );
window = view;
window->showMaximized();
exitCode = app.exec();
delete window;
return exitCode;
return app.exec();
}
......@@ -418,9 +418,10 @@ void AutotoolsProject::updateCppCodeModel()
QByteArray macros;
if (activeTarget()) {
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(activeTarget()->kit());
ProjectExplorer::Kit *k = activeTarget()->kit();
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
if (tc) {
const QList<HeaderPath> allHeaderPaths = tc->systemHeaderPaths();
const QList<HeaderPath> allHeaderPaths = tc->systemHeaderPaths(SysRootKitInformation::sysRoot(k));
foreach (const HeaderPath &headerPath, allHeaderPaths) {
if (headerPath.kind() == HeaderPath::FrameworkHeaderPath)
allFrameworkPaths.append(headerPath.path());
......
......@@ -425,7 +425,7 @@ void CMakeRunPage::initializePage()
} else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) {
#ifdef Q_OS_WIN
if (cachedGenerator.isEmpty() || cachedGenerator == "MinGW Makefiles")
m_generatorComboBox->addItem(tr("MinGW Generator (%1)").arg(p->displayName()), kitVariant);
m_generatorComboBox->addItem(tr("MinGW Generator (%1)").arg(k->displayName()), kitVariant);
#else
if (cachedGenerator.isEmpty() || cachedGenerator == "Unix Makefiles")
m_generatorComboBox->addItem(tr("Unix Generator (%1)").arg(k->displayName()), kitVariant);
......
......@@ -286,7 +286,8 @@ bool CMakeProject::parseCMakeLists()
createUiCodeModelSupport();
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(activeTarget()->kit());
Kit *k = activeTarget()->kit();
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
if (!tc) {
emit buildTargetsChanged();
emit fileListChanged();
......@@ -304,7 +305,7 @@ bool CMakeProject::parseCMakeLists()
QStringList allFrameworkPaths;
QList<ProjectExplorer::HeaderPath> allHeaderPaths;
allHeaderPaths = tc->systemHeaderPaths();
allHeaderPaths = tc->systemHeaderPaths(SysRootKitInformation::sysRoot(k));
foreach (const ProjectExplorer::HeaderPath &headerPath, allHeaderPaths) {
if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath)
allFrameworkPaths.append(headerPath.path());
......
......@@ -249,13 +249,13 @@ void GenericProject::refresh(RefreshOptions options)
CPlusPlus::CppModelManagerInterface::ProjectPart::Ptr part(
new CPlusPlus::CppModelManagerInterface::ProjectPart);
ToolChain *tc = activeTarget() ?
ToolChainKitInformation::toolChain(activeTarget()->kit()) : 0;
Kit *k = activeTarget() ? activeTarget()->kit() : KitManager::instance()->defaultKit();
ToolChain *tc = k ? ToolChainKitInformation::toolChain(k) : 0;
if (tc) {
part->defines = tc->predefinedMacros(QStringList());
part->defines += '\n';
foreach (const HeaderPath &headerPath, tc->systemHeaderPaths()) {
foreach (const HeaderPath &headerPath, tc->systemHeaderPaths(SysRootKitInformation::sysRoot(k))) {
if (headerPath.kind() == HeaderPath::FrameworkHeaderPath)
part->frameworkPaths.append(headerPath.path());
else
......
......@@ -98,11 +98,19 @@ QByteArray AbstractMsvcToolChain::predefinedMacros(const QStringList &cxxflags)
ToolChain::CompilerFlags AbstractMsvcToolChain::compilerFlags(const QStringList &cxxflags) const
{
Q_UNUSED(cxxflags);
return NO_FLAGS;
switch (m_abi.osFlavor()) {
case ProjectExplorer::Abi::WindowsMsvc2010Flavor:
case ProjectExplorer::Abi::WindowsMsvc2012Flavor:
return STD_CXX11;
default:
return NO_FLAGS;
}
}
QList<HeaderPath> AbstractMsvcToolChain::systemHeaderPaths() const
QList<HeaderPath> AbstractMsvcToolChain::systemHeaderPaths(const Utils::FileName &sysRoot) const
{
Q_UNUSED(sysRoot);
if (m_headerPaths.isEmpty()) {
Utils::Environment env(m_lastEnvironment);
addToEnvironment(env);
......
......@@ -53,7 +53,7 @@ public:
QByteArray predefinedMacros(const QStringList &cxxflags) const;
CompilerFlags compilerFlags(const QStringList &cxxflags) const;
QList<HeaderPath> systemHeaderPaths() const;
QList<HeaderPath> systemHeaderPaths(const Utils::FileName &sysRoot) const;
void addToEnvironment(Utils::Environment &env) const;
QString makeCommand() const;
......
......@@ -149,12 +149,12 @@ static QByteArray gccPredefinedMacros(const FileName &gcc, const QStringList &ar
return predefinedMacros;
}
QList<HeaderPath> GccToolChain::gccHeaderPaths(const FileName &gcc, const QStringList &env, const QString &sysrootPath)
QList<HeaderPath> GccToolChain::gccHeaderPaths(const FileName &gcc, const QStringList &env, const FileName &sysrootPath)
{
QList<HeaderPath> systemHeaderPaths;
QStringList arguments;
if (!sysrootPath.isEmpty())
arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysrootPath));
arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysrootPath.toString()));
arguments << QLatin1String("-xc++")
<< QLatin1String("-E")
<< QLatin1String("-v")
......@@ -388,18 +388,19 @@ QByteArray GccToolChain::predefinedMacros(const QStringList &cxxflags) const
ToolChain::CompilerFlags GccToolChain::compilerFlags(const QStringList &cxxflags) const
{
if (cxxflags.contains("-std=c++0x") || cxxflags.contains("-std=gnu++0x"))
if (cxxflags.contains("-std=c++0x") || cxxflags.contains("-std=gnu++0x") ||
cxxflags.contains("-std=c++11") || cxxflags.contains("-std=gnu++11"))
return STD_CXX11;
return NO_FLAGS;
}
QList<HeaderPath> GccToolChain::systemHeaderPaths() const
QList<HeaderPath> GccToolChain::systemHeaderPaths(const Utils::FileName &sysRoot) const
{
if (m_headerPaths.isEmpty()) {
// Using a clean environment breaks ccache/distcc/etc.
Environment env = Environment::systemEnvironment();
addToEnvironment(env);
m_headerPaths = gccHeaderPaths(m_compilerCommand, env.toStringList());
m_headerPaths = gccHeaderPaths(m_compilerCommand, env.toStringList(), sysRoot);
}
return m_headerPaths;
}
......
......@@ -64,7 +64,7 @@ public:
QByteArray predefinedMacros(const QStringList &cxxflags) const;
CompilerFlags compilerFlags(const QStringList &cxxflags) const;
QList<HeaderPath> systemHeaderPaths() const;
QList<HeaderPath> systemHeaderPaths(const Utils::FileName &sysRoot) const;
void addToEnvironment(Utils::Environment &env) const;
QString makeCommand() const;
QList<Utils::FileName> suggestedMkspecList() const;
......@@ -91,7 +91,7 @@ protected:
virtual QList<Abi> detectSupportedAbis() const;
virtual QString detectVersion() const;
static QList<HeaderPath> gccHeaderPaths(const Utils::FileName &gcc, const QStringList &env, const QString &sysrootPath = QString());
static QList<HeaderPath> gccHeaderPaths(const Utils::FileName &gcc, const QStringList &env, const Utils::FileName &sysrootPath);
mutable QByteArray m_predefinedMacros;
......
......@@ -124,7 +124,7 @@ QString ToolChain::id() const
return d->m_id;
}
Utils::FileName ToolChain::suggestedDebugger()
Utils::FileName ToolChain::suggestedDebugger() const
{
return ToolChainManager::instance()->defaultDebugger(targetAbi());
}
......
......@@ -73,7 +73,7 @@ public:
QString id() const;
virtual QList<Utils::FileName> suggestedMkspecList() const { return QList<Utils::FileName>(); }
virtual Utils::FileName suggestedDebugger();
virtual Utils::FileName suggestedDebugger() const;
virtual QString type() const = 0;
virtual QString typeDisplayName() const = 0;
......@@ -88,7 +88,7 @@ public:
STD_CXX11 = 1
};
virtual CompilerFlags compilerFlags(const QStringList &cxxflags) const = 0;
virtual QList<HeaderPath> systemHeaderPaths() const = 0;
virtual QList<HeaderPath> systemHeaderPaths(const Utils::FileName &sysRoot) const = 0;
virtual void addToEnvironment(Utils::Environment &env) const = 0;
virtual QString makeCommand() const = 0;
......
......@@ -527,7 +527,7 @@ void Qt4Project::updateCppCodeModel()
QList<HeaderPath> headers;
if (tc)
headers = tc->systemHeaderPaths(); // todo pass cxxflags?
headers = tc->systemHeaderPaths(SysRootKitInformation::sysRoot(k)); // todo pass cxxflags?
if (qtVersion) {
headers.append(qtVersion->systemHeaderPathes(k));
}
......
......@@ -265,7 +265,9 @@ ProjectExplorer::Project *Qt4Manager::openProject(const QString &fileName, QStri
}
}
const QtQuickApp qtQuickApp;
QtQuickApp qtQuickApp;
updateBoilerPlateCodeFiles(&qtQuickApp, canonicalFilePath);
qtQuickApp.setComponentSet(QtQuickApp::QtQuick20Components);
updateBoilerPlateCodeFiles(&qtQuickApp, canonicalFilePath);
const Html5App html5App;
updateBoilerPlateCodeFiles(&html5App, canonicalFilePath);
......
......@@ -43,12 +43,6 @@
namespace Qt4ProjectManager {
namespace Internal {
const QString appViewerBaseName(QLatin1String("qmlapplicationviewer"));
const QString appViewerPriFileName(appViewerBaseName + QLatin1String(".pri"));
const QString appViewerCppFileName(appViewerBaseName + QLatin1String(".cpp"));
const QString appViewerHFileName(appViewerBaseName + QLatin1String(".h"));
const QString appViewerOriginsSubDir(appViewerBaseName + QLatin1Char('/'));
QtQuickApp::QtQuickApp()
: AbstractMobileApp()
, m_mainQmlMode(ModeGenerate)
......@@ -85,7 +79,7 @@ QString QtQuickApp::pathExtended(int fileType) const
const QString qmlSubDir = QLatin1String("qml/")
+ (importQmlFile ? m_mainQmlFile.dir().dirName() : projectName())
+ QLatin1Char('/');
const QString appViewerTargetSubDir = appViewerOriginsSubDir;
const QString appViewerTargetSubDir = appViewerOriginSubDir();
const QString mainQmlFile = QLatin1String("main.qml");
const QString mainPageQmlFile = QLatin1String("MainPage.qml");
......@@ -104,12 +98,12 @@ QString QtQuickApp::pathExtended(int fileType) const
case MainQmlOrigin: return qmlOriginDir + mainQmlFile;
case MainPageQml: return pathBase + qmlSubDir + mainPageQmlFile;
case MainPageQmlOrigin: return qmlOriginDir + mainPageQmlFile;
case AppViewerPri: return pathBase + appViewerTargetSubDir + appViewerPriFileName;
case AppViewerPriOrigin: return originsRoot() + appViewerOriginsSubDir + appViewerPriFileName;
case AppViewerCpp: return pathBase + appViewerTargetSubDir + appViewerCppFileName;
case AppViewerCppOrigin: return originsRoot() + appViewerOriginsSubDir + appViewerCppFileName;
case AppViewerH: return pathBase + appViewerTargetSubDir + appViewerHFileName;
case AppViewerHOrigin: return originsRoot() + appViewerOriginsSubDir + appViewerHFileName;
case AppViewerPri: return pathBase + appViewerTargetSubDir + fileName(AppViewerPri);
case AppViewerPriOrigin: return originsRoot() + appViewerOriginSubDir() + fileName(AppViewerPri);
case AppViewerCpp: return pathBase + appViewerTargetSubDir + fileName(AppViewerCpp);
case AppViewerCppOrigin: return originsRoot() + appViewerOriginSubDir() + fileName(AppViewerCpp);
case AppViewerH: return pathBase + appViewerTargetSubDir + fileName(AppViewerH);
case AppViewerHOrigin: return originsRoot() + appViewerOriginSubDir() + fileName(AppViewerH);
case QmlDir: return pathBase + qmlSubDir;
case QmlDirProFileRelative: return importQmlFile ? appProFilePath.relativeFilePath(m_mainQmlFile.canonicalPath())
: QString(qmlSubDir).remove(qmlSubDir.length() - 1, 1);
......@@ -120,7 +114,8 @@ QString QtQuickApp::pathExtended(int fileType) const
QString QtQuickApp::originsRoot() const
{
return templatesRoot() + QLatin1String("qtquickapp/");
const bool isQtQuick2 = m_componentSet == QtQuick20Components;
return templatesRoot() + QLatin1String(isQtQuick2 ? "qtquick2app/" : "qtquickapp/");
}
QString QtQuickApp::mainWindowClassName() const
......@@ -180,6 +175,27 @@ bool QtQuickApp::useExistingMainQml() const
return !m_mainQmlFile.filePath().isEmpty();
}
QString QtQuickApp::appViewerBaseName() const
{
return QLatin1String(m_componentSet == QtQuick20Components ?
"qtquick2applicationviewer" : "qmlapplicationviewer");
}
QString QtQuickApp::fileName(QtQuickApp::ExtendedFileType type) const
{
switch (type) {
case AppViewerPri: return appViewerBaseName() + QLatin1String(".pri");
case AppViewerH: return appViewerBaseName() + QLatin1String(".h");
case AppViewerCpp: return appViewerBaseName() + QLatin1String(".cpp");
default: return QString();
}
}
QString QtQuickApp::appViewerOriginSubDir() const
{
return appViewerBaseName() + QLatin1Char('/');
}
QByteArray QtQuickApp::generateFileExtended(int fileType,
bool *versionAndCheckSum, QString *comment, QString *errorMessage) const
{
......@@ -212,7 +228,7 @@ QByteArray QtQuickApp::generateFileExtended(int fileType,
int QtQuickApp::stubVersionMinor() const
{
return StubVersion;
return m_componentSet == QtQuick20Components ? 1 : 22;
}
QList<AbstractGeneratedFileInfo> QtQuickApp::updateableFiles(const QString &mainProFile) const
......@@ -222,21 +238,21 @@ QList<AbstractGeneratedFileInfo> QtQuickApp::updateableFiles(const QString &main
int fileType;
QString fileName;
} files[] = {
{QtQuickAppGeneratedFileInfo::AppViewerPriFile, appViewerPriFileName},
{QtQuickAppGeneratedFileInfo::AppViewerHFile, appViewerHFileName},
{QtQuickAppGeneratedFileInfo::AppViewerCppFile, appViewerCppFileName}
{QtQuickAppGeneratedFileInfo::AppViewerPriFile, fileName(AppViewerPri)},
{QtQuickAppGeneratedFileInfo::AppViewerHFile, fileName(AppViewerH)},
{QtQuickAppGeneratedFileInfo::AppViewerCppFile, fileName(AppViewerCpp)}
};
const QFileInfo mainProFileInfo(mainProFile);
const int size = sizeof(files) / sizeof(files[0]);
for (int i = 0; i < size; ++i) {
const QString fileName = mainProFileInfo.dir().absolutePath()
+ QLatin1Char('/') + appViewerOriginsSubDir + files[i].fileName;
+ QLatin1Char('/') + appViewerOriginSubDir() + files[i].fileName;
if (!QFile::exists(fileName))
continue;
QtQuickAppGeneratedFileInfo file;
file.fileType = files[i].fileType;
file.fileInfo = QFileInfo(fileName);
file.currentVersion = AbstractMobileApp::makeStubVersion(QtQuickApp::StubVersion);
file.currentVersion = AbstractMobileApp::makeStubVersion(stubVersionMinor());
result.append(file);
}
if (result.count() != size)
......@@ -256,13 +272,13 @@ QString QtQuickApp::componentSetDir(ComponentSet componentSet) const
switch (componentSet) {
case Meego10Components:
return QLatin1String("meego10");
case QtQuick20Components:
return QLatin1String("qtquick20");
case QtQuick10Components:
default:
return QLatin1String("qtquick10");
}
}
const int QtQuickApp::StubVersion = 22;
} // namespace Internal
} // namespace Qt4ProjectManager
......@@ -78,7 +78,8 @@ public:
enum ComponentSet {
QtQuick10Components,
Meego10Components
Meego10Components,
QtQuick20Components
};
QtQuickApp();
......@@ -98,6 +99,11 @@ public:
static const int StubVersion;
protected:
virtual QString appViewerBaseName() const;
QString fileName(ExtendedFileType type) const;
QString appViewerOriginSubDir() const;
private:
virtual QByteArray generateFileExtended(int fileType,
bool *versionAndCheckSum, QString *comment, QString *errorMessage) const;
......
......@@ -72,7 +72,7 @@ QtQuickAppWizardDialog::QtQuickAppWizardDialog(QWidget *parent,
QtQuickAppWizard::Kind kind)
: AbstractMobileAppWizardDialog(parent,