Commit 7b276878 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Maemo: If we create a desktop file, we should also deploy it.

Reviewed-by: kh1
parent 14d7f6b6
...@@ -292,7 +292,7 @@ bool MaemoTemplatesManager::updateDesktopFile(const Qt4Target *target, ...@@ -292,7 +292,7 @@ bool MaemoTemplatesManager::updateDesktopFile(const Qt4Target *target,
"Version=1.0\nType=Application\nTerminal=false\nName=\nExec=\n" "Version=1.0\nType=Application\nTerminal=false\nName=\nExec=\n"
"Icon=\nX-Window-Icon=\nX-HildonDesk-ShowInToolbar=true\n" "Icon=\nX-Window-Icon=\nX-HildonDesk-ShowInToolbar=true\n"
"X-Osso-Type=application/x-executable\n"); "X-Osso-Type=application/x-executable\n");
QByteArray contents QByteArray desktopFileContents
= existsAlready ? desktopFile.readAll() : desktopTemplate; = existsAlready ? desktopFile.readAll() : desktopTemplate;
QString executable; QString executable;
...@@ -310,18 +310,18 @@ bool MaemoTemplatesManager::updateDesktopFile(const Qt4Target *target, ...@@ -310,18 +310,18 @@ bool MaemoTemplatesManager::updateDesktopFile(const Qt4Target *target,
qWarning("Strange: Project file node not managed by MaemoDeployables."); qWarning("Strange: Project file node not managed by MaemoDeployables.");
} else { } else {
int execNewLinePos, execValuePos; int execNewLinePos, execValuePos;
findLine("Exec=", contents, execNewLinePos, execValuePos); findLine("Exec=", desktopFileContents, execNewLinePos, execValuePos);
contents.replace(execValuePos, execNewLinePos - execValuePos, desktopFileContents.replace(execValuePos, execNewLinePos - execValuePos,
executable.toUtf8()); executable.toUtf8());
} }
int nameNewLinePos, nameValuePos; int nameNewLinePos, nameValuePos;
findLine("Name=", contents, nameNewLinePos, nameValuePos); findLine("Name=", desktopFileContents, nameNewLinePos, nameValuePos);
if (nameNewLinePos == nameValuePos) if (nameNewLinePos == nameValuePos)
contents.insert(nameValuePos, appName.toUtf8()); desktopFileContents.insert(nameValuePos, appName.toUtf8());
desktopFile.resize(0); desktopFile.resize(0);
desktopFile.write(contents); desktopFile.write(desktopFileContents);
desktopFile.close(); desktopFile.close();
if (desktopFile.error() != QFile::NoError) { if (desktopFile.error() != QFile::NoError) {
qWarning("Could not write '%s': %s", qPrintable(desktopFilePath), qWarning("Could not write '%s': %s", qPrintable(desktopFilePath),
...@@ -331,9 +331,27 @@ bool MaemoTemplatesManager::updateDesktopFile(const Qt4Target *target, ...@@ -331,9 +331,27 @@ bool MaemoTemplatesManager::updateDesktopFile(const Qt4Target *target,
if (!existsAlready) { if (!existsAlready) {
proFileNode->addFiles(UnknownFileType, proFileNode->addFiles(UnknownFileType,
QStringList() << desktopFilePath); QStringList() << desktopFilePath);
QFile proFile(proFileNode->path());
if (!proFile.open(QIODevice::ReadWrite)) {
qWarning("Failed to open '%s': %s", qPrintable(proFileNode->path()),
qPrintable(proFile.errorString()));
return false;
}
QByteArray proFileContents = proFile.readAll();
proFileContents += "\nmaemo5|maemp6{\n"
" desktopfile.files = $${TARGET}.desktop\n"
" desktopfile.path = /usr/share/applications/hildon\n"
" INSTALLS += desktopfile\n}\n";
proFile.resize(0);
proFile.write(proFileContents);
proFile.close();
if (proFile.error() != QFile::NoError) {
qWarning("Could not write '%s': %s", qPrintable(proFileNode->path()),
qPrintable(proFile.errorString()));
return false;
}
} }
return true; return true;
} }
void MaemoTemplatesManager::handleProjectToBeRemoved(ProjectExplorer::Project *project) void MaemoTemplatesManager::handleProjectToBeRemoved(ProjectExplorer::Project *project)
......
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