From ad3536b7ad31d141927cefa2a6b10ad4806781d2 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Thu, 20 Dec 2012 09:38:54 +0800 Subject: qmake: Add application icon support for windows A new qmake's variable RC_ICONS is introduced to specify the icons. The first one will be used as the application's icon. Change-Id: I4218db795837d470087dff8526eb0e4cb81ce5ed Reviewed-by: Orgad Shaneh Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen Reviewed-by: Joerg Bornemann --- qmake/generators/win32/msvc_nmake.cpp | 10 ---------- qmake/generators/win32/winmakefile.cpp | 21 ++++++++++++++++++++- qmake/generators/win32/winmakefile.h | 1 + 3 files changed, 21 insertions(+), 11 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index d899c707d4..9f5abfb307 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -366,16 +366,6 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t) } -static QString cQuoted(const QString &str) -{ - QString ret = str; - ret.replace(QLatin1Char('"'), QStringLiteral("\\\"")); - ret.replace(QLatin1Char('\\'), QStringLiteral("\\\\")); - ret.prepend(QLatin1Char('"')); - ret.append(QLatin1Char('"')); - return ret; -} - void NmakeMakefileGenerator::writeBuildRulesPart(QTextStream &t) { const ProString templateName = project->first("TEMPLATE"); diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index bda035e023..fa1d719a8a 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -382,7 +382,7 @@ void Win32MakefileGenerator::processRcFileVar() if (Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING) return; - if (((!project->values("VERSION").isEmpty()) + if (((!project->values("VERSION").isEmpty() || !project->values("RC_ICONS").isEmpty()) && project->values("RC_FILE").isEmpty() && project->values("RES_FILE").isEmpty() && !project->isActiveConfig("no_generated_target_info") @@ -397,6 +397,10 @@ void Win32MakefileGenerator::processRcFileVar() vers += "0"; QString versionString = vers.join('.'); + QStringList rcIcons; + foreach (const ProString &icon, project->values("RC_ICONS")) + rcIcons.append(fileFixify(icon.toQString(), FileFixifyAbsolute)); + QString companyName; if (!project->values("QMAKE_TARGET_COMPANY").isEmpty()) companyName = project->values("QMAKE_TARGET_COMPANY").join(' '); @@ -425,6 +429,11 @@ void Win32MakefileGenerator::processRcFileVar() ts << "# include " << endl; ts << "# endif" << endl; ts << endl; + if (!rcIcons.isEmpty()) { + for (int i = 0; i < rcIcons.size(); ++i) + ts << QString("IDI_ICON%1\tICON\tDISCARDABLE\t%2").arg(i + 1).arg(cQuoted(rcIcons[i])) << endl; + ts << endl; + } ts << "VS_VERSION_INFO VERSIONINFO" << endl; ts << "\tFILEVERSION " << QString(versionString).replace(".", ",") << endl; ts << "\tPRODUCTVERSION " << QString(versionString).replace(".", ",") << endl; @@ -902,4 +911,14 @@ QString Win32MakefileGenerator::escapeFilePath(const QString &path) const return ret; } +QString Win32MakefileGenerator::cQuoted(const QString &str) +{ + QString ret = str; + ret.replace(QLatin1Char('"'), QStringLiteral("\\\"")); + ret.replace(QLatin1Char('\\'), QStringLiteral("\\\\")); + ret.prepend(QLatin1Char('"')); + ret.append(QLatin1Char('"')); + return ret; +} + QT_END_NAMESPACE diff --git a/qmake/generators/win32/winmakefile.h b/qmake/generators/win32/winmakefile.h index 8d4bcbcd69..ec68828750 100644 --- a/qmake/generators/win32/winmakefile.h +++ b/qmake/generators/win32/winmakefile.h @@ -73,6 +73,7 @@ protected: void fixTargetExt(); void processRcFileVar(); virtual QString getLibTarget(); + static QString cQuoted(const QString &str); }; inline Win32MakefileGenerator::~Win32MakefileGenerator() -- cgit v1.2.3