Commit 071400d6 authored by Alessandro Portale's avatar Alessandro Portale
Browse files

Improved (and simplified) the stub directory structure

- Removed the "cpp/" dir
- Moved main.cpp and symbianicon.svg next to the main .pro.
  This also reduces the dir depth in the project view.
- Introduced "qmlapplicationviewer/" dir, which will contain the files
  which the user should not modify. All the files there have the base
  name "qmlapplicationviewer"
- Moved/renamed "qmlapplication.pri" to
  "qmlapplicationviewer/qmlapplicationviewer.pri"
parent 053721ea
......@@ -16,12 +16,12 @@ DEFINES += NETWORKACCESS
# TARGETUID3 #
symbian:TARGET.UID3 = 0xE1111234
symbian:ICON = cpp/symbianicon.svg
symbian:ICON = symbianicon.svg
# Define to enable the Qml Inspector in debug mode
# QMLINSPECTOR #
#DEFINES += QMLINSPECTOR
SOURCES += cpp/main.cpp
SOURCES += main.cpp
include($$PWD/qmlapplication.pri)
include(qmlapplicationviewer/qmlapplicationviewer.pri)
#include <QtGui/QApplication>
#include "qmlapplicationview.h"
#include "qmlapplicationviewer.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QmlApplicationView qmlApp;
qmlApp.addImportPath(QLatin1String("modules")); // ADDIMPORTPATH
qmlApp.setOrientation(QmlApplicationView::Auto); // ORIENTATION
qmlApp.setMainQmlFile(QLatin1String("qml/app/app.qml")); // MAINQML
qmlApp.setLoadDummyData(false); // LOADDUMMYDATA
QmlApplicationViewer viewer;
viewer.addImportPath(QLatin1String("modules")); // ADDIMPORTPATH
viewer.setOrientation(QmlApplicationViewer::Auto); // ORIENTATION
viewer.setMainQmlFile(QLatin1String("qml/app/app.qml")); // MAINQML
viewer.setLoadDummyData(false); // LOADDUMMYDATA
#ifdef Q_OS_SYMBIAN
qmlApp.showFullScreen();
viewer.showFullScreen();
#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
qmlApp.showMaximized();
viewer.showMaximized();
#else
qmlApp.show();
viewer.show();
#endif
return app.exec();
}
#include "qmlapplicationview.h"
#include "qmlapplicationviewer.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
......@@ -14,14 +14,14 @@
#include <aknappui.h>
#endif // Q_OS_SYMBIAN && ORIENTATIONLOCK
class QmlApplicationViewPrivate
class QmlApplicationViewerPrivate
{
QString mainQmlFile;
friend class QmlApplicationView;
friend class QmlApplicationViewer;
static QString adjustPath(const QString &path);
};
QString QmlApplicationViewPrivate::adjustPath(const QString &path)
QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
{
#ifdef Q_OS_MAC
if (!QDir::isAbsolutePath(path))
......@@ -31,35 +31,35 @@ QString QmlApplicationViewPrivate::adjustPath(const QString &path)
return path;
}
QmlApplicationView::QmlApplicationView(QWidget *parent) :
QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) :
#ifdef QMLINSPECTOR
QmlViewer::QDeclarativeDesignView(parent)
#else
QDeclarativeView(parent)
#endif
, m_d(new QmlApplicationViewPrivate)
, m_d(new QmlApplicationViewerPrivate)
{
connect(engine(), SIGNAL(quit()), SLOT(close()));
setResizeMode(QDeclarativeView::SizeRootObjectToView);
}
QmlApplicationView::~QmlApplicationView()
QmlApplicationViewer::~QmlApplicationViewer()
{
delete m_d;
}
void QmlApplicationView::setMainQmlFile(const QString &file)
void QmlApplicationViewer::setMainQmlFile(const QString &file)
{
m_d->mainQmlFile = QmlApplicationViewPrivate::adjustPath(file);
m_d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file);
setSource(QUrl::fromLocalFile(m_d->mainQmlFile));
}
void QmlApplicationView::addImportPath(const QString &path)
void QmlApplicationViewer::addImportPath(const QString &path)
{
engine()->addImportPath(QmlApplicationViewPrivate::adjustPath(path));
engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path));
}
void QmlApplicationView::setOrientation(Orientation orientation)
void QmlApplicationViewer::setOrientation(Orientation orientation)
{
if (orientation != Auto) {
#if defined(Q_OS_SYMBIAN)
......@@ -79,7 +79,7 @@ void QmlApplicationView::setOrientation(Orientation orientation)
}
}
void QmlApplicationView::setLoadDummyData(bool loadDummyData)
void QmlApplicationViewer::setLoadDummyData(bool loadDummyData)
{
if (loadDummyData) {
const QFileInfo mainQmlFileInfo(m_d->mainQmlFile);
......
#ifndef QMLAPPLICATIONVIEW_H
#define QMLAPPLICATIONVIEW_H
#ifndef QMLAPPLICATIONVIEWER_H
#define QMLAPPLICATIONVIEWER_H
#ifdef QMLINSPECTOR
#include <qdeclarativedesignview.h>
class QmlApplicationView : public QmlViewer::QDeclarativeDesignView
#else // QMLINSPECTOR
#include <QtDeclarative/QDeclarativeView>
class QmlApplicationView : public QDeclarativeView
class QmlApplicationViewer : public QDeclarativeView
#endif // QMLINSPECTOR
{
public:
......@@ -16,8 +16,8 @@ public:
Auto
};
QmlApplicationView(QWidget *parent = 0);
virtual ~QmlApplicationView();
QmlApplicationViewer(QWidget *parent = 0);
virtual ~QmlApplicationViewer();
void setMainQmlFile(const QString &file);
void addImportPath(const QString &path);
......@@ -25,7 +25,7 @@ public:
void setLoadDummyData(bool loadDummyData);
private:
class QmlApplicationViewPrivate *m_d;
class QmlApplicationViewerPrivate *m_d;
};
#endif // QMLAPPLICATIONVIEW_H
#endif // QMLAPPLICATIONVIEWER_H
......@@ -3,9 +3,9 @@
QT += declarative
SOURCES += cpp/qmlapplicationview.cpp
HEADERS += cpp/qmlapplicationview.h
INCLUDEPATH += cpp
SOURCES += $$PWD/qmlapplicationviewer.cpp
HEADERS += $$PWD/qmlapplicationviewer.h
INCLUDEPATH += $$PWD
contains(DEFINES, QMLINSPECTOR) {
CONFIG(debug, debug|release) {
......@@ -29,6 +29,8 @@ for(deploymentfolder, DEPLOYMENTFOLDERS) {
DEPLOYMENT += $$item
}
MAINPROFILEPWD = $$PWD/..
symbian {
TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
contains(DEFINES, ORIENTATIONLOCK):LIBS += -lavkon -leikcore -leiksrv -lcone
......@@ -39,7 +41,7 @@ symbian {
for(deploymentfolder, DEPLOYMENTFOLDERS) {
source = $$eval($${deploymentfolder}.source)
pathSegments = $$split(source, /)
sourceAndTarget = $$PWD/$$source $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(pathSegments)
sourceAndTarget = $$MAINPROFILEPWD/$$source $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(pathSegments)
copyCommand += && $(COPY_DIR) $$replace(sourceAndTarget, /, \\)
}
copydeploymentfolders.commands = $$copyCommand
......@@ -65,7 +67,7 @@ symbian {
for(deploymentfolder, DEPLOYMENTFOLDERS) {
target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target)
copyCommand += && $(MKDIR) $$target
copyCommand += && $(COPY_DIR) $$PWD/$$eval($${deploymentfolder}.source) $$target
copyCommand += && $(COPY_DIR) $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) $$target
}
copydeploymentfolders.commands = $$copyCommand
first.depends = $(first) copydeploymentfolders
......@@ -77,7 +79,7 @@ symbian {
for(deploymentfolder, DEPLOYMENTFOLDERS) {
target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
copyCommand += && $(MKDIR) $$target
copyCommand += && $(COPY_DIR) $$PWD/$$eval($${deploymentfolder}.source) $$target
copyCommand += && $(COPY_DIR) $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) $$target
}
copydeploymentfolders.commands = $$copyCommand
first.depends = $(first) copydeploymentfolders
......
......@@ -41,14 +41,15 @@
namespace Qt4ProjectManager {
namespace Internal {
const QLatin1String qmldir("qmldir");
const QLatin1String qmldir_plugin("plugin");
const QLatin1String cppOriginsSubDir("cpp/");
const QLatin1String appPriFileName("qmlapplication.pri");
const QLatin1String appViewCppFileName("qmlapplicationview.cpp");
const QLatin1String appViewHFileName("qmlapplicationview.h");
const QLatin1String fileChecksum("checksum");
const QLatin1String fileStubVersion("version");
const QString qmldir(QLatin1String("qmldir"));
const QString qmldir_plugin(QLatin1String("plugin"));
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('/'));
const QString fileChecksum(QLatin1String("checksum"));
const QString fileStubVersion(QLatin1String("version"));
QmlModule::QmlModule(const QString &uri, const QFileInfo &rootDir, const QFileInfo &qmldir,
bool isExternal, QmlStandaloneApp *qmlStandaloneApp)
......@@ -66,7 +67,7 @@ QString QmlModule::path(Path path) const
return rootDir.canonicalFilePath();
}
case ContentDir: {
const QDir proFile(qmlStandaloneApp->path(QmlStandaloneApp::AppProfilePath));
const QDir proFile(qmlStandaloneApp->path(QmlStandaloneApp::AppProPath));
return proFile.relativeFilePath(qmldir.canonicalPath());
}
case ContentBase: {
......@@ -178,7 +179,7 @@ void QmlStandaloneApp::setSymbianTargetUid(const QString &uid)
QString QmlStandaloneApp::symbianTargetUid() const
{
return !m_symbianTargetUid.isEmpty() ? m_symbianTargetUid
: symbianUidForPath(path(AppProfile));
: symbianUidForPath(path(AppPro));
}
void QmlStandaloneApp::setLoadDummyData(bool loadIt)
......@@ -244,11 +245,10 @@ QString QmlStandaloneApp::path(Path path) const
+ (useExistingMainQml() ? m_mainQmlFile.dir().dirName() : m_projectName)
+ QLatin1Char('/');
const QString originsRoot = templatesRoot();
const QString cppTargetSubDir = cppOriginsSubDir;
const QString appViewerTargetSubDir = appViewerOriginsSubDir;
const QString qmlExtension = QLatin1String(".qml");
const QString mainCppFileName = QLatin1String("main.cpp");
const QString symbianIconFileName = QLatin1String("symbianicon.svg");
const char* const errorMessage = "QmlStandaloneApp::path() needs more work";
const QString pathBase = m_projectPath.absoluteFilePath() + QLatin1Char('/')
+ m_projectName + QLatin1Char('/');
const QDir appProFilePath(pathBase);
......@@ -259,29 +259,25 @@ QString QmlStandaloneApp::path(Path path) const
case MainQmlDeployed: return useExistingMainQml() ? qmlSubDir + m_mainQmlFile.fileName()
: QString(qmlSubDir + m_projectName + qmlExtension);
case MainQmlOrigin: return originsRoot + QLatin1String("qml/app/app.qml");
case MainCpp: return pathBase + cppTargetSubDir + mainCppFileName;
case MainCppOrigin: return originsRoot + cppOriginsSubDir + mainCppFileName;
case MainCppProFileRelative: return cppTargetSubDir + mainCppFileName;
case AppProfile: return pathBase + m_projectName + QLatin1String(".pro");
case AppProfileOrigin: return originsRoot + QLatin1String("app.pro");
case AppProfilePath: return pathBase;
case AppPri: return pathBase + appPriFileName;
case AppPriOrigin: return originsRoot + appPriFileName;
case AppViewerCpp: return pathBase + cppTargetSubDir + appViewCppFileName;
case AppViewerCppOrigin: return originsRoot + cppOriginsSubDir + appViewCppFileName;
case AppViewerCppProFileRelative: return cppTargetSubDir + appViewCppFileName;
case AppViewerH: return pathBase + cppTargetSubDir + appViewHFileName;
case AppViewerHOrigin: return originsRoot + cppOriginsSubDir + appViewHFileName;
case AppViewerHProFileRelative: return cppTargetSubDir + appViewHFileName;
case SymbianSvgIcon: return pathBase + cppTargetSubDir + symbianIconFileName;
case MainCpp: return pathBase + mainCppFileName;
case MainCppOrigin: return originsRoot + mainCppFileName;
case AppPro: return pathBase + m_projectName + QLatin1String(".pro");
case AppProOrigin: return originsRoot + QLatin1String("app.pro");
case AppProPath: return pathBase;
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 SymbianSvgIcon: return pathBase + symbianIconFileName;
case SymbianSvgIconOrigin: return !m_symbianSvgIcon.isEmpty() ? m_symbianSvgIcon
: originsRoot + cppOriginsSubDir + symbianIconFileName;
case SymbianSvgIconProFileRelative: return cppTargetSubDir + symbianIconFileName;
: originsRoot + symbianIconFileName;
case QmlDir: return pathBase + qmlSubDir;
case QmlDirProFileRelative: return useExistingMainQml() ? appProFilePath.relativeFilePath(m_mainQmlFile.canonicalPath())
: QString(qmlSubDir).remove(qmlSubDir.length() - 1, 1);
case ModulesDir: return QLatin1String("modules");
default: qFatal(errorMessage);
default: qFatal("QmlStandaloneApp::path() needs more work");
}
return QString();
}
......@@ -337,7 +333,7 @@ QByteArray QmlStandaloneApp::generateProFile(const QString *errorMessage) const
Q_UNUSED(errorMessage)
const QChar comment = QLatin1Char('#');
QFile proFile(path(AppProfileOrigin));
QFile proFile(path(AppProOrigin));
proFile.open(QIODevice::ReadOnly);
Q_ASSERT(proFile.isOpen());
QTextStream in(&proFile);
......@@ -497,19 +493,19 @@ Core::GeneratedFiles QmlStandaloneApp::generateFiles(QString *errorMessage) cons
{
Core::GeneratedFiles files;
files.append(file(generateFile(GeneratedFileInfo::AppProfileFile, errorMessage), path(AppProfile)));
files.last().setAttributes(Core::GeneratedFile::OpenProjectAttribute);
files.append(file(generateFile(GeneratedFileInfo::AppPriFile, errorMessage), path(AppPri)));
if (!useExistingMainQml()) {
files.append(file(generateFile(GeneratedFileInfo::MainQmlFile, errorMessage), path(MainQml)));
files.last().setAttributes(Core::GeneratedFile::OpenEditorAttribute);
}
files.append(file(generateFile(GeneratedFileInfo::AppProFile, errorMessage), path(AppPro)));
files.last().setAttributes(Core::GeneratedFile::OpenProjectAttribute);
files.append(file(generateFile(GeneratedFileInfo::MainCppFile, errorMessage), path(MainCpp)));
files.append(file(generateFile(GeneratedFileInfo::SymbianSvgIconFile, errorMessage), path(SymbianSvgIcon)));
files.append(file(generateFile(GeneratedFileInfo::AppViewerPriFile, errorMessage), path(AppViewerPri)));
files.append(file(generateFile(GeneratedFileInfo::AppViewerCppFile, errorMessage), path(AppViewerCpp)));
files.append(file(generateFile(GeneratedFileInfo::AppViewerHFile, errorMessage), path(AppViewerH)));
files.append(file(generateFile(GeneratedFileInfo::SymbianSvgIconFile, errorMessage), path(SymbianSvgIcon)));
return files;
}
......@@ -556,12 +552,12 @@ QByteArray QmlStandaloneApp::generateFile(GeneratedFileInfo::File file,
case GeneratedFileInfo::SymbianSvgIconFile:
data = readBlob(path(SymbianSvgIconOrigin));
break;
case GeneratedFileInfo::AppProfileFile:
case GeneratedFileInfo::AppProFile:
data = generateProFile(errorMessage);
comment = proFileComment;
break;
case GeneratedFileInfo::AppPriFile:
data = readBlob(path(AppPriOrigin));
case GeneratedFileInfo::AppViewerPriFile:
data = readBlob(path(AppViewerPriOrigin));
comment = proFileComment;
versionAndChecksum = true;
break;
......@@ -602,14 +598,14 @@ static QList<GeneratedFileInfo> updateableFiles(const QString &mainProFile)
GeneratedFileInfo::File file;
QString fileName;
} files[] = {
{GeneratedFileInfo::AppPriFile, appPriFileName},
{GeneratedFileInfo::AppViewerHFile, cppOriginsSubDir + appViewCppFileName},
{GeneratedFileInfo::AppViewerCppFile, cppOriginsSubDir + appViewHFileName}
{GeneratedFileInfo::AppViewerPriFile, appViewerPriFileName},
{GeneratedFileInfo::AppViewerHFile, appViewerCppFileName},
{GeneratedFileInfo::AppViewerCppFile, appViewerHFileName}
};
const QFileInfo mainProFileInfo(mainProFile);
for (int i = 0; i < sizeof files / sizeof files[0]; ++i) {
const QString fileName = mainProFileInfo.dir().absolutePath()
+ QLatin1Char('/') + files[i].fileName;
+ QLatin1Char('/') + appViewerOriginsSubDir + files[i].fileName;
if (!QFile::exists(fileName))
continue;
GeneratedFileInfo file;
......
......@@ -81,8 +81,8 @@ struct GeneratedFileInfo
enum File {
MainQmlFile,
MainCppFile,
AppProfileFile,
AppPriFile,
AppProFile,
AppViewerPriFile,
AppViewerCppFile,
AppViewerHFile,
SymbianSvgIconFile
......@@ -121,22 +121,17 @@ public:
MainQmlOrigin,
MainCpp,
MainCppOrigin,
MainCppProFileRelative,
AppProfile,
AppProfileOrigin,
AppProfilePath,
AppPri,
AppPriOrigin,
AppPriProFileRelative,
AppPro,
AppProOrigin,
AppProPath,
AppViewerPri,
AppViewerPriOrigin,
AppViewerCpp,
AppViewerCppOrigin,
AppViewerCppProFileRelative,
AppViewerH,
AppViewerHOrigin,
AppViewerHProFileRelative,
SymbianSvgIcon,
SymbianSvgIconOrigin,
SymbianSvgIconProFileRelative,
QmlDir,
QmlDirProFileRelative,
ModulesDir
......
Markdown is supported
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