summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Bache-Wiig <jbache@trolltech.com>2009-08-05 16:19:11 (GMT)
committerJens Bache-Wiig <jbache@trolltech.com>2009-08-11 13:39:10 (GMT)
commitd82ab0709286f6b6816064affee4705d821830ec (patch)
treebaf3aac1b528e43013888ba7293088afd5db1d16
parentd117525a4ff8757208231fa77f171c7fd7a30ef9 (diff)
downloadQt-d82ab0709286f6b6816064affee4705d821830ec.zip
Qt-d82ab0709286f6b6816064affee4705d821830ec.tar.gz
Qt-d82ab0709286f6b6816064affee4705d821830ec.tar.bz2
Make QIconloader use resource directory as fallback
Instead of using different paths on Mac and Windows we now simply use ":\icons" on all platforms. It is a little more effort to create resources but it is certainly the Qt way to do it. :) Reviewed-by: ogoffart
-rw-r--r--src/gui/image/qicon.cpp13
-rw-r--r--src/gui/image/qiconloader.cpp7
-rw-r--r--tests/auto/qicon/tst_qicon.cpp3
-rw-r--r--tests/auto/qicon/tst_qicon.qrc14
4 files changed, 24 insertions, 13 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index a4ea6af..e23677f 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -888,10 +888,9 @@ void QIcon::setThemeSearchPaths(const QStringList &paths)
On X11, the search path will use the XDG_DATA_DIRS environment
variable if available.
- On Windows the search path defaults to [Application Directory]/icons
-
- On Mac the default search path will search in the
- [Contents/Resources/icons] part of the application bundle.
+ By default all platforms will have the resource directory
+ ":\icons" as their fallback. You can use "rcc -project"
+ to generate a resource file from your icon theme.
\sa setThemeSearchPaths(), fromTheme(), setThemeName()
*/
@@ -906,7 +905,7 @@ QStringList QIcon::themeSearchPaths()
Sets the current icon theme to \a name.
The \a name should correspond to a directory name in the
- current themeSearchPath() containing an index.theme
+ themeSearchPath() containing an index.theme
file describing it's contents.
\sa themeSearchPaths(), themeName()
@@ -939,10 +938,6 @@ QString QIcon::themeName()
icon theme. If no such icon is found in the current theme
\a fallback is return instead.
- To use an icon theme on Windows or Mac, you will need to
- bundle a compliant theme with your application and make sure
- it is located in your themeSarchPaths.
-
The lastest version of the freedesktop icon specification and naming
spesification can be obtained here:
http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 279703c..cb1cc61 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -187,14 +187,17 @@ QStringList QIconLoader::themeSearchPaths() const
QDir homeDir(QDir::homePath() + QLatin1String("/.icons"));
if (homeDir.exists())
m_iconDirs.prepend(homeDir.path());
-
-#elif defined(Q_WS_WIN)
+#endif
+
+#if defined(Q_WS_WIN)
m_iconDirs.append(qApp->applicationDirPath() +
QLatin1String("/icons"));
#elif defined(Q_WS_MAC)
m_iconDirs.append(qApp->applicationDirPath() +
QLatin1String("/../Resources/icons"));
#endif
+ // Allways add resource directory as search path
+ m_iconDirs.append(QLatin1String(":/icons"));
}
return m_iconDirs;
}
diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp
index b614ab9..bacf7a5 100644
--- a/tests/auto/qicon/tst_qicon.cpp
+++ b/tests/auto/qicon/tst_qicon.cpp
@@ -609,8 +609,7 @@ void tst_QIcon::task184901_badCache()
void tst_QIcon::fromTheme()
{
- const QString prefix = QLatin1String(SRCDIR) + QLatin1String("/");
- QString searchPath = prefix + QLatin1String("/icons");
+ QString searchPath = QLatin1String(":/icons");
QIcon::setThemeSearchPaths(QStringList() << searchPath);
QVERIFY(QIcon::themeSearchPaths().size() == 1);
QCOMPARE(searchPath, QIcon::themeSearchPaths()[0]);
diff --git a/tests/auto/qicon/tst_qicon.qrc b/tests/auto/qicon/tst_qicon.qrc
index 1e1a030..7925a33 100644
--- a/tests/auto/qicon/tst_qicon.qrc
+++ b/tests/auto/qicon/tst_qicon.qrc
@@ -2,5 +2,19 @@
<qresource prefix="/">
<file>image.png</file>
<file>rect.png</file>
+<file>./icons/testtheme/16x16/actions/appointment-new.png</file>
+<file>./icons/testtheme/22x22/actions/appointment-new.png</file>
+<file>./icons/testtheme/32x32/actions/appointment-new.png</file>
+<file>./icons/testtheme/index.theme</file>
+<file>./icons/testtheme/scalable/actions/svg-only.svg</file>
+<file>./icons/themeparent/16x16/actions/address-book-new.png</file>
+<file>./icons/themeparent/16x16/actions/appointment-new.png</file>
+<file>./icons/themeparent/22x22/actions/address-book-new.png</file>
+<file>./icons/themeparent/22x22/actions/appointment-new.png</file>
+<file>./icons/themeparent/32x32/actions/address-book-new.png</file>
+<file>./icons/themeparent/32x32/actions/appointment-new.png</file>
+<file>./icons/themeparent/index.theme</file>
+<file>./icons/themeparent/scalable/actions/address-book-new.svg</file>
+<file>./icons/themeparent/scalable/actions/appointment-new.svg</file>
</qresource>
</RCC>