当前位置: 首页>>代码示例>>C++>>正文


C++ QDBusArgument::endStructure方法代码示例

本文整理汇总了C++中QDBusArgument::endStructure方法的典型用法代码示例。如果您正苦于以下问题:C++ QDBusArgument::endStructure方法的具体用法?C++ QDBusArgument::endStructure怎么用?C++ QDBusArgument::endStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDBusArgument的用法示例。


在下文中一共展示了QDBusArgument::endStructure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getPixmapFromHint

QPixmap Notification::getPixmapFromHint(const QVariant &argument) const
{
    int width, height, rowstride, bitsPerSample, channels;
    bool hasAlpha;
    QByteArray data;

    const QDBusArgument arg = argument.value<QDBusArgument>();
    arg.beginStructure();
    arg >> width;
    arg >> height;
    arg >> rowstride;
    arg >> hasAlpha;
    arg >> bitsPerSample;
    arg >> channels;
    arg >> data;
    arg.endStructure();

    bool rgb = !hasAlpha && channels == 3 && bitsPerSample == 8;
    QImage::Format imageFormat = rgb ? QImage::Format_RGB888 : QImage::Format_ARGB32;

    QImage img = QImage((uchar*)data.constData(), width, height, imageFormat);

    if (!rgb)
        img = img.rgbSwapped();

    return QPixmap::fromImage(img);
}
开发者ID:lxde,项目名称:lxqt-notificationd,代码行数:27,代码来源:notification.cpp

示例2: decodeNotificationSpecImageHint

static QImage decodeNotificationSpecImageHint(const QDBusArgument& arg)
{
    int width, height, rowStride, hasAlpha, bitsPerSample, channels;
    QByteArray pixels;
    char* ptr;
    char* end;

    arg.beginStructure();
    arg >> width >> height >> rowStride >> hasAlpha >> bitsPerSample >> channels >> pixels;
    arg.endStructure();
    //qDebug() << width << height << rowStride << hasAlpha << bitsPerSample << channels;

    #define SANITY_CHECK(condition) \
    if (!(condition)) { \
        qWarning() << "Sanity check failed on" << #condition; \
        return QImage(); \
    }

    SANITY_CHECK(width > 0);
    SANITY_CHECK(width < 2048);
    SANITY_CHECK(height > 0);
    SANITY_CHECK(height < 2048);
    SANITY_CHECK(rowStride > 0);

    #undef SANITY_CHECK

    QImage::Format format = QImage::Format_Invalid;
    void (*fcn)(QRgb*, const char*, int) = 0;
    if (bitsPerSample == 8) {
        if (channels == 4) {
            format = QImage::Format_ARGB32;
            fcn = copyLineARGB32;
        } else if (channels == 3) {
            format = QImage::Format_RGB32;
            fcn = copyLineRGB32;
        }
    }
    if (format == QImage::Format_Invalid) {
        qWarning() << "Unsupported image format (hasAlpha:" << hasAlpha << "bitsPerSample:" << bitsPerSample << "channels:" << channels << ")";
        return QImage();
    }

    QImage image(width, height, format);
    ptr = pixels.data();
    end = ptr + pixels.length();
    for (int y=0; y<height; ++y, ptr += rowStride) {
        if (ptr + channels * width > end) {
            qWarning() << "Image data is incomplete. y:" << y << "height:" << height;
            break;
        }
        fcn((QRgb*)image.scanLine(y), ptr, width);
    }

    return image;
}
开发者ID:linuxdeepin,项目名称:deepin-notifications,代码行数:55,代码来源:bubble.cpp

示例3: decodeImageHint

QImage decodeImageHint(const QDBusArgument &arg)
{
    int width, height, stride, hasAlpha, bitsPerSample, channels;
    QByteArray pixels;

    // Decode hint
    arg.beginStructure();
    arg >> width >> height >> stride >> hasAlpha
        >> bitsPerSample >> channels >> pixels;
    arg.endStructure();

    char *ptr, *end;

    // Sanity check
    if ((width <= 0) || (width >= 2048) || (height <= 0) ||
            (height >= 2048) || (stride <= 0)) {
        qWarning() << "Image hint is not valid!";
        return QImage();
    }

    QImage::Format format = QImage::Format_Invalid;
    void (*function)(QRgb *, const char *, int) = 0;
    if (bitsPerSample == 8) {
        if (channels == 4) {
            format = QImage::Format_ARGB32;
            function = copyLineARGB32;
        } else if (channels == 3) {
            format = QImage::Format_RGB32;
            function = copyLineRGB32;
        }
    }

    if (format == QImage::Format_Invalid) {
        qWarning() << "Unsupported image format received from hint (hasAlpha:"
                   << hasAlpha << "bitsPerSample:" << bitsPerSample
                   << "channels:" << channels << ")";
        return QImage();
    }

    QImage image(width, height, format);
    ptr = pixels.data();
    end = ptr + pixels.length();
    for (int y = 0; y < height; ++y, ptr += stride) {
        if (ptr + channels * width > end) {
            qWarning() << "Image data is incomplete. y:" << y << "height:" << height;
            break;
        }
        function((QRgb *)image.scanLine(y), ptr, width);
    }

    return image;
}
开发者ID:JDHankle,项目名称:hawaii-shell,代码行数:52,代码来源:notificationsimage.cpp

示例4: sipNoMethod

static PyObject *meth_QDBusArgument_endStructure(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        QDBusArgument *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QDBusArgument, &sipCpp))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->endStructure();
            Py_END_ALLOW_THREADS

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QDBusArgument, sipName_endStructure, doc_QDBusArgument_endStructure);

    return NULL;
}
开发者ID:annelida,项目名称:stuff,代码行数:23,代码来源:sipQtDBusQDBusArgument.cpp

示例5: if

static QVariantList
qml_from_dbus(QVariant v)
{
	QVariantList r;
	const char *type=v.typeName();
	switch (v.type()) {
    case QVariant::ULongLong:
        r.append("uint64");
        r.append(v.toULongLong());
        break;
    case QVariant::UInt:
		r.append("uint32");
		r.append(v.toUInt());
		break;
	case QVariant::Int:
		r.append("int32");
		r.append(v.toInt());
		break;
	case QMetaType::UShort:
		r.append("uint16");
		r.append(v.toUInt());
		break;
	case QMetaType::UChar:
		r.append("uint8");
		r.append(v.toUInt());
		break;
	case QVariant::String:
		r.append("string");
		r.append(v.toString());
		break;
	case QVariant::Bool:
		r.append("bool");
		r.append(v.toBool());
		break;
	case QVariant::Double:
		r.append("double");
		r.append(v.toDouble());
		break;
	case QVariant::UserType:
		if (!strcmp(type,"QDBusArgument")) {
			const QDBusArgument arg=v.value < QDBusArgument>();
			QVariantList rl;
			switch(arg.currentType()) {
			case QDBusArgument::ArrayType:
				r.append("array");
				arg.beginArray();
				while (!arg.atEnd()) {
					rl.append(qml_from_dbus(arg.asVariant()));
				}
				r.append(QVariant(rl));
				break;
			case QDBusArgument::StructureType:
				r.append("structure");
				arg.beginStructure();
				while (!arg.atEnd()) {
					rl.append(qml_from_dbus(arg.asVariant()));
				}
				arg.endStructure();
				r.append(QVariant(rl));
				break;
			case QDBusArgument::MapType:
				r.append("map");
				arg.beginMap();
				while (!arg.atEnd()) {
					arg.beginMapEntry();
					rl.append(qml_from_dbus(arg.asVariant()));
					rl.append(qml_from_dbus(arg.asVariant()));
					arg.endMapEntry();
				}
				arg.endMap();
				r.append(QVariant(rl));
				break;
			case QDBusArgument::UnknownType:
				break;
			default:
				printf("Unknown type %d\n",arg.currentType());
				break;
			}
		} else if (!strcmp(type,"QDBusVariant")) {
			const QDBusVariant arg=v.value < QDBusVariant>();
			QVariantList rl;
			r.append("variant");
			rl.append(qml_from_dbus(arg.variant()));
			r.append(QVariant(rl));
		} else {
			printf("User type %s\n",v.typeName());
		}
		break;
	default:
		fprintf(stderr,"Unsupported Arg %s(%d)\n",type,v.type());
	}
	return r;
}
开发者ID:GENIVI,项目名称:navigation-application,代码行数:93,代码来源:dbusif.cpp


注:本文中的QDBusArgument::endStructure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。