summaryrefslogtreecommitdiffstats
path: root/qmake/generators/win32/winmakefile.cpp
diff options
context:
space:
mode:
authorDebao Zhang <hello@debao.me>2012-12-20 09:38:54 +0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-10 15:13:46 +0100
commitad3536b7ad31d141927cefa2a6b10ad4806781d2 (patch)
tree17634f6f3074d0e72feaf0dd74608b8c76fcc71c /qmake/generators/win32/winmakefile.cpp
parentef838063b1246b997257b76df3a877a8ba395b99 (diff)
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 <orgads@gmail.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'qmake/generators/win32/winmakefile.cpp')
-rw-r--r--qmake/generators/win32/winmakefile.cpp21
1 files changed, 20 insertions, 1 deletions
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 <winver.h>" << 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