| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/dbustray/qdbustraytypes.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | static const int IconSizeLimit = 64; | - | ||||||
| 6 | static const int IconNormalSmallSize = 22; | - | ||||||
| 7 | static const int IconNormalMediumSize = 64; | - | ||||||
| 8 | - | |||||||
| 9 | QXdgDBusImageVector iconToQXdgDBusImageVector(const QIcon &icon) | - | ||||||
| 10 | { | - | ||||||
| 11 | QXdgDBusImageVector ret; | - | ||||||
| 12 | QList<QSize> sizes = icon.availableSizes(); | - | ||||||
| 13 | - | |||||||
| 14 | - | |||||||
| 15 | - | |||||||
| 16 | - | |||||||
| 17 | bool hasSmallIcon = false; | - | ||||||
| 18 | bool hasMediumIcon = false; | - | ||||||
| 19 | qreal dpr = (static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio(); | - | ||||||
| 20 | QList<QSize> toRemove; | - | ||||||
| 21 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(sizes)>::type> _container_((sizes)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QSize &size = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||
| 22 | int maxSize = qMax(size.width(), size.height()); | - | ||||||
| 23 | if (maxSize <= IconNormalSmallSize * dpr
| 0 | ||||||
| 24 | hasSmallIcon = true; never executed: hasSmallIcon = true; | 0 | ||||||
| 25 | else if (maxSize <= IconNormalMediumSize * dpr
| 0 | ||||||
| 26 | hasMediumIcon = true; never executed: hasMediumIcon = true; | 0 | ||||||
| 27 | else if (maxSize > IconSizeLimit * dpr
| 0 | ||||||
| 28 | toRemove << size; never executed: toRemove << size; | 0 | ||||||
| 29 | } never executed: end of block | 0 | ||||||
| 30 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(toRemove)>::type> _container_((toRemove)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QSize &size = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||
| 31 | sizes.removeOne(size); never executed: sizes.removeOne(size); | 0 | ||||||
| 32 | if (!hasSmallIcon
| 0 | ||||||
| 33 | sizes.append(QSize(IconNormalSmallSize * dpr, IconNormalSmallSize * dpr)); never executed: sizes.append(QSize(IconNormalSmallSize * dpr, IconNormalSmallSize * dpr)); | 0 | ||||||
| 34 | if (!hasMediumIcon
| 0 | ||||||
| 35 | sizes.append(QSize(IconNormalMediumSize * dpr, IconNormalMediumSize * dpr)); never executed: sizes.append(QSize(IconNormalMediumSize * dpr, IconNormalMediumSize * dpr)); | 0 | ||||||
| 36 | - | |||||||
| 37 | ret.reserve(sizes.size()); | - | ||||||
| 38 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(sizes)>::type> _container_((sizes)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QSize size = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||
| 39 | - | |||||||
| 40 | QImage im = icon.pixmap(size).toImage().convertToFormat(QImage::Format_ARGB32); | - | ||||||
| 41 | - | |||||||
| 42 | if (im.height() != im.width()
| 0 | ||||||
| 43 | int maxSize = qMax(im.width(), im.height()); | - | ||||||
| 44 | QImage padded(maxSize, maxSize, QImage::Format_ARGB32); | - | ||||||
| 45 | padded.fill(Qt::transparent); | - | ||||||
| 46 | QPainter painter(&padded); | - | ||||||
| 47 | painter.drawImage((maxSize - im.width()) / 2, (maxSize - im.height()) / 2, im); | - | ||||||
| 48 | im = padded; | - | ||||||
| 49 | } never executed: end of block | 0 | ||||||
| 50 | - | |||||||
| 51 | QXdgDBusImageStruct kim(im.width(), im.height()); | - | ||||||
| 52 | const uchar *end = im.constBits() + im.byteCount(); | - | ||||||
| 53 | uchar *dest = reinterpret_cast<uchar *>(kim.data.data()); | - | ||||||
| 54 | for (const uchar *src = im.constBits(); src < end
| 0 | ||||||
| 55 | qToUnaligned(qToBigEndian<quint32>(qFromUnaligned<quint32>(src)), dest); never executed: qToUnaligned(qToBigEndian<quint32>(qFromUnaligned<quint32>(src)), dest); | 0 | ||||||
| 56 | - | |||||||
| 57 | ret << kim; | - | ||||||
| 58 | } never executed: end of block | 0 | ||||||
| 59 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||
| 60 | } | - | ||||||
| 61 | - | |||||||
| 62 | - | |||||||
| 63 | const QDBusArgument &operator<<(QDBusArgument &argument, const QXdgDBusImageStruct &icon) | - | ||||||
| 64 | { | - | ||||||
| 65 | argument.beginStructure(); | - | ||||||
| 66 | argument << icon.width; | - | ||||||
| 67 | argument << icon.height; | - | ||||||
| 68 | argument << icon.data; | - | ||||||
| 69 | argument.endStructure(); | - | ||||||
| 70 | return never executed: argument;return argument;never executed: return argument; | 0 | ||||||
| 71 | } | - | ||||||
| 72 | - | |||||||
| 73 | - | |||||||
| 74 | const QDBusArgument &operator>>(const QDBusArgument &argument, QXdgDBusImageStruct &icon) | - | ||||||
| 75 | { | - | ||||||
| 76 | qint32 width; | - | ||||||
| 77 | qint32 height; | - | ||||||
| 78 | QByteArray data; | - | ||||||
| 79 | - | |||||||
| 80 | argument.beginStructure(); | - | ||||||
| 81 | argument >> width; | - | ||||||
| 82 | argument >> height; | - | ||||||
| 83 | argument >> data; | - | ||||||
| 84 | argument.endStructure(); | - | ||||||
| 85 | - | |||||||
| 86 | icon.width = width; | - | ||||||
| 87 | icon.height = height; | - | ||||||
| 88 | icon.data = data; | - | ||||||
| 89 | - | |||||||
| 90 | return never executed: argument;return argument;never executed: return argument; | 0 | ||||||
| 91 | } | - | ||||||
| 92 | - | |||||||
| 93 | - | |||||||
| 94 | const QDBusArgument &operator<<(QDBusArgument &argument, const QXdgDBusImageVector &iconVector) | - | ||||||
| 95 | { | - | ||||||
| 96 | argument.beginArray(qMetaTypeId<QXdgDBusImageStruct>()); | - | ||||||
| 97 | for (int i = 0; i < iconVector.size()
| 0 | ||||||
| 98 | argument << iconVector[i]; | - | ||||||
| 99 | } never executed: end of block | 0 | ||||||
| 100 | argument.endArray(); | - | ||||||
| 101 | return never executed: argument;return argument;never executed: return argument; | 0 | ||||||
| 102 | } | - | ||||||
| 103 | - | |||||||
| 104 | - | |||||||
| 105 | const QDBusArgument &operator>>(const QDBusArgument &argument, QXdgDBusImageVector &iconVector) | - | ||||||
| 106 | { | - | ||||||
| 107 | argument.beginArray(); | - | ||||||
| 108 | iconVector.clear(); | - | ||||||
| 109 | - | |||||||
| 110 | while (!argument.atEnd()
| 0 | ||||||
| 111 | QXdgDBusImageStruct element; | - | ||||||
| 112 | argument >> element; | - | ||||||
| 113 | iconVector.append(element); | - | ||||||
| 114 | } never executed: end of block | 0 | ||||||
| 115 | - | |||||||
| 116 | argument.endArray(); | - | ||||||
| 117 | - | |||||||
| 118 | return never executed: argument;return argument;never executed: return argument; | 0 | ||||||
| 119 | } | - | ||||||
| 120 | - | |||||||
| 121 | - | |||||||
| 122 | const QDBusArgument &operator<<(QDBusArgument &argument, const QXdgDBusToolTipStruct &toolTip) | - | ||||||
| 123 | { | - | ||||||
| 124 | argument.beginStructure(); | - | ||||||
| 125 | argument << toolTip.icon; | - | ||||||
| 126 | argument << toolTip.image; | - | ||||||
| 127 | argument << toolTip.title; | - | ||||||
| 128 | argument << toolTip.subTitle; | - | ||||||
| 129 | argument.endStructure(); | - | ||||||
| 130 | return never executed: argument;return argument;never executed: return argument; | 0 | ||||||
| 131 | } | - | ||||||
| 132 | - | |||||||
| 133 | - | |||||||
| 134 | const QDBusArgument &operator>>(const QDBusArgument &argument, QXdgDBusToolTipStruct &toolTip) | - | ||||||
| 135 | { | - | ||||||
| 136 | QString icon; | - | ||||||
| 137 | QXdgDBusImageVector image; | - | ||||||
| 138 | QString title; | - | ||||||
| 139 | QString subTitle; | - | ||||||
| 140 | - | |||||||
| 141 | argument.beginStructure(); | - | ||||||
| 142 | argument >> icon; | - | ||||||
| 143 | argument >> image; | - | ||||||
| 144 | argument >> title; | - | ||||||
| 145 | argument >> subTitle; | - | ||||||
| 146 | argument.endStructure(); | - | ||||||
| 147 | - | |||||||
| 148 | toolTip.icon = icon; | - | ||||||
| 149 | toolTip.image = image; | - | ||||||
| 150 | toolTip.title = title; | - | ||||||
| 151 | toolTip.subTitle = subTitle; | - | ||||||
| 152 | - | |||||||
| 153 | return never executed: argument;return argument;never executed: return argument; | 0 | ||||||
| 154 | } | - | ||||||
| 155 | - | |||||||
| 156 | - | |||||||
| Switch to Source code | Preprocessed file |