Commit 84f60e5f authored by Christian Kandeler's avatar Christian Kandeler Committed by Alessandro Portale

Maemo: Use different desktop files for Fremantle and Harmattan.

So far, we desperately tried not to duplicate the desktop file,
resorting to all kinds of "clever" heuristics in the process.
This is, however, somewhat limiting and confusing to users,
because we do magic stuff behind their backs.
So it seems better to "give up" and use two desktop files.

Change-Id: Idf969eb3ad365f080e5a9c1608149ea6de629d5c
Reviewed-on: http://codereview.qt.nokia.com/31Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@nokia.com>
parent ea9b7fb5
......@@ -51,10 +51,12 @@ symbian {
}
} else:unix {
maemo5 {
desktopfile.files = $${TARGET}.desktop
desktopfile.path = /usr/share/applications/hildon
icon.files = $${TARGET}64.png
icon.path = /usr/share/icons/hicolor/64x64/apps
} else {
desktopfile.files = $${TARGET}_harmattan.desktop
desktopfile.path = /usr/share/applications
icon.files = $${TARGET}80.png
icon.path = /usr/share/icons/hicolor/80x80/apps
......@@ -96,7 +98,6 @@ symbian {
export($$itempath)
INSTALLS += $$item
}
desktopfile.files = $${TARGET}.desktop
target.path = $${installPrefix}/bin
export(icon.files)
export(icon.path)
......
......@@ -499,52 +499,8 @@ bool MaemoDebianPackageCreationStep::adaptRulesFile(
return false;
}
QByteArray content = reader.data();
const int makeInstallLine = content.indexOf("\t$(MAKE) INSTALL_ROOT");
if (makeInstallLine == -1)
return true;
const int makeInstallEol = content.indexOf('\n', makeInstallLine);
if (makeInstallEol == -1)
return true;
QString desktopFileDir = QFileInfo(rulesFilePath).path()
+ QLatin1Char('/') + maemoTarget()->packageName()
+ QLatin1String("/usr/share/applications/");
const Qt4BuildConfiguration * const bc = qt4BuildConfiguration();
const BaseQtVersion *const lqt = bc->qtVersion();
if (!lqt)
return false;
const MaemoDeviceConfig::OsVersion version
= MaemoGlobal::version(lqt->qmakeCommand());
if (version == MaemoDeviceConfig::Maemo5)
desktopFileDir += QLatin1String("hildon/");
#ifdef Q_OS_WIN
desktopFileDir.remove(QLatin1Char(':'));
desktopFileDir.prepend(QLatin1Char('/'));
#endif
int insertPos = makeInstallEol + 1;
for (int i = 0; i < deployConfig()->deployables()->modelCount(); ++i) {
const MaemoDeployableListModel * const model
= deployConfig()->deployables()->modelAt(i);
if (!model->hasDesktopFile())
continue;
if (version == MaemoDeviceConfig::Maemo6) {
addWorkaroundForHarmattanBug(content, insertPos,
model, desktopFileDir);
}
const QString executableFilePath = model->remoteExecutableFilePath();
if (executableFilePath.isEmpty()) {
qDebug("%s: Skipping subproject %s with missing deployment information.",
Q_FUNC_INFO, qPrintable(model->proFilePath()));
continue;
}
const QByteArray lineBefore("Exec=.*");
const QByteArray lineAfter("Exec=" + executableFilePath.toUtf8());
const QString desktopFilePath = desktopFileDir
+ model->applicationName() + QLatin1String(".desktop");
addSedCmdToRulesFile(content, insertPos, desktopFilePath, lineBefore,
lineAfter);
}
// Always check for dependencies in release builds.
if (!(bc->qmakeBuildConfiguration() & BaseQtVersion::DebugBuild))
ensureShlibdeps(content);
......@@ -560,37 +516,6 @@ bool MaemoDebianPackageCreationStep::adaptRulesFile(
return true;
}
void MaemoDebianPackageCreationStep::addWorkaroundForHarmattanBug(QByteArray &rulesFileContent,
int &insertPos, const MaemoDeployableListModel *model,
const QString &desktopFileDir)
{
const QString iconFilePath = model->remoteIconFilePath();
if (iconFilePath.isEmpty())
return;
const QByteArray lineBefore("^Icon=.*");
const QByteArray lineAfter("Icon=" + iconFilePath.toUtf8());
const QString desktopFilePath
= desktopFileDir + model->applicationName() + QLatin1String(".desktop");
addSedCmdToRulesFile(rulesFileContent, insertPos, desktopFilePath,
lineBefore, lineAfter);
}
void MaemoDebianPackageCreationStep::addSedCmdToRulesFile(QByteArray &rulesFileContent,
int &insertPos, const QString &desktopFilePath, const QByteArray &oldString,
const QByteArray &newString)
{
const QString tmpFilePath = desktopFilePath + QLatin1String(".sed");
const QByteArray sedCmd = "\tsed 's:" + oldString + ':' + newString
+ ":' " + desktopFilePath.toLocal8Bit() + " > "
+ tmpFilePath.toLocal8Bit() + " || echo -n\n";
const QByteArray mvCmd = "\tmv " + tmpFilePath.toLocal8Bit() + ' '
+ desktopFilePath.toLocal8Bit() + " || echo -n\n";
rulesFileContent.insert(insertPos, sedCmd);
insertPos += sedCmd.length();
rulesFileContent.insert(insertPos, mvCmd);
insertPos += mvCmd.length();
}
MaemoRpmPackageCreationStep::MaemoRpmPackageCreationStep(BuildStepList *bsl)
: AbstractMaemoPackageCreationStep(bsl, CreatePackageId)
......
......@@ -130,12 +130,6 @@ private:
static QString packagingCommand(const Qt4BuildConfiguration *bc,
const QString &commandName);
bool copyDebianFiles(bool inSourceBuild);
void addSedCmdToRulesFile(QByteArray &rulesFileContent, int &insertPos,
const QString &desktopFilePath, const QByteArray &oldString,
const QByteArray &newString);
void addWorkaroundForHarmattanBug(QByteArray &rulesFileContent,
int &insertPos, const MaemoDeployableListModel *model,
const QString &desktopFileDir);
void checkProjectName();
bool adaptRulesFile(const QString &templatePath, const QString &rulesFilePath);
......
......@@ -170,7 +170,8 @@ QString AbstractMobileApp::path(int fileType) const
case AppPro: return outputPathBase() + cleanProjectName + QLatin1String(".pro");
case AppProOrigin: return originsRootApp + QLatin1String("app.pro");
case AppProPath: return outputPathBase();
case Desktop: return outputPathBase() + cleanProjectName + QLatin1String(".desktop");
case DesktopFremantle: return outputPathBase() + cleanProjectName + QLatin1String(".desktop");
case DesktopHarmattan: return outputPathBase() + cleanProjectName + QLatin1String("_harmattan.desktop");
case DesktopOrigin: return originsRootShared + QLatin1String("app.desktop");
case DeploymentPri: return outputPathBase() + DeploymentPriFileName;
case DeploymentPriOrigin: return originsRootShared + DeploymentPriFileName;
......@@ -197,13 +198,18 @@ bool AbstractMobileApp::readTemplate(int fileType, QByteArray *data, QString *er
return true;
}
QByteArray AbstractMobileApp::generateDesktopFile(QString *errorMessage) const
QByteArray AbstractMobileApp::generateDesktopFile(QString *errorMessage, int fileType) const
{
QByteArray desktopFileContent;
if (!readTemplate(DesktopOrigin, &desktopFileContent, errorMessage))
return QByteArray();
desktopFileContent.replace("Icon=thisApp",
"Icon=" + projectName().toUtf8() + "64");
if (fileType == AbstractGeneratedFileInfo::DesktopFileFremantle) {
desktopFileContent.replace("Icon=thisApp",
"Icon=" + projectName().toUtf8() + "64");
} else if (fileType == AbstractGeneratedFileInfo::DesktopFileHarmattan) {
desktopFileContent.replace("Icon=thisApp",
"Icon=/usr/share/icons/hicolor/80x80/apps/" + projectName().toUtf8() + "80.png");
}
return desktopFileContent.replace("thisApp", projectName().toUtf8());
}
......@@ -395,7 +401,8 @@ Core::GeneratedFiles AbstractMobileApp::generateFiles(QString *errorMessage) con
files << file(generateFile(AbstractGeneratedFileInfo::SymbianSvgIconFile, errorMessage), path(SymbianSvgIcon));
files << file(generateFile(AbstractGeneratedFileInfo::MaemoPngIconFile64, errorMessage), path(MaemoPngIcon64));
files << file(generateFile(AbstractGeneratedFileInfo::MaemoPngIconFile80, errorMessage), path(MaemoPngIcon80));
files << file(generateFile(AbstractGeneratedFileInfo::DesktopFile, errorMessage), path(Desktop));
files << file(generateFile(AbstractGeneratedFileInfo::DesktopFileFremantle, errorMessage), path(DesktopFremantle));
files << file(generateFile(AbstractGeneratedFileInfo::DesktopFileHarmattan, errorMessage), path(DesktopHarmattan));
return files;
}
#endif // CREATORLESSTEST
......@@ -437,8 +444,9 @@ QByteArray AbstractMobileApp::generateFile(int fileType,
case AbstractGeneratedFileInfo::MaemoPngIconFile80:
data = readBlob(path(MaemoPngIconOrigin80), errorMessage);
break;
case AbstractGeneratedFileInfo::DesktopFile:
data = generateDesktopFile(errorMessage);
case AbstractGeneratedFileInfo::DesktopFileFremantle:
case AbstractGeneratedFileInfo::DesktopFileHarmattan:
data = generateDesktopFile(errorMessage, fileType);
break;
case AbstractGeneratedFileInfo::DeploymentPriFile:
data = readBlob(path(DeploymentPriOrigin), errorMessage);
......
......@@ -59,7 +59,8 @@ struct
SymbianSvgIconFile,
MaemoPngIconFile64,
MaemoPngIconFile80,
DesktopFile,
DesktopFileFremantle,
DesktopFileHarmattan,
ExtendedFile
};
......@@ -97,7 +98,8 @@ public:
AppPro,
AppProOrigin,
AppProPath,
Desktop,
DesktopFremantle,
DesktopHarmattan,
DesktopOrigin,
DeploymentPri,
DeploymentPriOrigin,
......@@ -166,7 +168,7 @@ protected:
QString m_error;
private:
QByteArray generateDesktopFile(QString *errorMessage) const;
QByteArray generateDesktopFile(QString *errorMessage, int fileType) const;
QByteArray generateMainCpp(QString *errorMessage) const;
QByteArray generateProFile(QString *errorMessage) const;
......
......@@ -58,7 +58,8 @@ bool QtQuickApp::generateFiles(QString *errorMessage) const
&& writeFile(generateFile(QtQuickAppGeneratedFileInfo::SymbianSvgIconFile, errorMessage), path(SymbianSvgIcon))
&& writeFile(generateFile(QtQuickAppGeneratedFileInfo::MaemoPngIconFile64, errorMessage), path(MaemoPngIcon64))
&& writeFile(generateFile(QtQuickAppGeneratedFileInfo::MaemoPngIconFile80, errorMessage), path(MaemoPngIcon80))
&& writeFile(generateFile(QtQuickAppGeneratedFileInfo::DesktopFile, errorMessage), path(Desktop));
&& writeFile(generateFile(QtQuickAppGeneratedFileInfo::DesktopFileFremantle, errorMessage), path(DesktopFremantle))
&& writeFile(generateFile(QtQuickAppGeneratedFileInfo::DesktopFileHarmattan, errorMessage), path(DesktopHarmattan));
}
bool Html5App::generateFiles(QString *errorMessage) const
......@@ -72,7 +73,8 @@ bool Html5App::generateFiles(QString *errorMessage) const
&& writeFile(generateFile(Html5AppGeneratedFileInfo::SymbianSvgIconFile, errorMessage), path(SymbianSvgIcon))
&& writeFile(generateFile(Html5AppGeneratedFileInfo::MaemoPngIconFile64, errorMessage), path(MaemoPngIcon64))
&& writeFile(generateFile(Html5AppGeneratedFileInfo::MaemoPngIconFile80, errorMessage), path(MaemoPngIcon80))
&& writeFile(generateFile(Html5AppGeneratedFileInfo::DesktopFile, errorMessage), path(Desktop));
&& writeFile(generateFile(Html5AppGeneratedFileInfo::DesktopFileFremantle, errorMessage), path(DesktopFremantle))
&& writeFile(generateFile(Html5AppGeneratedFileInfo::DesktopFileHarmattan, errorMessage), path(DesktopHarmattan));
}
QString AbstractMobileApp::templatesRoot()
......
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