Commit de885384 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

QML Wizard: Add support for .desktop files.

Reviewed-by: Alessandro Portale
parent e6958859
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Name=thisApp
Exec=/opt/bin/thisApp
Icon=thisApp
X-Window-Icon=
X-HildonDesk-ShowInToolbar=true
X-Osso-Type=application/x-executable
...@@ -288,6 +288,8 @@ QString QmlStandaloneApp::path(Path path) const ...@@ -288,6 +288,8 @@ QString QmlStandaloneApp::path(Path path) const
case AppPro: return pathBase + m_projectName + QLatin1String(".pro"); case AppPro: return pathBase + m_projectName + QLatin1String(".pro");
case AppProOrigin: return originsRoot + QLatin1String("app.pro"); case AppProOrigin: return originsRoot + QLatin1String("app.pro");
case AppProPath: return pathBase; case AppProPath: return pathBase;
case Desktop: return pathBase + m_projectName + QLatin1String(".desktop");
case DesktopOrigin: return originsRoot + QLatin1String("app.desktop");
case AppViewerPri: return pathBase + appViewerTargetSubDir + appViewerPriFileName; case AppViewerPri: return pathBase + appViewerTargetSubDir + appViewerPriFileName;
case AppViewerPriOrigin: return originsRoot + appViewerOriginsSubDir + appViewerPriFileName; case AppViewerPriOrigin: return originsRoot + appViewerOriginsSubDir + appViewerPriFileName;
case AppViewerCpp: return pathBase + appViewerTargetSubDir + appViewerCppFileName; case AppViewerCpp: return pathBase + appViewerTargetSubDir + appViewerCppFileName;
...@@ -429,6 +431,17 @@ QByteArray QmlStandaloneApp::generateProFile(const QString *errorMessage) const ...@@ -429,6 +431,17 @@ QByteArray QmlStandaloneApp::generateProFile(const QString *errorMessage) const
return proFileContent; return proFileContent;
} }
QByteArray QmlStandaloneApp::generateDesktopFile(const QString *errorMessage) const
{
Q_UNUSED(errorMessage);
QFile desktopTemplate(path(DesktopOrigin));
desktopTemplate.open(QIODevice::ReadOnly);
Q_ASSERT(desktopTemplate.isOpen());
QByteArray desktopFileContent = desktopTemplate.readAll();
return desktopFileContent.replace("thisApp", projectName().toUtf8());
}
void QmlStandaloneApp::clearModulesAndPlugins() void QmlStandaloneApp::clearModulesAndPlugins()
{ {
qDeleteAll(m_modules); qDeleteAll(m_modules);
...@@ -530,6 +543,7 @@ Core::GeneratedFiles QmlStandaloneApp::generateFiles(QString *errorMessage) cons ...@@ -530,6 +543,7 @@ Core::GeneratedFiles QmlStandaloneApp::generateFiles(QString *errorMessage) cons
files.append(file(generateFile(GeneratedFileInfo::MainCppFile, errorMessage), path(MainCpp))); files.append(file(generateFile(GeneratedFileInfo::MainCppFile, errorMessage), path(MainCpp)));
files.append(file(generateFile(GeneratedFileInfo::SymbianSvgIconFile, errorMessage), path(SymbianSvgIcon))); files.append(file(generateFile(GeneratedFileInfo::SymbianSvgIconFile, errorMessage), path(SymbianSvgIcon)));
files.append(file(generateFile(GeneratedFileInfo::MaemoPngIconFile, errorMessage), path(MaemoPngIcon))); files.append(file(generateFile(GeneratedFileInfo::MaemoPngIconFile, errorMessage), path(MaemoPngIcon)));
files.append(file(generateFile(GeneratedFileInfo::DesktopFile, errorMessage), path(Desktop)));
files.append(file(generateFile(GeneratedFileInfo::AppViewerPriFile, errorMessage), path(AppViewerPri))); files.append(file(generateFile(GeneratedFileInfo::AppViewerPriFile, errorMessage), path(AppViewerPri)));
files.append(file(generateFile(GeneratedFileInfo::AppViewerCppFile, errorMessage), path(AppViewerCpp))); files.append(file(generateFile(GeneratedFileInfo::AppViewerCppFile, errorMessage), path(AppViewerCpp)));
...@@ -583,6 +597,9 @@ QByteArray QmlStandaloneApp::generateFile(GeneratedFileInfo::File file, ...@@ -583,6 +597,9 @@ QByteArray QmlStandaloneApp::generateFile(GeneratedFileInfo::File file,
case GeneratedFileInfo::MaemoPngIconFile: case GeneratedFileInfo::MaemoPngIconFile:
data = readBlob(path(MaemoPngIconOrigin)); data = readBlob(path(MaemoPngIconOrigin));
break; break;
case GeneratedFileInfo::DesktopFile:
data = generateDesktopFile(errorMessage);
break;
case GeneratedFileInfo::AppProFile: case GeneratedFileInfo::AppProFile:
data = generateProFile(errorMessage); data = generateProFile(errorMessage);
comment = proFileComment; comment = proFileComment;
...@@ -619,7 +636,7 @@ QByteArray QmlStandaloneApp::generateFile(GeneratedFileInfo::File file, ...@@ -619,7 +636,7 @@ QByteArray QmlStandaloneApp::generateFile(GeneratedFileInfo::File file,
int QmlStandaloneApp::stubVersion() int QmlStandaloneApp::stubVersion()
{ {
return 2; return 3;
} }
static QList<GeneratedFileInfo> updateableFiles(const QString &mainProFile) static QList<GeneratedFileInfo> updateableFiles(const QString &mainProFile)
......
...@@ -86,7 +86,8 @@ struct GeneratedFileInfo ...@@ -86,7 +86,8 @@ struct GeneratedFileInfo
AppViewerCppFile, AppViewerCppFile,
AppViewerHFile, AppViewerHFile,
SymbianSvgIconFile, SymbianSvgIconFile,
MaemoPngIconFile MaemoPngIconFile,
DesktopFile
}; };
GeneratedFileInfo(); GeneratedFileInfo();
...@@ -120,6 +121,8 @@ public: ...@@ -120,6 +121,8 @@ public:
AppPro, AppPro,
AppProOrigin, AppProOrigin,
AppProPath, AppProPath,
Desktop,
DesktopOrigin,
AppViewerPri, AppViewerPri,
AppViewerPriOrigin, AppViewerPriOrigin,
AppViewerCpp, AppViewerCpp,
...@@ -175,6 +178,7 @@ public: ...@@ -175,6 +178,7 @@ public:
private: private:
QByteArray generateMainCpp(const QString *errorMessage) const; QByteArray generateMainCpp(const QString *errorMessage) const;
QByteArray generateProFile(const QString *errorMessage) const; QByteArray generateProFile(const QString *errorMessage) const;
QByteArray generateDesktopFile(const QString *errorMessage) const;
static QString templatesRoot(); static QString templatesRoot();
bool addExternalModule(const QString &uri, const QFileInfo &dir, bool addExternalModule(const QString &uri, const QFileInfo &dir,
const QFileInfo &contentDir); const QFileInfo &contentDir);
......
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