本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}