diff options
author | Paul Olav Tvete <paul.tvete@nokia.com> | 2010-05-10 13:12:30 (GMT) |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@nokia.com> | 2010-05-10 13:12:30 (GMT) |
commit | 395508f4700bb72c120e0f9e8a19ffa69a7c5d88 (patch) | |
tree | 92efbecc98b018cfc617aab2c4811f921becd79c /src/gui/image | |
parent | 6f39ecdabdae9b2132729a2a9940e5febaa420d2 (diff) | |
parent | 03f8f1df0d88f5ffe0b3120cffce614cbeefdb70 (diff) | |
download | Qt-395508f4700bb72c120e0f9e8a19ffa69a7c5d88.zip Qt-395508f4700bb72c120e0f9e8a19ffa69a7c5d88.tar.gz Qt-395508f4700bb72c120e0f9e8a19ffa69a7c5d88.tar.bz2 |
Merge remote branch 'qt/4.7' into lighthouse-4.7
Conflicts:
src/gui/egl/egl.pri
src/gui/painting/qwindowsurface_p.h
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qicon.cpp | 21 | ||||
-rw-r--r-- | src/gui/image/qicon.h | 2 | ||||
-rw-r--r-- | src/gui/image/qiconengine.cpp | 20 | ||||
-rw-r--r-- | src/gui/image/qiconengine.h | 5 | ||||
-rw-r--r-- | src/gui/image/qiconloader.cpp | 6 | ||||
-rw-r--r-- | src/gui/image/qimagereader.cpp | 14 | ||||
-rw-r--r-- | src/gui/image/qimagewriter.cpp | 16 |
7 files changed, 67 insertions, 17 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index fad51f4..891b1db 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -441,7 +441,7 @@ void QPixmapIconEngine::virtual_hook(int id, void *data) } } -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +#ifndef QT_NO_LIBRARY Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QIconEngineFactoryInterface_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive)) Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loaderV2, @@ -879,6 +879,25 @@ QList<QSize> QIcon::availableSizes(Mode mode, State state) const } /*! + \since 4.7 + + Returns the name used to create the icon, if available. + + Depending on the way the icon was created, it may have an associated + name. This is the case for icons created with fromTheme() or icons + using a QIconEngine which supports the QIconEngineV2::IconNameHook. + + \sa fromTheme(), QIconEngine +*/ +QString QIcon::name() const +{ + if (!d || !d->engine || d->engine_version < 2) + return QString(); + QIconEngineV2 *engine = static_cast<QIconEngineV2*>(d->engine); + return engine->iconName(); +} + +/*! \since 4.6 Sets the search paths for icon themes to \a paths. diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h index 2812703..faef07b 100644 --- a/src/gui/image/qicon.h +++ b/src/gui/image/qicon.h @@ -81,6 +81,8 @@ public: QSize actualSize(const QSize &size, Mode mode = Normal, State state = Off) const; + QString name() const; + void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const; inline void paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const { paint(painter, QRect(x, y, w, h), alignment, mode, state); } diff --git a/src/gui/image/qiconengine.cpp b/src/gui/image/qiconengine.cpp index 4c7c728..050d48d 100644 --- a/src/gui/image/qiconengine.cpp +++ b/src/gui/image/qiconengine.cpp @@ -183,6 +183,10 @@ void QIconEngine::addFile(const QString &/*fileName*/, const QSize &/*size*/, QI that should be filled with icon sizes. Engines that work in terms of a scalable, vectorial format normally return an empty list. + \value IconNameHook Allows to query the name used to create the + icon, for example when instantiating an icon using + QIcon::fromTheme(). + \sa virtual_hook() */ @@ -301,4 +305,20 @@ QList<QSize> QIconEngineV2::availableSizes(QIcon::Mode mode, QIcon::State state) return arg.sizes; } +/*! + \since 4.7 + + Returns the name used to create the engine, if available. + + \note This is a helper method and the actual work is done by + virtual_hook() method, hence this method depends on icon engine support + and may not work with all icon engines. + */ +QString QIconEngineV2::iconName() +{ + QString name; + virtual_hook(QIconEngineV2::IconNameHook, reinterpret_cast<void*>(&name)); + return name; +} + QT_END_NAMESPACE diff --git a/src/gui/image/qiconengine.h b/src/gui/image/qiconengine.h index 1f9266b..6d8b6ad 100644 --- a/src/gui/image/qiconengine.h +++ b/src/gui/image/qiconengine.h @@ -80,7 +80,7 @@ public: virtual void virtual_hook(int id, void *data); public: - enum IconEngineHook { AvailableSizesHook = 1 }; + enum IconEngineHook { AvailableSizesHook = 1, IconNameHook }; struct AvailableSizesArgument { @@ -92,6 +92,9 @@ public: // ### Qt 5: make this function const and virtual. QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off); + + // ### Qt 5: make this function const and virtual. + QString iconName(); }; QT_END_NAMESPACE diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 72ec2e8..a515ef8 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -554,6 +554,12 @@ void QIconLoaderEngine::virtual_hook(int id, void *data) } } break; + case QIconEngineV2::IconNameHook: + { + QString &name = *reinterpret_cast<QString*>(data); + name = m_iconName; + } + break; default: QIconEngineV2::virtual_hook(id, data); } diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 27f9627..93d5cd3 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -144,7 +144,7 @@ QT_BEGIN_NAMESPACE -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +#ifndef QT_NO_LIBRARY Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QImageIOHandlerFactoryInterface_iid, QLatin1String("/imageformats"))) #endif @@ -205,7 +205,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, QByteArray form = format.toLower(); QImageIOHandler *handler = 0; -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +#ifndef QT_NO_LIBRARY // check if we have plugins that support the image format QFactoryLoader *l = loader(); QStringList keys = l->keys(); @@ -217,7 +217,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, << keys.size() << "plugins available: " << keys; #endif -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +#ifndef QT_NO_LIBRARY int suffixPluginIndex = -1; if (device && format.isEmpty() && autoDetectImageFormat && !ignoresFormatAndExtension) { // if there's no format, see if \a device is a file, and if so, find @@ -246,7 +246,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, if (ignoresFormatAndExtension) testFormat = QByteArray(); -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +#ifndef QT_NO_LIBRARY if (suffixPluginIndex != -1) { // check if the plugin that claims support for this format can load // from this device with this format. @@ -331,7 +331,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, #endif } -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +#ifndef QT_NO_LIBRARY if (!handler && (autoDetectImageFormat || ignoresFormatAndExtension)) { // check if any of our plugins recognize the file from its contents. const qint64 pos = device ? device->pos() : 0; @@ -350,7 +350,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, if (device && !device->isSequential()) device->seek(pos); } -#endif +#endif // QT_NO_LIBRARY if (!handler && (autoDetectImageFormat || ignoresFormatAndExtension)) { // check if any of our built-in handlers recognize the file from its @@ -1414,7 +1414,7 @@ QList<QByteArray> QImageReader::supportedImageFormats() for (int i = 0; i < _qt_NumFormats; ++i) formats << _qt_BuiltInFormats[i].extension; -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +#ifndef QT_NO_LIBRARY QFactoryLoader *l = loader(); QStringList keys = l->keys(); diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index 503a1b2..552729f 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -117,7 +117,7 @@ QT_BEGIN_NAMESPACE -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +#ifndef QT_NO_LIBRARY Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QImageIOHandlerFactoryInterface_iid, QLatin1String("/imageformats"))) #endif @@ -129,7 +129,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, QByteArray suffix; QImageIOHandler *handler = 0; -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +#ifndef QT_NO_LIBRARY // check if any plugins can write the image QFactoryLoader *l = loader(); QStringList keys = l->keys(); @@ -142,7 +142,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, // this allows plugins to override our built-in handlers. if (QFile *file = qobject_cast<QFile *>(device)) { if (!(suffix = QFileInfo(file->fileName()).suffix().toLower().toLatin1()).isEmpty()) { -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +#ifndef QT_NO_LIBRARY int index = keys.indexOf(QString::fromLatin1(suffix)); if (index != -1) suffixPluginIndex = index; @@ -153,7 +153,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, QByteArray testFormat = !form.isEmpty() ? form : suffix; -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +#ifndef QT_NO_LIBRARY if (suffixPluginIndex != -1) { // when format is missing, check if we can find a plugin for the // suffix. @@ -161,7 +161,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, if (plugin && (plugin->capabilities(device, suffix) & QImageIOPlugin::CanWrite)) handler = plugin->create(device, suffix); } -#endif // Q_NO_LIBRARY +#endif // QT_NO_LIBRARY // check if any built-in handlers can write the image if (!handler && !testFormat.isEmpty()) { @@ -192,7 +192,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, } } -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +#ifndef QT_NO_LIBRARY if (!testFormat.isEmpty()) { for (int i = 0; i < keys.size(); ++i) { QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i))); @@ -203,7 +203,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, } } } -#endif +#endif // QT_NO_LIBRARY if (!handler) return 0; @@ -670,7 +670,7 @@ QList<QByteArray> QImageWriter::supportedImageFormats() formats << "png"; #endif -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +#ifndef QT_NO_LIBRARY QFactoryLoader *l = loader(); QStringList keys = l->keys(); for (int i = 0; i < keys.count(); ++i) { |