const QSize LayoutsSettings::getReplayMessageLayoutSize() { QVariant previous = getValue("layouts/replayplayarea_MessageLayoutSize"); return previous == QVariant() ? QSize(250, 200) : previous.toSize(); }
void QSGPropertyAnimator::updateProperty(QObject *target, const QString& p) { QSGAnimatedProperty *ap = m_controller->registeredProperty(p, target); if (ap && m_duration > 0) { if (m_elapsed > m_startTime && ((m_elapsed < m_startTime + m_loops * m_duration) || (m_loops < 0))) { QVariant value = ap->value(); qreal tx = int(m_elapsed - m_startTime) % int(m_duration); switch (value.type()) { case QMetaType::Double: value = QVariant(m_from.toReal() + (m_to.toReal() - m_from.toReal()) * m_easing.valueForProgress(tx / m_duration)); break; case QMetaType::QColor: { QColor from = qvariant_cast<QColor>(m_from); QColor to = qvariant_cast<QColor>(m_to); QColor result = qvariant_cast<QColor>(value); result.setRed(from.red() + (to.red() - from.red()) * m_easing.valueForProgress(tx / m_duration)); result.setGreen(from.green() + (to.green() - from.green()) * m_easing.valueForProgress(tx / m_duration)); result.setBlue(from.blue() + (to.blue() - from.blue()) * m_easing.valueForProgress(tx / m_duration)); result.setAlpha(from.alpha() + (to.alpha() - from.alpha()) * m_easing.valueForProgress(tx / m_duration)); value = result; break; } case QMetaType::Int: value = QVariant(m_from.toInt() + (m_to.toInt() - m_from.toInt()) * m_easing.valueForProgress(tx / m_duration)); break; case QMetaType::QSize: { QSize from = m_from.toSize(); QSize to = m_to.toSize(); QSize result = value.toSize(); result.setWidth(from.width() + (to.width() - from.width()) * m_easing.valueForProgress(tx / m_duration)); result.setHeight(from.height() + (to.height() - from.height()) * m_easing.valueForProgress(tx / m_duration)); value = result; break; } case QMetaType::QSizeF: { QSizeF from = m_from.toSize(); QSizeF to = m_to.toSize(); QSizeF result = value.toSize(); result.setWidth(from.width() + (to.width() - from.width()) * m_easing.valueForProgress(tx / m_duration)); result.setHeight(from.height() + (to.height() - from.height()) * m_easing.valueForProgress(tx / m_duration)); value = result; break; } case QMetaType::QPoint: { QPoint from = m_from.toPoint(); QPoint to = m_to.toPoint(); QPoint result = value.toPoint(); result.setX(from.x() + (to.x() - from.x()) * m_easing.valueForProgress(tx / m_duration)); result.setY(from.y() + (to.y() - from.y()) * m_easing.valueForProgress(tx / m_duration)); value = result; break; } case QMetaType::QPointF: { QPointF from = m_from.toPointF(); QPointF to = m_to.toPointF(); QPointF result = value.toPointF(); result.setX(from.x() + (to.x() - from.x()) * m_easing.valueForProgress(tx / m_duration)); result.setY(from.y() + (to.y() - from.y()) * m_easing.valueForProgress(tx / m_duration)); value = result; break; } case QMetaType::QRect: { QRect from = m_from.toRect(); QRect to = m_to.toRect(); QRect result = value.toRect(); result.setX(from.x() + (to.x() - from.x()) * m_easing.valueForProgress(tx / m_duration)); result.setY(from.y() + (to.y() - from.y()) * m_easing.valueForProgress(tx / m_duration)); result.setWidth(from.width() + (to.width() - from.width()) * m_easing.valueForProgress(tx / m_duration)); result.setHeight(from.height() + (to.height() - from.height()) * m_easing.valueForProgress(tx / m_duration)); value = result; break; } case QMetaType::QRectF: { QRectF from = m_from.toRectF(); QRectF to = m_to.toRectF(); QRectF result = value.toRectF(); result.setX(from.x() + (to.x() - from.x()) * m_easing.valueForProgress(tx / m_duration)); result.setY(from.y() + (to.y() - from.y()) * m_easing.valueForProgress(tx / m_duration)); result.setWidth(from.width() + (to.width() - from.width()) * m_easing.valueForProgress(tx / m_duration)); result.setHeight(from.height() + (to.height() - from.height()) * m_easing.valueForProgress(tx / m_duration)); value = result; break; } case QMetaType::QVector3D: { QVector3D from = qvariant_cast<QVector3D>(m_from); QVector3D to = qvariant_cast<QVector3D>(m_to); QVector3D result = qvariant_cast<QVector3D>(value); result.setX(from.x() + (to.x() - from.x()) * m_easing.valueForProgress(tx / m_duration)); result.setY(from.y() + (to.y() - from.y()) * m_easing.valueForProgress(tx / m_duration)); result.setZ(from.z() + (to.z() - from.z()) * m_easing.valueForProgress(tx / m_duration)); value = result; break; } default: break; } ap->setValue(value); } } }
VCAudioTriggers::VCAudioTriggers(QWidget* parent, Doc* doc) : VCWidget(parent, doc) , m_hbox(NULL) , m_button(NULL) , m_label(NULL) , m_spectrum(NULL) #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) , m_volumeSlider(NULL) #endif , m_inputCapture(NULL) { /* Set the class name "VCAudioTriggers" as the object name as well */ setObjectName(VCAudioTriggers::staticMetaObject.className()); setType(VCWidget::AudioTriggersWidget); setFrameStyle(KVCFrameStyleSunken); new QVBoxLayout(this); /* Main HBox */ m_hbox = new QHBoxLayout(); m_hbox->setGeometry(QRect(0, 0, 300, 40)); layout()->setSpacing(2); layout()->setContentsMargins(4, 4, 4, 4); layout()->addItem(m_hbox); m_button = new QToolButton(this); m_button->setStyle(AppUtil::saneStyle()); m_button->setIconSize(QSize(32, 32)); m_button->setMinimumSize(QSize(32, 32)); m_button->setMaximumSize(QSize(32, 32)); m_button->setIcon(QIcon(":/check.png")); m_button->setCheckable(true); QString btnSS = "QToolButton { background-color: #E0DFDF; border: 1px solid gray; border-radius: 3px; padding: 3px; } "; btnSS += "QToolButton:checked { background-color: #D7DE75; border: 1px solid gray; border-radius: 3px; padding: 3px; } "; m_button->setStyleSheet(btnSS); m_button->setEnabled(false); m_hbox->addWidget(m_button); connect(m_button, SIGNAL(toggled(bool)), this, SLOT(slotEnableButtonToggled(bool))); m_label = new QLabel(this); m_label->setText(this->caption()); QString txtColor = "white"; if (m_hasCustomForegroundColor) txtColor = this->foregroundColor().name(); m_label->setStyleSheet("QLabel { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #345D27, stop: 1 #0E1A0A); " "color: " + txtColor + "; border-radius: 3px; padding: 3px; margin-left: 2px; }"); if (m_hasCustomFont) m_label->setFont(font()); else { QFont m_font = QApplication::font(); m_font.setBold(true); m_font.setPixelSize(12); m_label->setFont(m_font); } m_hbox->addWidget(m_label); QSharedPointer<AudioCapture> capture(m_doc->audioInputCapture()); m_inputCapture = capture.data(); // create the AudioBar items to hold the spectrum data. // To be loaded from the project m_volumeBar = new AudioBar(AudioBar::None, 0); for (int i = 0; i < m_inputCapture->defaultBarsNumber(); i++) { AudioBar *asb = new AudioBar(AudioBar::None, 0); m_spectrumBars.append(asb); } #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QHBoxLayout *hbox2 = new QHBoxLayout(); m_volumeSlider = new ClickAndGoSlider(this); m_volumeSlider->setOrientation(Qt::Vertical); m_volumeSlider->setRange(0, 100); m_volumeSlider->setSliderStyleSheet(CNG_DEFAULT_STYLE); m_volumeSlider->setValue(100); m_volumeSlider->setFixedWidth(32); m_volumeSlider->setEnabled(false); connect(m_volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(slotVolumeChanged(int))); #endif m_spectrum = new AudioTriggerWidget(this); m_spectrum->setBarsNumber(m_inputCapture->defaultBarsNumber()); m_spectrum->setMaxFrequency(AudioCapture::maxFrequency()); m_spectrum->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) layout()->addWidget(m_spectrum); #else layout()->addItem(hbox2); hbox2->addWidget(m_spectrum); hbox2->addWidget(m_volumeSlider); #endif /* Initial size */ QSettings settings; QVariant var = settings.value(SETTINGS_AUDIOTRIGGERS_SIZE); if (var.isValid() == true) resize(var.toSize()); else resize(defaultSize); slotModeChanged(m_doc->mode()); }
bool DomConvenience::variantToElement(const QVariant& v, QDomElement& e) { bool ok = true; clearAttributes(e); switch (v.type()) { case QVariant::String: e.setTagName("string"); e.setAttribute("value", v.toString().utf8()); break; case QVariant::CString: e.setTagName("string"); e.setAttribute("value", v.toCString()); break; case QVariant::Int: e.setTagName("int"); e.setAttribute("value", v.toInt()); break; case QVariant::UInt: e.setTagName("uint"); e.setAttribute("value", v.toUInt()); break; case QVariant::Double: e.setTagName("double"); e.setAttribute("value", v.toDouble()); break; case QVariant::Bool: e.setTagName("bool"); e.setAttribute("value", boolString(v.toBool())); break; case QVariant::Color: { e.setTagName("color"); QColor color = v.toColor(); e.setAttribute("red", color.red()); e.setAttribute("green", color.green()); e.setAttribute("blue", color.blue()); } break; case QVariant::Pen: { e.setTagName("pen"); QPen pen = v.toPen(); e.setAttribute("red", pen.color().red()); e.setAttribute("green", pen.color().green()); e.setAttribute("blue", pen.color().blue()); e.setAttribute("style", pen.style()); e.setAttribute("cap", pen.capStyle()); e.setAttribute("join", pen.joinStyle()); } break; case QVariant::Brush: { e.setTagName("brush"); QBrush brush = v.toBrush(); e.setAttribute("red", brush.color().red()); e.setAttribute("green", brush.color().green()); e.setAttribute("blue", brush.color().blue()); e.setAttribute("style", brush.style()); } break; case QVariant::Point: { e.setTagName("point"); QPoint point = v.toPoint(); e.setAttribute("x", point.x()); e.setAttribute("y", point.y()); } break; case QVariant::Rect: { e.setTagName("rect"); QRect rect = v.toRect(); e.setAttribute("x", rect.x()); e.setAttribute("y", rect.y()); e.setAttribute("width", rect.width()); e.setAttribute("height", rect.height()); } break; case QVariant::Size: { e.setTagName("size"); QSize qsize = v.toSize(); e.setAttribute("width", qsize.width()); e.setAttribute("height", qsize.height()); } break; case QVariant::Font: { e.setTagName("font"); QFont f(v.toFont()); e.setAttribute("family", f.family()); e.setAttribute("pointsize", f.pointSize()); e.setAttribute("bold", boolString(f.bold())); e.setAttribute("italic", boolString(f.italic())); e.setAttribute("underline", boolString(f.underline())); e.setAttribute("strikeout", boolString(f.strikeOut())); } break; case QVariant::SizePolicy: { e.setTagName("sizepolicy"); QSizePolicy sp(v.toSizePolicy()); e.setAttribute("hsizetype", sp.horData()); e.setAttribute("vsizetype", sp.verData()); #if (QT_VERSION >= 300) e.setAttribute("horstretch", sp.horStretch()); e.setAttribute("verstretch", sp.verStretch()); #endif } break; case QVariant::Cursor: e.setTagName("cursor"); e.setAttribute("shape", v.toCursor().shape()); break; case QVariant::StringList: { e.setTagName("stringlist"); uint j; QDomNode n; QDomNodeList stringNodeList = e.elementsByTagName("string"); QDomElement stringElem; QStringList stringList = v.toStringList(); QStringList::Iterator it = stringList.begin(); for (j = 0; ((j < stringNodeList.length()) && (it != stringList.end())); j++) { // get the current string element stringElem = stringNodeList.item(j).toElement(); // set it to the current string variantToElement(QVariant(*it), stringElem); // iterate to the next string ++it; } // more nodes in previous stringlist then current, remove excess nodes if (stringNodeList.count() > stringList.count()) { while (j < stringNodeList.count()) e.removeChild(stringNodeList.item(j).toElement()); } else if (j <stringList.count()) { while (it != stringList.end()) { // create a new element stringElem = m_doc.createElement("string"); // set it to the currentstring variantToElement(QVariant(*it), stringElem); // append it to the current element e.appendChild(stringElem); // iterate to the next string ++it; } } } break; #if QT_VERSION >= 300 case QVariant::KeySequence: e.setTagName("key"); e.setAttribute("sequence", (QString)v.toKeySequence()); break; #endif case QVariant::ByteArray: // this is only for [u]int64_t { e.setTagName("uint64"); QByteArray ba = v.toByteArray(); // make sure this only handles [u]int64_t's if (ba.size() != sizeof(uint64_t)) { qWarning("Don't know how to persist variant of type: %s (%d) (size=%d)!", v.typeName(), v.type(), ba.size()); ok = false; break; } // convert the data back into a uint64_t uint64_t num = *(uint64_t*)ba.data(); QChar buff[33]; QChar* p = &buff[32]; const char* digitSet = "0123456789abcdef"; int len = 0; // construct the string do { *--p = digitSet[((int)(num%16))]; num = num >> 4; // divide by 16 len++; } while ( num ); // store it in a QString QString storage; storage.setUnicode(p, len); // set the value e.setAttribute("value", storage); } break; #if 0 case QVariant::List: case QVaraint::Map: #endif default: qWarning("Don't know how to persist variant of type: %s (%d)!", v.typeName(), v.type()); ok = false; break; } return ok; }
VCXYPad::VCXYPad(QWidget* parent, Doc* doc) : VCWidget(parent, doc) { /* Set the class name "VCXYPad" as the object name as well */ setObjectName(VCXYPad::staticMetaObject.className()); m_hbox = new QHBoxLayout(this); m_lvbox = new QVBoxLayout; m_lvbox->addSpacing(20); m_vRangeSlider = new ctkRangeSlider(this); m_lvbox->addWidget(m_vRangeSlider); m_lvbox->addSpacing(25); m_hbox->addLayout(m_lvbox); m_cvbox = new QVBoxLayout; m_hbox->addLayout(m_cvbox); m_hRangeSlider = new ctkRangeSlider(Qt::Horizontal, this); m_cvbox->addWidget(m_hRangeSlider); m_area = new VCXYPadArea(this); m_cvbox->addWidget(m_area); m_hSlider = new QSlider(Qt::Horizontal, this); m_cvbox->addWidget(m_hSlider); m_rvbox = new QVBoxLayout; m_hbox->addLayout(m_rvbox); m_rvbox->addSpacing(20); m_vSlider = new QSlider(this); m_rvbox->addWidget(m_vSlider); m_rvbox->addSpacing(25); m_vSlider->setRange(0, 256); m_hSlider->setRange(0, 256); m_vSlider->setInvertedAppearance(true); m_vSlider->setTickPosition(QSlider::TicksLeft); m_vSlider->setTickInterval(16); m_hSlider->setTickPosition(QSlider::TicksAbove); m_hSlider->setTickInterval(16); m_vSlider->setStyle(AppUtil::saneStyle()); m_hSlider->setStyle(AppUtil::saneStyle()); m_hRangeSlider->setRange(0, 256); m_vRangeSlider->setInvertedAppearance(true); m_vRangeSlider->setRange(0, 256); m_hRangeSlider->setMaximumPosition(256); m_vRangeSlider->setMaximumPosition(256); connect(m_area, SIGNAL(positionChanged(const QPointF&)), this, SLOT(slotPositionChanged(const QPointF&))); connect(this, SIGNAL(fixturePositions(const QVariantList)), m_area, SLOT(slotFixturePositions(const QVariantList))); connect(m_vSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSliderValueChanged())); connect(m_hSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSliderValueChanged())); connect(m_hRangeSlider, SIGNAL(positionsChanged(int,int)), this, SLOT(slotRangeValueChanged())); connect(m_vRangeSlider, SIGNAL(positionsChanged(int,int)), this, SLOT(slotRangeValueChanged())); setFrameStyle(KVCFrameStyleSunken); setType(VCWidget::XYPadWidget); setCaption("XY Pad"); setMinimumSize(20, 20); QSettings settings; QVariant var = settings.value(SETTINGS_XYPAD_SIZE); if (var.isValid() == true) resize(var.toSize()); else resize(QSize(230, 230)); m_padInteraction = false; m_sliderInteraction = false; m_inputValueChanged = false; slotModeChanged(Doc::Design); }
QString VariantHandler::displayString(const QVariant &value) { switch (value.type()) { #ifndef QT_NO_CURSOR case QVariant::Cursor: { const QCursor cursor = value.value<QCursor>(); return Util::enumToString(QVariant::fromValue<int>(cursor.shape()), "Qt::CursorShape"); } #endif case QVariant::Icon: { const QIcon icon = value.value<QIcon>(); if (icon.isNull()) { return QObject::tr("<no icon>"); } QStringList l; foreach (const QSize &size, icon.availableSizes()) { l.push_back(displayString(size)); } return l.join(QLatin1String(", ")); } case QVariant::Line: return QString::fromUtf8("%1, %2 → %3, %4"). arg(value.toLine().x1()).arg(value.toLine().y1()). arg(value.toLine().x2()).arg(value.toLine().y2()); case QVariant::LineF: return QString::fromUtf8("%1, %2 → %3, %4"). arg(value.toLineF().x1()).arg(value.toLineF().y1()). arg(value.toLineF().x2()).arg(value.toLineF().y2()); case QVariant::Locale: return value.value<QLocale>().name(); case QVariant::Point: return QString::fromLatin1("%1, %2"). arg(value.toPoint().x()). arg(value.toPoint().y()); case QVariant::PointF: return QString::fromLatin1("%1, %2"). arg(value.toPointF().x()). arg(value.toPointF().y()); case QVariant::Rect: return QString::fromLatin1("%1, %2 %3 x %4"). arg(value.toRect().x()). arg(value.toRect().y()). arg(value.toRect().width()). arg(value.toRect().height()); case QVariant::RectF: return QString::fromLatin1("%1, %2 %3 x %4"). arg(value.toRectF().x()). arg(value.toRectF().y()). arg(value.toRectF().width()). arg(value.toRectF().height()); case QVariant::Region: { const QRegion region = value.value<QRegion>(); if (region.isEmpty()) { return QLatin1String("<empty>"); } if (region.rectCount() == 1) { return displayString(region.rects().first()); } else { return QString::fromLatin1("<%1 rects>").arg(region.rectCount()); } } case QVariant::Palette: { const QPalette pal = value.value<QPalette>(); if (pal == qApp->palette()) { return QLatin1String("<inherited>"); } return QLatin1String("<custom>"); } case QVariant::Size: return QString::fromLatin1("%1 x %2"). arg(value.toSize().width()). arg(value.toSize().height()); case QVariant::SizeF: return QString::fromLatin1("%1 x %2"). arg(value.toSizeF().width()). arg(value.toSizeF().height()); case QVariant::StringList: return value.toStringList().join(", "); case QVariant::Transform: { const QTransform t = value.value<QTransform>(); return QString::fromLatin1("[%1 %2 %3, %4 %5 %6, %7 %8 %9]"). arg(t.m11()).arg(t.m12()).arg(t.m13()). arg(t.m21()).arg(t.m22()).arg(t.m23()). arg(t.m31()).arg(t.m32()).arg(t.m33()); } default: break; } // types with dynamic type ids if (value.type() == (QVariant::Type)qMetaTypeId<QTextLength>()) { const QTextLength l = value.value<QTextLength>(); QString typeStr; switch (l.type()) { case QTextLength::VariableLength: typeStr = QObject::tr("variable"); break; case QTextLength::FixedLength: typeStr = QObject::tr("fixed"); break; case QTextLength::PercentageLength: typeStr = QObject::tr("percentage"); break; } return QString::fromLatin1("%1 (%2)").arg(l.rawValue()).arg(typeStr); } if (value.userType() == qMetaTypeId<QPainterPath>()) { const QPainterPath path = value.value<QPainterPath>(); if (path.isEmpty()) { return QObject::tr("<empty>"); } return QObject::tr("<%1 elements>").arg(path.elementCount()); } if (value.userType() == qMetaTypeId<QMargins>()) { const QMargins margins = value.value<QMargins>(); return QObject::tr("left: %1, top: %2, right: %3, bottom: %4") .arg(margins.left()).arg(margins.top()) .arg(margins.right()).arg(margins.bottom()); } if (value.canConvert<QObject*>()) { return Util::displayString(value.value<QObject*>()); } if (value.userType() == qMetaTypeId<QMatrix4x4>()) { return displayMatrix4x4(value.value<QMatrix4x4>()); } if (value.userType() == qMetaTypeId<const QMatrix4x4*>()) { return displayMatrix4x4(value.value<const QMatrix4x4*>()); } #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if (value.userType() == qMetaTypeId<QSet<QByteArray> >()) { const QSet<QByteArray> set = value.value<QSet<QByteArray> >(); QStringList l; foreach (const QByteArray &b, set) { l.push_back(QString::fromUtf8(b)); } return l.join(", "); }
void QGIPiece::propertySet( char const *pname, QVariant const & var ) { // FIXME: treat QVariant::Invalid appropriately for each property typedef QMap<QString,int> PMAP; static PMAP pmap; if( pmap.isEmpty() ) { #define MAP(S,V) pmap[S] = Impl::V; MAP("color",PropColor); MAP("alpha",PropAlpha); MAP("colorAlpha",PropAlpha); // older name MAP("borderColor",PropBorderColor); MAP("borderSize",PropBorderSize); MAP("borderAlpha",PropBorderAlpha); MAP("borderStyle",PropBorderStyle); MAP("zLevel",PropZLevel); MAP("pos",PropPos); MAP("scale",PropScale); MAP("size",PropSize); MAP("angle",PropAngle); MAP("dragDisabled",PropDragDisabled); MAP("pixmap",PropPixmap); #undef MAP } const QString key(pname?pname:""); int kid = pmap.value( key, Impl::PropUnknown ); if( Impl::PropUnknown == kid ) return; if(0) qDebug() << "QGIPiece::propertySet("<<key<<")] val ="<<var; if( Impl::PropZLevel == kid ) { this->setZValue(var.toDouble()); this->update(); } else if( Impl::PropPos == kid ) { this->setPos( var.value<QPointF>() ); this->update(); } else if( Impl::PropColor == kid ) { QColor col = var.value<QColor>(); qreal alpha = impl->pen.color().alphaF(); if( 255 == col.alpha() ) // keep original alpha level { if( alpha > 1 ) { col.setAlpha( int(alpha) ); } else { col.setAlphaF( alpha ); } } impl->pen.setColor( col ); if(0) qDebug() << "QGIPiece::propertySet(color):"<<impl->pen.color()<<" alpha ="<<impl->alpha; impl->clearCache(); this->update(); } else if( Impl::PropAlpha == kid ) { qreal a = var.toDouble(); QColor col = impl->pen.color(); if( a > 1.0 ) { // assume it's int-encoded col.setAlpha( int(a) ); } else { col.setAlphaF( a ); } impl->pen.setColor( col ); impl->clearCache(); this->update(); } else if( Impl::PropBorderColor == kid ) { QColor col = var.value<QColor>(); if( 255 == col.alpha() ) { col.setAlphaF( impl->penB.color().alphaF() ); } impl->penB.setColor( col ); impl->clearCache(); this->update(); } else if( Impl::PropBorderAlpha == kid ) { qreal a = var.toDouble(); QColor col( impl->penB.color() ); if( a > 1.0 ) { // assume it's int-encoded col.setAlpha( int(a) ); } else { col.setAlphaF( a ); } impl->penB.setColor( col ); impl->clearCache(); this->update(); } else if( Impl::PropBorderSize == kid ) { double bs = var.toDouble(); impl->penB.setWidth( (bs >= 0) ? bs : 0 ); impl->clearCache(); this->update(); } else if( Impl::PropBorderStyle == kid ) { impl->clearCache(); impl->penB.setStyle( s11n::qt::stringToPenStyle(var.toString()) ); this->update(); } else if( (Impl::PropScale == kid) || (Impl::PropAngle == kid) ) { this->refreshTransformation(); } else if( Impl::PropDragDisabled == kid ) { if( var.isValid() ) { this->setFlag( QGraphicsItem::ItemIsMovable, var.toInt() ? false : true ); } else { this->setFlag( QGraphicsItem::ItemIsMovable, true ); } } else if( Impl::PropPixmap == kid ) { this->prepareGeometryChange(); impl->clearCache(); QPixmap pix; if( var.canConvert<QPixmap>() ) { pix = var.value<QPixmap>(); } else if( var.canConvert<QString>() ) { QString fname( qboard::homeRelative(var.toString()) ); if( pix.load( fname ) ) { this->setProperty("size",pix.size()); } else { pix = QPixmap(300,40); QPainter pain(&pix); pain.fillRect( pix.rect(), Qt::yellow ); QFont font( "courier", 8 ); pain.setFont( font ); pain.setPen( QPen(Qt::red) ); pain.drawText(5,font.pointSize()+6,"Error loading pixmap:"); pain.drawText(5,pix.height()-6,fname); } } // var.canConvert<QString>() this->impl->pixmap = pix; if(1) { // Kludge to ensure that this type's shape is properly set. We don't want // the parent class to have the real pixmap, so that we can control all // painting ourselves. QPixmap bogus( pix.size() ); bogus.fill( QColor(Qt::transparent) ); this->setPixmap(bogus); } this->update(); } // pixmap property if( Impl::PropSize == kid ) { impl->clearCache(); if( impl->pixmap.isNull() ) { QPixmap bogus( var.toSize() ); bogus.fill( QColor(Qt::transparent) ); impl->pixmap = bogus; // Kludge to ensure bounding rect is kept intact this->setPixmap(bogus); } } }
bool KCoreConfigSkeleton::ItemSize::isEqual(const QVariant &v) const { return mReference == v.toSize(); }
void process(const QObject * obj){ if(obj != NULL){ QListViewItem * buf = __current; __current = new QListViewItem(__current,obj->className(),QString(obj->name())); __current->setPixmap(0,__pixgeom); QMetaObject* _m = obj->metaObject(); QListViewItem * att = NULL; if(_m != NULL){ QString _superclass(_m->superClassName()); if(!_superclass.isEmpty()){ att = new QListViewItem(__current,"Inherit",_superclass); att->setPixmap(0,__pixattptr); QMetaObject* _meta = _m->superClass(); QListViewItem * att4 = NULL; while((_meta = _meta->superClass())!= NULL){ att4 = new QListViewItem(att,att4,QString(_meta->className())); att4->setPixmap(0,__pixatt); } } att = new QListViewItem(__current,att,"Priority",(obj->highPriority()?"High":"Normal")); att->setPixmap(0,__pixatt); att = new QListViewItem(__current,att,"Widget",(obj->isWidgetType()?"True":"False")); att->setPixmap(0,__pixatt); QStrList _slots = _m->slotNames(true); if(!_slots.isEmpty()){ att = new QListViewItem(__current,att,"Slots"); att->setPixmap(0,__pixtransf); uint sl_size = _slots.count(); QListViewItem * att2 = NULL; for(uint j = 0; j < sl_size; j++ ){ att2 = new QListViewItem(att,att2,_slots.at(j)); att2->setPixmap(0,__pixatt); } } QStrList _signals = _m->signalNames(true); if(!_signals.isEmpty()){ att = new QListViewItem(__current,att,"Signals"); att->setPixmap(0,__pixtransf); uint si_size = _signals.count(); QListViewItem * att2 = NULL; for(uint j = 0; j < si_size; j++ ){ att2 = new QListViewItem(att,att2,_signals.at(j)); att2->setPixmap(0,__pixatt); } } int numCInfo = _m->numClassInfo(true); if(numCInfo !=0){ att = new QListViewItem(__current,att,"ClassInfo","List<Info>["+QString::number(numCInfo)+']'); att->setPixmap(0,__pixtransf); QListViewItem * att2 = NULL; for(int j = 0; j < numCInfo; j++ ){ const QClassInfo * _inf = _m->classInfo(j); if(_inf != NULL){ att2 = new QListViewItem(att,att2,QString(_inf->name),QString(_inf->value)); att2->setPixmap(0,__pixatt); } } } QStrList _props = _m->propertyNames(true); if(!_props.isEmpty()){ att = new QListViewItem(__current,att,"Properties"); att->setPixmap(0,__pixtransf); uint p_size = _props.count(); QListViewItem * att2 = NULL; for(uint j = 0; j < p_size; j++ ){ att2 = new QListViewItem(att,att2,_props.at(j)); att2->setPixmap(0,__pixatt); QVariant val; QString propname(_props.at(j)); #if QT_VERSION >= 300 const QMetaProperty* prop = _m->property (j,true); #else const QMetaProperty* prop = _m->property (propname,true); #endif QString proptype; if(prop){ proptype = prop->type(); att2->setText(2,proptype); /* QListViewItem * att3 = new QListViewItem(att2,"Writable",(prop->writable()?"True":"False")); att3->setPixmap(0,__pixatt); att3 = new QListViewItem(att2,att3,"Designable",(prop->designable()?"True":"False")); att3->setPixmap(0,__pixatt); */ } val = obj->property(propname); if(!val.isValid())att2->setText(1,"Invalid"); else if(prop->isEnumType()){ att2->setText(1,prop->valueToKey(val.toInt())); } else if(prop->isSetType()){ QStrList st = prop->valueToKeys(val.toInt()); QString t = st.at(0); for(uint i= 1; i < st.count(); i++)t+='/'+st.at(i); att2->setText(1,t); } else if(val.type() == QVariant::String)att2->setText(1,'"'+val.toString()+'"'); else if(val.type() == QVariant::CString)att2->setText(1,'"'+val.toCString()+'"'); else if(val.type() == QVariant::Bool){ if(val.toBool())att2->setText(1,"True"); else att2->setText(1,"False"); } else if(val.type() == QVariant::Int)att2->setText(1,QString::number(val.toInt())); else if(val.type() == QVariant::UInt)att2->setText(1,QString::number(val.toUInt())); else if(val.type() == QVariant::Double)att2->setText(1,QString::number(val.toDouble())); else if(val.type() == QVariant::Rect){ const QRect r = val.toRect(); att2->setText(1,'[' + QString::number(r.left()) + ',' + QString::number(r.top())+ ',' + QString::number(r.right()) + ',' + QString::number(r.bottom())+']'); } else if(val.type() == QVariant::Region){ const QRegion reg = val.toRegion(); QRect r = reg.boundingRect(); att2->setText(1,'[' + QString::number(r.left()) + ',' + QString::number(r.top())+ ',' + QString::number(r.right()) + ',' + QString::number(r.bottom())+"],"); } else if(val.type() == QVariant::Size){ const QSize s = val.toSize(); att2->setText(1,'[' + QString::number(s.width()) + ',' + QString::number(s.height())+']'); } else if(val.type() == QVariant::Point){ const QPoint p = val.toPoint(); att2->setText(1,'[' + QString::number(p.x()) + ',' + QString::number(p.y())+']'); } else if(val.type() == QVariant::Color){ const QColor c = val.toColor(); att2->setText(1,'[' + QString::number(c.red()) + ',' + QString::number(c.green()) + ',' + QString::number(c.blue()) + ']'); } else if(val.type() == QVariant::ColorGroup){ const QColorGroup cg = val.toColorGroup(); QColor c = cg.base(); att2->setText(1,'[' + QString::number(c.red()) + ',' + QString::number(c.green()) + ',' + QString::number(c.blue()) + "], ..."); } else if(val.type() == QVariant::Font){ const QFont f = val.toFont(); QString text = '\'' + f.family() + "', " + QString::number(f.pointSize()) + ", " + QString::number(f.weight()); if(f.italic())text+=", italic"; att2->setText(1,text); } else if(val.type() == QVariant::SizePolicy){ QSizePolicy sp = val.toSizePolicy(); QString text; if(sp.horData() == QSizePolicy::Fixed)text+="Fixed"; else if(sp.horData() == QSizePolicy::Minimum )text+="Minimum"; else if(sp.horData() == QSizePolicy::Maximum )text+="Maximum"; else if(sp.horData() == QSizePolicy::Preferred )text+="Preferred"; else if(sp.horData() == QSizePolicy::MinimumExpanding )text+="MinimumExpanding"; else if(sp.horData() == QSizePolicy::Expanding )text+="Expanding"; text +='/'; if(sp.verData() == QSizePolicy::Fixed)text+="Fixed"; else if(sp.verData() == QSizePolicy::Minimum )text+="Minimum"; else if(sp.verData() == QSizePolicy::Maximum )text+="Maximum"; else if(sp.verData() == QSizePolicy::Preferred )text+="Preferred"; else if(sp.verData() == QSizePolicy::MinimumExpanding )text+="MinimumExpanding"; else if(sp.verData() == QSizePolicy::Expanding )text+="Expanding"; att2->setText(1,text); } else if(val.type() == QVariant::Pixmap){ QPixmap pix = val.toPixmap(); if(!pix.isNull())att2->setPixmap(1,pix); } else if(val.type() == QVariant::Cursor){ const QCursor cur = val.toCursor(); const QBitmap * pix = cur.bitmap(); if(pix && !pix->isNull())att2->setPixmap(1,*pix); else att2->setText(1,QString::number(cur.shape())); } } } } const QObjectList * roots = obj->children(); if(roots != NULL){ __current = new QListViewItem(__current,att,"children","ptr="+QString::number((unsigned long)roots), "List<QObject>["+QString::number(roots->count())+"]"); __current->setPixmap(0,__pixappe); QObjectList r(*roots); uint size = r.count(); for(uint i = 0; i < size; i++ ){ QObject * _obj = r.at(i); process(_obj); } } __current = buf; } }
const QSize LayoutsSettings::getGameCardInfoSize() { QVariant previous = getValue("layouts/gameplayarea_CardInfoSize"); return previous == QVariant() ? QSize(250, 360) : previous.toSize(); }
void KCoreConfigSkeleton::ItemSize::setProperty(const QVariant & p) { mReference = p.toSize(); }
const QSize LayoutsSettings::getDeckEditorFilterSize() { QVariant previous = getValue("layouts/deckEditor_FilterSize"); return previous == QVariant() ? QSize(250, 250) : previous.toSize(); }
const QSize LayoutsSettings::getReplayReplaySize() { QVariant previous = getValue("layouts/replayplayarea_ReplaySize"); return previous == QVariant() ? QSize(900, 100) : previous.toSize(); }
const QSize LayoutsSettings::getReplayPlayerListSize() { QVariant previous = getValue("layouts/replayplayarea_PlayerListSize"); return previous == QVariant() ? QSize(250, 50) : previous.toSize(); }
void QDetaliiTabDialog::saveConfiguration() { QString fileName = QFileDialog::getSaveFileName(this, tr("Save layout"),"./","*.ccf"); if (fileName.isEmpty()) return; if (fileName.right(4) != ".ccf") fileName += ".ccf"; QFile file(fileName); if (!file.open(QFile::WriteOnly | QIODevice::Text)) { QString msg = tr("Failed to open %1\n%2") .arg(fileName) .arg(file.errorString()); QMessageBox::warning(this, tr("Error"), msg); return; } bool ok = true; QTextStream text(&file); QSettings settings; QVariant settingsValue; QStringList settingsKeys = settings.allKeys(); QList<QString>::iterator j; QString settingsType; QString stringValue; bool okInt; for (j = settingsKeys.begin(); j != settingsKeys.end(); ++j) { settingsValue = settings.value(*j); settingsType = settingsValue.typeName(); if (settingsType == "QString") { stringValue = settingsValue.toString(); stringValue.toInt(&okInt, 10); if (okInt) { text << *j << "=@Int(" << settingsValue.toString() << ")" << endl; } else { if (stringValue == "true") { text << *j << "=@Bool(" << settingsValue.toString() << ")" << endl; } else if (stringValue == "false") { text << *j << "=@Bool(" << settingsValue.toString() << ")" << endl; } else { text << *j << "=@String(\"" << settingsValue.toString() << "\")" << endl; } } } if (settingsType == "QSize") { text << *j << "=@Size(" << settingsValue.toSize().width() << "," << settingsValue.toSize().height() << ")" << endl; } if (settingsType == "QPoint") { text << *j << "=@Point(" << settingsValue.toPoint().x() << "," << settingsValue.toPoint().y() << ")" << endl; } } text.flush(); if (!ok) { QString msg = tr("Error writing to %1\n%2") .arg(fileName) .arg(file.errorString()); QMessageBox::warning(this, tr("Error"), msg); return; } }
void KConfigBase::writeEntry(const char *pKey, const QVariant &prop, bool bPersistent, bool bGlobal, bool bNLS) { switch(prop.type()) { case QVariant::Invalid: writeEntry(pKey, "", bPersistent, bGlobal, bNLS); return; case QVariant::String: writeEntry(pKey, prop.toString(), bPersistent, bGlobal, bNLS); return; case QVariant::StringList: writeEntry(pKey, prop.toStringList(), ',', bPersistent, bGlobal, bNLS); return; case QVariant::List: { QValueList< QVariant > list = prop.toList(); QValueList< QVariant >::ConstIterator it = list.begin(); QValueList< QVariant >::ConstIterator end = list.end(); QStringList strList; for(; it != end; ++it) strList.append((*it).toString()); writeEntry(pKey, strList, ',', bPersistent, bGlobal, bNLS); return; } case QVariant::Font: writeEntry(pKey, prop.toFont(), bPersistent, bGlobal, bNLS); return; case QVariant::Point: writeEntry(pKey, prop.toPoint(), bPersistent, bGlobal, bNLS); return; case QVariant::Rect: writeEntry(pKey, prop.toRect(), bPersistent, bGlobal, bNLS); return; case QVariant::Size: writeEntry(pKey, prop.toSize(), bPersistent, bGlobal, bNLS); return; case QVariant::Color: writeEntry(pKey, prop.toColor(), bPersistent, bGlobal, bNLS); return; case QVariant::Int: writeEntry(pKey, prop.toInt(), bPersistent, bGlobal, bNLS); return; case QVariant::UInt: writeEntry(pKey, prop.toUInt(), bPersistent, bGlobal, bNLS); return; case QVariant::LongLong: writeEntry(pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS); return; case QVariant::ULongLong: writeEntry(pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS); return; case QVariant::Bool: writeEntry(pKey, prop.toBool(), bPersistent, bGlobal, bNLS); return; case QVariant::Double: writeEntry(pKey, prop.toDouble(), bPersistent, bGlobal, 'g', 6, bNLS); return; case QVariant::DateTime: writeEntry(pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS); return; case QVariant::Date: writeEntry(pKey, QDateTime(prop.toDate()), bPersistent, bGlobal, bNLS); return; case QVariant::Pixmap: case QVariant::Image: case QVariant::Brush: case QVariant::Palette: case QVariant::ColorGroup: case QVariant::Map: case QVariant::IconSet: case QVariant::CString: case QVariant::PointArray: case QVariant::Region: case QVariant::Bitmap: case QVariant::Cursor: case QVariant::SizePolicy: case QVariant::Time: case QVariant::ByteArray: case QVariant::BitArray: case QVariant::KeySequence: case QVariant::Pen: break; } Q_ASSERT(0); }
QString GammaRay::Util::variantToString(const QVariant &value) { switch (value.type()) { case QVariant::Icon: { const QIcon icon = value.value<QIcon>(); if (icon.isNull()) return QObject::tr("<no icon>"); QStringList l; foreach (const QSize &size, icon.availableSizes()) l.push_back(variantToString(size)); return l.join(QLatin1String(", ")); } case QVariant::Line: return QString::fromUtf8("%1 x %2 → %3 x %4") .arg(value.toLine().x1()).arg(value.toLine().y1()) .arg(value.toLine().x2()).arg(value.toLine().y2()); case QVariant::LineF: return QString::fromUtf8("%1 x %2 → %3 x %4") .arg(value.toLineF().x1()).arg(value.toLineF().y1()) .arg(value.toLineF().x2()).arg(value.toLineF().y2()); case QVariant::Point: return QString::fromLatin1("%1x%2"). arg(value.toPoint().x()). arg(value.toPoint().y()); case QVariant::PointF: return QString::fromLatin1("%1x%2"). arg(value.toPointF().x()). arg(value.toPointF().y()); case QVariant::Rect: return QString::fromLatin1("%1x%2 %3x%4"). arg(value.toRect().x()). arg(value.toRect().y()). arg(value.toRect().width()). arg(value.toRect().height()); case QVariant::RectF: return QString::fromLatin1("%1x%2 %3x%4"). arg(value.toRectF().x()). arg(value.toRectF().y()). arg(value.toRectF().width()). arg(value.toRectF().height()); case QVariant::Region: { const QRegion region = value.value<QRegion>(); if (region.isEmpty()) { return QLatin1String("<empty>"); } if (region.rectCount() == 1) { return variantToString(region.rects().first()); } else { return QString::fromLatin1("<%1 rects>").arg(region.rectCount()); } } case QVariant::Palette: { const QPalette pal = value.value<QPalette>(); if (pal == qApp->palette()) return QLatin1String("<inherited>"); return QLatin1String("<custom>"); } case QVariant::Size: return QString::fromLatin1("%1x%2"). arg(value.toSize().width()). arg(value.toSize().height()); case QVariant::SizeF: return QString::fromLatin1("%1x%2"). arg(value.toSizeF().width()). arg(value.toSizeF().height()); case QVariant::SizePolicy: return QString::fromLatin1("%1 x %2"). arg(sizePolicyToString(value.value<QSizePolicy>().horizontalPolicy())). arg(sizePolicyToString(value.value<QSizePolicy>().verticalPolicy())); case QVariant::StringList: return value.toStringList().join(", "); case QVariant::Transform: { const QTransform t = value.value<QTransform>(); return QString::fromLatin1("[%1 %2 %3, %4 %5 %6, %7 %8 %9]"). arg(t.m11()).arg(t.m12()).arg(t.m13()). arg(t.m21()).arg(t.m22()).arg(t.m23()). arg(t.m31()).arg(t.m32()).arg(t.m33()); } default: break; } // types with dynamic type ids if (value.type() == qMetaTypeId<QTextLength>()) { const QTextLength l = value.value<QTextLength>(); QString typeStr; switch (l.type()) { case QTextLength::VariableLength: typeStr = QObject::tr("variable"); break; case QTextLength::FixedLength: typeStr = QObject::tr("fixed"); break; case QTextLength::PercentageLength: typeStr = QObject::tr("percentage"); break; } return QString::fromLatin1("%1 (%2)").arg(l.rawValue()).arg(typeStr); } if (value.userType() == qMetaTypeId<QPainterPath>()) { const QPainterPath path = value.value<QPainterPath>(); if (path.isEmpty()) { return QObject::tr("<empty>"); } return QObject::tr("<%1 elements>").arg(path.elementCount()); } if (value.type() == qMetaTypeId<QWidget*>()) { return displayString(value.value<QWidget*>()); } if (value.userType() == qMetaTypeId<QGraphicsEffect*>()) { return addressToString(value.value<QGraphicsEffect*>()); } if (value.userType() == qMetaTypeId<QGraphicsItem*>()) { return addressToString(value.value<QGraphicsItem*>()); } if (value.userType() == qMetaTypeId<QGraphicsItemGroup*>()) { return addressToString(value.value<QGraphicsItemGroup*>()); } if (value.userType() == qMetaTypeId<QGraphicsObject*>()) { return displayString(value.value<QGraphicsObject*>()); } if (value.userType() == qMetaTypeId<QGraphicsWidget*>()) { return displayString(value.value<QGraphicsWidget*>()); } if (value.userType() == qMetaTypeId<const QStyle*>()) { return displayString(value.value<const QStyle*>()); } // enums const QString enumStr = enumToString(value); if (!enumStr.isEmpty()) { return enumStr; } return value.toString(); }
int AskSkelPairDialog::skelTo() const{ QVariant ud = ui->skelTo->itemData( ui->skelTo->currentIndex() , Qt::UserRole ); return ud.toSize().height(); }
VCCueList::VCCueList(QWidget* parent, Doc* doc) : VCWidget(parent, doc) , m_chaserID(Function::invalidId()) //, m_chaser(NULL) , m_timer(NULL) , m_primaryIndex(0) , m_secondaryIndex(0) , m_primaryLeft(true) { /* Set the class name "VCCueList" as the object name as well */ setObjectName(VCCueList::staticMetaObject.className()); /* Create a layout for this widget */ QGridLayout* grid = new QGridLayout(this); grid->setSpacing(2); m_linkCheck = new QCheckBox(tr("Link")); grid->addWidget(m_linkCheck, 0, 0, 1, 2, Qt::AlignVCenter | Qt::AlignCenter); m_sl1TopLabel = new QLabel("100%"); m_sl1TopLabel->setAlignment(Qt::AlignHCenter); grid->addWidget(m_sl1TopLabel, 1, 0, 1, 1); m_slider1 = new ClickAndGoSlider(); m_slider1->setSliderStyleSheet(CNG_DEFAULT_STYLE); m_slider1->setFixedWidth(32); m_slider1->setRange(0, 100); m_slider1->setValue(100); grid->addWidget(m_slider1, 2, 0, 1, 1); m_sl1BottomLabel = new QLabel(""); m_sl1BottomLabel->setStyleSheet(cfLabelNoStyle); m_sl1BottomLabel->setAlignment(Qt::AlignCenter); grid->addWidget(m_sl1BottomLabel, 3, 0, 1, 1); connect(m_slider1, SIGNAL(valueChanged(int)), this, SLOT(slotSlider1ValueChanged(int))); m_sl2TopLabel = new QLabel("0%"); m_sl2TopLabel->setAlignment(Qt::AlignHCenter); grid->addWidget(m_sl2TopLabel, 1, 1, 1, 1); m_slider2 = new ClickAndGoSlider(); m_slider2->setSliderStyleSheet(CNG_DEFAULT_STYLE); m_slider2->setFixedWidth(32); m_slider2->setRange(0, 100); m_slider2->setValue(0); m_slider2->setInvertedAppearance(true); grid->addWidget(m_slider2, 2, 1, 1, 1); m_sl2BottomLabel = new QLabel(""); m_sl2BottomLabel->setStyleSheet(cfLabelNoStyle); m_sl2BottomLabel->setAlignment(Qt::AlignCenter); grid->addWidget(m_sl2BottomLabel, 3, 1, 1, 1); connect(m_slider2, SIGNAL(valueChanged(int)), this, SLOT(slotSlider2ValueChanged(int))); slotShowCrossfadePanel(false); /* Create a list for scenes (cues) */ m_tree = new QTreeWidget(this); grid->addWidget(m_tree, 0, 2, 3, 1); m_tree->setSelectionMode(QAbstractItemView::SingleSelection); //m_tree->setAlternatingRowColors(true); m_tree->setAllColumnsShowFocus(true); m_tree->setRootIsDecorated(false); m_tree->setItemsExpandable(false); m_tree->header()->setSortIndicatorShown(false); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) m_tree->header()->setClickable(false); m_tree->header()->setMovable(false); #else m_tree->header()->setSectionsClickable(false); m_tree->header()->setSectionsMovable(false); #endif // Make only the notes column editable m_tree->setItemDelegateForColumn(COL_NUM, new NoEditDelegate(this)); m_tree->setItemDelegateForColumn(COL_NAME, new NoEditDelegate(this)); m_tree->setItemDelegateForColumn(COL_FADEIN, new NoEditDelegate(this)); m_tree->setItemDelegateForColumn(COL_FADEOUT, new NoEditDelegate(this)); m_tree->setItemDelegateForColumn(COL_DURATION, new NoEditDelegate(this)); connect(m_tree, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(slotItemActivated(QTreeWidgetItem*))); connect(m_tree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotItemChanged(QTreeWidgetItem*,int))); m_progress = new QProgressBar(this); m_progress->setOrientation(Qt::Horizontal); m_progress->setStyleSheet(progressDisabledStyle); m_progress->setProperty("status", 0); m_progress->setFixedHeight(20); grid->addWidget(m_progress, 3, 2); m_timer = new QTimer(this); connect(m_timer, SIGNAL(timeout()), this, SLOT(slotProgressTimeout())); m_updateTimer = new QTimer(this); connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(slotUpdateStepList())); m_updateTimer->setSingleShot(true); /* Create control buttons */ QHBoxLayout *hbox = new QHBoxLayout(); hbox->setSpacing(2); m_crossfadeButton = new QToolButton(this); m_crossfadeButton->setIcon(QIcon(":/slider.png")); m_crossfadeButton->setIconSize(QSize(24, 24)); m_crossfadeButton->setCheckable(true); m_crossfadeButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); m_crossfadeButton->setFixedHeight(32); m_crossfadeButton->setToolTip(tr("Show/Hide crossfade sliders")); connect(m_crossfadeButton, SIGNAL(toggled(bool)), this, SLOT(slotShowCrossfadePanel(bool))); hbox->addWidget(m_crossfadeButton); m_playbackButton = new QToolButton(this); m_playbackButton->setIcon(QIcon(":/player_play.png")); m_playbackButton->setIconSize(QSize(24, 24)); m_playbackButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); m_playbackButton->setFixedHeight(32); m_playbackButton->setToolTip(tr("Play/Stop Cue list")); connect(m_playbackButton, SIGNAL(clicked()), this, SLOT(slotPlayback())); hbox->addWidget(m_playbackButton); m_previousButton = new QToolButton(this); m_previousButton->setIcon(QIcon(":/back.png")); m_previousButton->setIconSize(QSize(24, 24)); m_previousButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); m_previousButton->setFixedHeight(32); m_previousButton->setToolTip(tr("Go to previous step in the list")); connect(m_previousButton, SIGNAL(clicked()), this, SLOT(slotPreviousCue())); hbox->addWidget(m_previousButton); m_nextButton = new QToolButton(this); m_nextButton->setIcon(QIcon(":/forward.png")); m_nextButton->setIconSize(QSize(24, 24)); m_nextButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); m_nextButton->setFixedHeight(32); m_nextButton->setToolTip(tr("Go to next step in the list")); connect(m_nextButton, SIGNAL(clicked()), this, SLOT(slotNextCue())); hbox->addWidget(m_nextButton); grid->addItem(hbox, 4, 2); setFrameStyle(KVCFrameStyleSunken); setType(VCWidget::CueListWidget); setCaption(tr("Cue list")); QSettings settings; QVariant var = settings.value(SETTINGS_CUELIST_SIZE); if (var.isValid() == true) resize(var.toSize()); else resize(QSize(300, 220)); slotModeChanged(m_doc->mode()); setLiveEdit(m_liveEdit); connect(m_doc, SIGNAL(functionRemoved(quint32)), this, SLOT(slotFunctionRemoved(quint32))); connect(m_doc, SIGNAL(functionChanged(quint32)), this, SLOT(slotFunctionChanged(quint32))); connect(m_doc, SIGNAL(functionNameChanged(quint32)), this, SLOT(slotFunctionNameChanged(quint32))); m_nextLatestValue = 0; m_previousLatestValue = 0; m_playbackLatestValue = 0; }
VCMatrix::VCMatrix(QWidget *parent, Doc *doc) : VCWidget(parent, doc) , m_matrixID(Function::invalidId()) , m_instantApply(true) , m_visibilityMask(VCMatrix::defaultVisibilityMask()) { /* Set the class name "VCLabel" as the object name as well */ setObjectName(VCMatrix::staticMetaObject.className()); setFrameStyle(KVCFrameStyleSunken); QHBoxLayout *hBox = new QHBoxLayout(this); //hBox->setContentsMargins(3, 3, 3, 10); //hBox->setSpacing(5); m_slider = new ClickAndGoSlider(); m_slider->setStyleSheet(CNG_DEFAULT_STYLE); m_slider->setFixedWidth(32); m_slider->setRange(0, 255); m_slider->setPageStep(1); m_slider->setInvertedAppearance(false); hBox->addWidget(m_slider); connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(slotSliderMoved(int))); QVBoxLayout *vbox = new QVBoxLayout(this); m_startColorButton = new QToolButton(this); m_startColorButton->setFixedSize(48, 48); m_startColorButton->setIconSize(QSize(42, 42)); QWidgetAction* scAction = new QWidgetAction(this); m_scCnGWidget = new ClickAndGoWidget(); m_scCnGWidget->setType(ClickAndGoWidget::RGB, NULL); scAction->setDefaultWidget(m_scCnGWidget); QMenu *startColorMenu = new QMenu(); startColorMenu->addAction(scAction); m_startColorButton->setMenu(startColorMenu); m_startColorButton->setPopupMode(QToolButton::InstantPopup); connect(m_scCnGWidget, SIGNAL(colorChanged(QRgb)), this, SLOT(slotStartColorChanged(QRgb))); m_endColorButton = new QToolButton(this); m_endColorButton->setFixedSize(48, 48); m_endColorButton->setIconSize(QSize(42, 42)); QWidgetAction* ecAction = new QWidgetAction(this); m_ecCnGWidget = new ClickAndGoWidget(); m_ecCnGWidget->setType(ClickAndGoWidget::RGB, NULL); ecAction->setDefaultWidget(m_ecCnGWidget); QMenu *endColorMenu = new QMenu(); endColorMenu->addAction(ecAction); m_endColorButton->setMenu(endColorMenu); m_endColorButton->setPopupMode(QToolButton::InstantPopup); connect(m_ecCnGWidget, SIGNAL(colorChanged(QRgb)), this, SLOT(slotEndColorChanged(QRgb))); m_label = new QLabel(this); m_label->setAlignment(Qt::AlignCenter); m_label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); vbox->addWidget(m_label); QHBoxLayout *btnHbox = new QHBoxLayout(this); btnHbox->addWidget(m_startColorButton); btnHbox->addWidget(m_endColorButton); vbox->addLayout(btnHbox); m_presetCombo = new QComboBox(this); //m_presetCombo->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); m_presetCombo->addItems(doc->rgbScriptsCache()->names()); connect(m_presetCombo, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotAnimationChanged(QString))); vbox->addWidget(m_presetCombo); hBox->addLayout(vbox); m_controlsLayout = new FlowLayout(); vbox->addLayout(m_controlsLayout); setType(VCWidget::AnimationWidget); setCaption(QString()); /* Initial size */ QSettings settings; QVariant var = settings.value(SETTINGS_RGBMATRIX_SIZE); if (var.isValid() == true) resize(var.toSize()); else resize(defaultSize); /* Update timer */ m_updateTimer = new QTimer(this); connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(slotUpdate())); m_updateTimer->setSingleShot(true); /* Update the slider according to current mode */ slotModeChanged(m_doc->mode()); setLiveEdit(m_liveEdit); }
VALUE RubyType<QVariant>::toVALUE(const QVariant& v) { #ifdef QROSS_RUBY_VARIANT_DEBUG qrossdebug( QString("RubyType<QVariant>::toVALUE variant.toString=%1 variant.typeid=%2 variant.typeName=%3").arg(v.toString()).arg(v.type()).arg(v.typeName()) ); #endif switch( v.type() ) { case QVariant::Int: return RubyType<int>::toVALUE(v.toInt()); case QVariant::UInt: return RubyType<uint>::toVALUE(v.toUInt()); case QVariant::Double: return RubyType<double>::toVALUE(v.toDouble()); case QVariant::ByteArray: return RubyType<QByteArray>::toVALUE(v.toByteArray()); case QVariant::String: return RubyType<QString>::toVALUE(v.toString()); case QVariant::Bool: return RubyType<bool>::toVALUE(v.toBool()); case QVariant::StringList: return RubyType<QStringList>::toVALUE(v.toStringList()); case QVariant::Map: return RubyType<QVariantMap>::toVALUE(v.toMap()); case QVariant::List: return RubyType<QVariantList>::toVALUE(v.toList()); case QVariant::LongLong: return RubyType<qlonglong>::toVALUE(v.toLongLong()); case QVariant::ULongLong: return RubyType<qlonglong>::toVALUE(v.toULongLong()); case QVariant::Size: return RubyType<QSize>::toVALUE(v.toSize()); case QVariant::SizeF: return RubyType<QSizeF>::toVALUE(v.toSizeF()); case QVariant::Point: return RubyType<QPoint>::toVALUE(v.toPoint()); case QVariant::PointF: return RubyType<QPointF>::toVALUE(v.toPointF()); case QVariant::Rect: return RubyType<QRect>::toVALUE(v.toRect()); case QVariant::RectF: return RubyType<QRectF>::toVALUE(v.toRectF()); case QVariant::Color: return RubyType<QColor>::toVALUE( v.value<QColor>() ); case QVariant::Url: return RubyType<QUrl>::toVALUE(v.toUrl()); case QVariant::Date: return RubyType<QDate>::toVALUE( v.value<QDate>() ); case QVariant::Time: return RubyType<QTime>::toVALUE( v.value<QTime>() ); case QVariant::DateTime: return RubyType<QDateTime>::toVALUE( v.value<QDateTime>() ); case QVariant::Invalid: { #ifdef QROSS_RUBY_VARIANT_DEBUG qrossdebug( QString("RubyType<QVariant>::toVALUE variant=%1 is QVariant::Invalid. Returning Qnil.").arg(v.toString()) ); #endif return Qnil; } // fall through case QVariant::UserType: { #ifdef QROSS_RUBY_VARIANT_DEBUG qrossdebug( QString("RubyType<QVariant>::toVALUE variant=%1 is QVariant::UserType. Trying to cast now.").arg(v.toString()) ); #endif } // fall through default: { if( strcmp(v.typeName(),"float") == 0 ) { #ifdef QROSS_RUBY_VARIANT_DEBUG qrossdebug( QString("RubyType<QVariant>::toVALUE Casting '%1' to double").arg(v.typeName()) ); #endif return RubyType<double>::toVALUE(v.toDouble()); } if( strcmp(v.typeName(),"Qross::VoidList") == 0 ) { VoidList list = v.value<VoidList>(); Qross::MetaTypeHandler* handler = Qross::Manager::self().metaTypeHandler(list.typeName); #ifdef QROSS_RUBY_VARIANT_DEBUG qrossdebug( QString("RubyType<QVariant>::toVALUE Casting '%1' to QList<%2> with %3 items, hasHandler=%4").arg(v.typeName()).arg(list.typeName.constData()).arg(list.count()).arg(handler ? "true" : "false") ); #endif QVariantList l; foreach(void* ptr, list) { if( handler ) { l << handler->callHandler(ptr); } else { QVariant v; v.setValue(ptr); l << v; } } return RubyType<QVariantList>::toVALUE(l); } if( qVariantCanConvert< Qross::Object::Ptr >(v) ) { #ifdef QROSS_RUBY_VARIANT_DEBUG qrossdebug( QString("RubyType<QVariant>::toPyObject Casting '%1' to Qross::Object::Ptr").arg(v.typeName()) ); #endif Qross::Object::Ptr obj = v.value< Qross::Object::Ptr >(); Qross::RubyObject* rbobj = dynamic_cast< Qross::RubyObject* >(obj.data()); if(! obj) { #ifdef QROSS_RUBY_VARIANT_DEBUG qrossdebug( QString("RubyType<QVariant>::toPyObject To Qross::RubyObject* casted '%1' is NULL").arg(v.typeName()) ); #endif return Qnil; } return rbobj->rbObject(); } if( qVariantCanConvert< QWidget* >(v) ) { #ifdef QROSS_RUBY_VARIANT_DEBUG qrossdebug( QString("RubyType<QVariant>::toVALUE Casting '%1' to QWidget").arg(v.typeName()) ); #endif QWidget* widget = qvariant_cast< QWidget* >(v); if(! widget) { #ifdef QROSS_RUBY_VARIANT_DEBUG qrosswarning( QString("RubyType<QVariant>::toVALUE To QWidget casted '%1' is NULL").arg(v.typeName()) ); #endif return Qnil; } return RubyExtension::toVALUE( new RubyExtension(widget), true /*owner*/ ); } if( qVariantCanConvert< QObject* >(v) ) { #ifdef QROSS_RUBY_VARIANT_DEBUG qrossdebug( QString("RubyType<QVariant>::toVALUE Casting '%1' to QObject*").arg(v.typeName()) ); #endif QObject* obj = qvariant_cast< QObject* >(v); if(! obj) { #ifdef QROSS_RUBY_VARIANT_DEBUG qrosswarning( QString("RubyType<QVariant>::toVALUE To QObject casted '%1' is NULL").arg(v.typeName()) ); #endif return Qnil; } return RubyExtension::toVALUE( new RubyExtension(obj), true /*owner*/ ); } if( qVariantCanConvert< void* >(v) ) { return Data_Wrap_Struct( rb_cObject, 0, 0, qvariant_cast<void*>(v)); } //QObject* obj = (*reinterpret_cast< QObject*(*)>( variantargs[0]->toVoidStar() )); //PyObject* qobjectptr = PyLong_FromVoidPtr( (void*) variantargs[0]->toVoidStar() ); #ifdef QROSS_RUBY_VARIANT_DEBUG qrosswarning( QString("RubyType<QVariant>::toVALUE Not possible to convert the QVariant '%1' with type '%2' (%3) to a VALUE.").arg(v.toString()).arg(v.typeName()).arg(v.type()) ); #endif //throw Py::TypeError( QString("Variant of type %1 can not be casted to a Ruby object.").arg(v.typeName()).toLatin1().constData() ); return 0; } }
VCPropertiesEditor::VCPropertiesEditor(QWidget* parent, const VCProperties& properties, InputMap* inputMap) : QDialog(parent) , m_inputMap(inputMap) { Q_ASSERT(inputMap != NULL); setupUi(this); QAction* action = new QAction(this); action->setShortcut(QKeySequence(QKeySequence::Close)); connect(action, SIGNAL(triggered(bool)), this, SLOT(reject())); addAction(action); m_properties = properties; /* General page */ m_sizeXSpin->setValue(properties.size().width()); m_sizeYSpin->setValue(properties.size().height()); fillTapModifierCombo(); /* Widgets page */ QSettings settings; // ********************* BUTTON **************************** QVariant var = settings.value(SETTINGS_BUTTON_SIZE); if (var.isValid() == true) { QSize size = var.toSize(); m_buttonWspin->setValue(size.width()); m_buttonHspin->setValue(size.height()); } else { m_buttonWspin->setValue(50); m_buttonHspin->setValue(50); } // ********************* BUTTON STATUS ********************* var = settings.value(SETTINGS_BUTTON_STATUSLED); if (var.isValid() == true && var.toBool() == true) m_buttonStatusLEDRadio->setChecked(true); // ********************* SLIDER **************************** var = settings.value(SETTINGS_SLIDER_SIZE); if (var.isValid() == true) { QSize size = var.toSize(); m_sliderWspin->setValue(size.width()); m_sliderHspin->setValue(size.height()); } else { m_sliderWspin->setValue(60); m_sliderHspin->setValue(200); } // ********************* SPEED DIAL ************************ var = settings.value(SETTINGS_SPEEDDIAL_SIZE); if (var.isValid() == true) { QSize size = var.toSize(); m_speedWspin->setValue(size.width()); m_speedHspin->setValue(size.height()); } else { m_speedWspin->setValue(200); m_speedHspin->setValue(175); } // ********************* SPEED DIAL VALUE ****************** var = settings.value(SETTINGS_SPEEDDIAL_VALUE); if (var.isValid() == true) m_speedValueEdit->setText(Function::speedToString(var.toUInt())); else m_speedValueEdit->setText(Function::speedToString(0)); connect(m_speedValueEdit, SIGNAL(editingFinished()), this, SLOT(slotSpeedDialConfirmed())); // ********************* XY PAD **************************** var = settings.value(SETTINGS_XYPAD_SIZE); if (var.isValid() == true) { QSize size = var.toSize(); m_xypadWspin->setValue(size.width()); m_xypadHspin->setValue(size.height()); } else { m_xypadWspin->setValue(230); m_xypadHspin->setValue(230); } // ********************* CUE LIST ************************** var = settings.value(SETTINGS_CUELIST_SIZE); if (var.isValid() == true) { QSize size = var.toSize(); m_cuelistWspin->setValue(size.width()); m_cuelistHspin->setValue(size.height()); } else { m_cuelistWspin->setValue(300); m_cuelistHspin->setValue(220); } // ************************ FRAME ************************** var = settings.value(SETTINGS_FRAME_SIZE); if (var.isValid() == true) { QSize size = var.toSize(); m_frameWspin->setValue(size.width()); m_frameHspin->setValue(size.height()); } else { m_frameWspin->setValue(200); m_frameHspin->setValue(200); } // ********************* SOLO FRAME ************************ var = settings.value(SETTINGS_SOLOFRAME_SIZE); if (var.isValid() == true) { QSize size = var.toSize(); m_soloWspin->setValue(size.width()); m_soloHspin->setValue(size.height()); } else { m_soloWspin->setValue(200); m_soloHspin->setValue(200); } // ***************** AUDIO TRIGGERS ************************ var = settings.value(SETTINGS_AUDIOTRIGGERS_SIZE); if (var.isValid() == true) { QSize size = var.toSize(); m_audioWspin->setValue(size.width()); m_audioHspin->setValue(size.height()); } else { m_audioWspin->setValue(200); m_audioHspin->setValue(200); } /* Grand Master page */ switch (properties.grandMasterChannelMode()) { default: case UniverseArray::GMIntensity: m_gmIntensityRadio->setChecked(true); break; case UniverseArray::GMAllChannels: m_gmAllChannelsRadio->setChecked(true); break; } switch (properties.grandMasterValueMode()) { default: case UniverseArray::GMReduce: m_gmReduceRadio->setChecked(true); break; case UniverseArray::GMLimit: m_gmLimitRadio->setChecked(true); break; } switch (properties.grandMasterSlideMode()) { default: case UniverseArray::GMNormal: m_gmSliderModeNormalRadio->setChecked(true); break; case UniverseArray::GMInverted: m_gmSliderModeInvertedRadio->setChecked(true); break; } updateGrandMasterInputSource(); }
QVariant Property::convert(QVariant &value, QVariant::Type type) { QVariant::Type v_type = value.type(); /// current variant type QVariant c_value; /// converted value QSize size; QSizeF sizef; QRect rect; QRectF rectf; QString string; QStringList str_parts; /// Parts of string when parsing a string c_value = value; // Parse variant switch (v_type) { case QVariant::Size: size = value.toSize(); switch (type) { case QVariant::String: c_value = QVariant(QString("%1,%2").arg(size.width()).arg(size.height())); break; default: break; } break; case QVariant::SizeF: sizef = value.toSizeF(); switch (type) { case QVariant::String: c_value = QVariant(QString("%1,%2").arg(sizef.width()).arg(sizef.height())); break; default: break; } break; case QVariant::Rect: rect = value.toRect(); switch (type) { case QVariant::String: c_value = QVariant(QString("%1,%2,%3,%4").arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height())); break; default: break; } break; case QVariant::RectF: rectf = value.toRectF(); switch (type) { case QVariant::String: c_value = QVariant(QString("%1,%2,%3,%4").arg(rectf.x()).arg(rectf.y()).arg(rectf.width()).arg(rectf.height())); break; default: break; } break; case QVariant::String: string = value.toString(); str_parts = string.split(","); switch(type) { case QVariant::Rect: rect = QRect(str_parts[0].toInt(), str_parts[1].toInt(), str_parts[2].toInt(), str_parts[3].toInt()); c_value = QVariant(rect); break; case QVariant::RectF: rectf = QRectF(str_parts[0].toFloat(), str_parts[1].toFloat(), str_parts[2].toFloat(), str_parts[3].toFloat()); c_value = QVariant(rectf); break; case QVariant::Size: size = QSize(str_parts[0].toInt(), str_parts[1].toInt()); c_value = QVariant(size); break; case QVariant::SizeF: sizef = QSizeF(str_parts[0].toFloat(), str_parts[1].toFloat()); c_value = QVariant(sizef); break; default: break; } break; default: // No (known) need for processing break; } return c_value; }
bool DomConvenience::variantToElement(const QVariant& v, QDomElement& e) { bool ok = true; clearAttributes(e); switch (v.type()) { case QVariant::String: e.setTagName("string"); e.setAttribute("value", v.toString()); break; #if 0 case QVariant::CString: e.setTagName("string"); e.setAttribute("value", v.toString()); break; #endif case QVariant::Int: e.setTagName("int"); e.setAttribute("value", v.toInt()); break; case QVariant::UInt: e.setTagName("uint"); e.setAttribute("value", v.toUInt()); break; case QVariant::Double: e.setTagName("double"); e.setAttribute("value", v.toDouble()); break; case QVariant::Bool: e.setTagName("bool"); e.setAttribute("value", boolString(v.toBool())); break; case QVariant::Color: { e.setTagName("color"); QColor color = v.value<QColor>(); e.setAttribute("red", color.red()); e.setAttribute("green", color.green()); e.setAttribute("blue", color.blue()); } break; case QVariant::Pen: { e.setTagName("pen"); QPen pen = v.value<QPen>(); e.setAttribute("red", pen.color().red()); e.setAttribute("green", pen.color().green()); e.setAttribute("blue", pen.color().blue()); e.setAttribute("style", pen.style()); e.setAttribute("cap", pen.capStyle()); e.setAttribute("join", pen.joinStyle()); } break; case QVariant::Brush: { e.setTagName("brush"); QBrush brush = v.value<QBrush>(); e.setAttribute("red", brush.color().red()); e.setAttribute("green", brush.color().green()); e.setAttribute("blue", brush.color().blue()); e.setAttribute("style", brush.style()); } break; case QVariant::Point: { e.setTagName("point"); QPoint point = v.toPoint(); e.setAttribute("x", point.x()); e.setAttribute("y", point.y()); } break; case QVariant::Rect: { e.setTagName("rect"); QRect rect = v.toRect(); e.setAttribute("x", rect.x()); e.setAttribute("y", rect.y()); e.setAttribute("width", rect.width()); e.setAttribute("height", rect.height()); } break; case QVariant::Size: { e.setTagName("size"); QSize qsize = v.toSize(); e.setAttribute("width", qsize.width()); e.setAttribute("height", qsize.height()); } break; case QVariant::Font: { e.setTagName("font"); QFont f(v.value<QFont>()); e.setAttribute("family", f.family()); e.setAttribute("pointsize", f.pointSize()); e.setAttribute("bold", boolString(f.bold())); e.setAttribute("italic", boolString(f.italic())); e.setAttribute("underline", boolString(f.underline())); e.setAttribute("strikeout", boolString(f.strikeOut())); } break; case QVariant::SizePolicy: { e.setTagName("sizepolicy"); QSizePolicy sp(v.value<QSizePolicy>()); e.setAttribute("hsizetype", sp.horData()); e.setAttribute("vsizetype", sp.verData()); e.setAttribute("horstretch", sp.horStretch()); e.setAttribute("verstretch", sp.verStretch()); } break; case QVariant::Cursor: e.setTagName("cursor"); e.setAttribute("shape", v.value<QCursor>().shape()); break; case QVariant::StringList: { e.setTagName("stringlist"); int32_t j; QDomNode n; QDomNodeList stringNodeList = e.elementsByTagName("string"); QDomElement stringElem; QStringList stringList = v.toStringList(); QStringList::Iterator it = stringList.begin(); for (j = 0; ((j < (int32_t)stringNodeList.length()) && (it != stringList.end())); j++) { // get the current string element stringElem = stringNodeList.item(j).toElement(); // set it to the current string variantToElement(QVariant(*it), stringElem); // iterate to the next string ++it; } // more nodes in previous stringlist then current, remove excess nodes if (stringNodeList.count() > stringList.count()) { while (j < (int32_t)stringNodeList.count()) e.removeChild(stringNodeList.item(j).toElement()); } else if (j < (int32_t)stringList.count()) { while (it != stringList.end()) { // create a new element stringElem = m_doc.createElement("string"); // set it to the currentstring variantToElement(QVariant(*it), stringElem); // append it to the current element e.appendChild(stringElem); // iterate to the next string ++it; } } } break; case QVariant::KeySequence: e.setTagName("key"); e.setAttribute("sequence", (QString)v.value<QKeySequence>().toString()); break; case QVariant::ByteArray: // this is only for [u]int64_t { e.setTagName("data"); // set the value e.setAttribute("value", getStringFromByteArray(v.toByteArray())); } break; default: qWarning("Don't know how to persist variant of type: %s (%d)!", v.typeName(), v.type()); ok = false; break; } return ok; }
void KConfigGroup::writeEntry( const char* key, const QVariant &value, WriteConfigFlags flags ) { Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group"); Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group"); if ( writeEntryGui( this, key, value, flags ) ) return; // GUI type that was handled QByteArray data; // if a type handler is added here you must add a QVConversions definition // to conversion_check.h, or ConversionCheck::to_QVariant will not allow // writeEntry<T> to convert to QVariant. switch( value.type() ) { case QVariant::Invalid: data = ""; break; case QVariant::ByteArray: data = value.toByteArray(); break; case QVariant::String: case QVariant::Int: case QVariant::UInt: case QVariant::Double: case QMetaType::Float: case QVariant::Bool: case QVariant::LongLong: case QVariant::ULongLong: data = value.toString().toUtf8(); break; case QVariant::List: if (!value.canConvert(QVariant::StringList)) qWarning() << "not all types in \"" << key << "\" can convert to QString," " information will be lost"; case QVariant::StringList: writeEntry( key, value.toList(), flags ); return; case QVariant::Point: { QVariantList list; const QPoint rPoint = value.toPoint(); list.insert( 0, rPoint.x() ); list.insert( 1, rPoint.y() ); writeEntry( key, list, flags ); return; } case QVariant::PointF: { QVariantList list; const QPointF point = value.toPointF(); list.insert( 0, point.x() ); list.insert( 1, point.y() ); writeEntry( key, list, flags ); return; } case QVariant::Rect:{ QVariantList list; const QRect rRect = value.toRect(); list.insert( 0, rRect.left() ); list.insert( 1, rRect.top() ); list.insert( 2, rRect.width() ); list.insert( 3, rRect.height() ); writeEntry( key, list, flags ); return; } case QVariant::RectF:{ QVariantList list; const QRectF rRectF = value.toRectF(); list.insert(0, rRectF.left()); list.insert(1, rRectF.top()); list.insert(2, rRectF.width()); list.insert(3, rRectF.height()); writeEntry(key, list, flags); return; } case QVariant::Size:{ QVariantList list; const QSize rSize = value.toSize(); list.insert( 0, rSize.width() ); list.insert( 1, rSize.height() ); writeEntry( key, list, flags ); return; } case QVariant::SizeF:{ QVariantList list; const QSizeF rSizeF = value.toSizeF(); list.insert(0, rSizeF.width()); list.insert(1, rSizeF.height()); writeEntry(key, list, flags); return; } case QVariant::Date: { QVariantList list; const QDate date = value.toDate(); list.insert( 0, date.year() ); list.insert( 1, date.month() ); list.insert( 2, date.day() ); writeEntry( key, list, flags ); return; } case QVariant::DateTime: { QVariantList list; const QDateTime rDateTime = value.toDateTime(); const QTime time = rDateTime.time(); const QDate date = rDateTime.date(); list.insert( 0, date.year() ); list.insert( 1, date.month() ); list.insert( 2, date.day() ); list.insert( 3, time.hour() ); list.insert( 4, time.minute() ); list.insert( 5, time.second() ); writeEntry( key, list, flags ); return; } case QVariant::Color: case QVariant::Font: qWarning() << "KConfigGroup::writeEntry was passed GUI type '" << value.typeName() << "' but kdeui isn't linked! If it is linked to your program, this is a platform bug. " "Please inform the KDE developers"; break; case QVariant::Url: data = QUrl(value.toUrl()).toString().toUtf8(); break; default: qWarning() << "KConfigGroup::writeEntry - unhandled type" << value.typeName() << "in group" << name(); } writeEntry(key, data, flags); }
VCSpeedDial::VCSpeedDial(QWidget* parent, Doc* doc) : VCWidget(parent, doc) , m_currentFactor(1) , m_resetFactorOnDialChange(false) , m_absoluteValueMin(0) , m_absoluteValueMax(1000 * 10) { setFrameStyle(KVCFrameStyleSunken); QVBoxLayout* vBox = new QVBoxLayout(this); vBox->setMargin(0); QHBoxLayout* speedDialHBox = new QHBoxLayout(); vBox->addLayout(speedDialHBox); m_dial = new SpeedDial(this); speedDialHBox->addWidget(m_dial); connect(m_dial, SIGNAL(valueChanged(int)), this, SLOT(slotDialValueChanged())); connect(m_dial, SIGNAL(tapped()), this, SLOT(slotDialTapped())); m_factoredValue = m_dial->value(); setType(VCWidget::SpeedDialWidget); setCaption(tr("Duration")); QSettings settings; QVariant var = settings.value(SETTINGS_SPEEDDIAL_SIZE); if (var.isValid() == true) resize(var.toSize()); else resize(VCSpeedDial::defaultSize); var = settings.value(SETTINGS_SPEEDDIAL_VALUE); if (var.isValid() == true) m_dial->setValue(var.toUInt()); // Multiplier, factor, divider and reset box QHBoxLayout* multFactorDivHBox = new QHBoxLayout(); m_divButton = new QToolButton(); m_divButton->setIconSize(QSize(32, 32)); m_divButton->setIcon(QIcon(":/back.png")); m_divButton->setToolTip(tr("Divide the current time by 2")); connect(m_divButton, SIGNAL(clicked()), this, SLOT(slotDiv())); multFactorDivHBox->addWidget(m_divButton, Qt::AlignVCenter | Qt::AlignLeft); QVBoxLayout* labelsVboxBox = new QVBoxLayout(); m_multDivLabel = new QLabel(); m_multDivLabel->setAlignment(Qt::AlignCenter); m_multDivLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); labelsVboxBox->addWidget(m_multDivLabel, Qt::AlignVCenter | Qt::AlignLeft); m_multDivResultLabel = new QLabel(); m_multDivResultLabel->setAlignment(Qt::AlignCenter); m_multDivResultLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); m_multDivResultLabel->setBackgroundRole(QPalette::BrightText); labelsVboxBox->addWidget(m_multDivResultLabel); multFactorDivHBox->addLayout(labelsVboxBox); m_multButton = new QToolButton(); m_multButton->setIconSize(QSize(32, 32)); m_multButton->setIcon(QIcon(":/forward.png")); m_multButton->setToolTip(tr("Multiply the current time by 2")); connect(m_multButton, SIGNAL(clicked()), this, SLOT(slotMult())); multFactorDivHBox->addWidget(m_multButton, Qt::AlignVCenter | Qt::AlignLeft); m_multDivResetButton = new QToolButton(); m_multDivResetButton->setIconSize(QSize(32, 32)); m_multDivResetButton->setIcon(QIcon(":/fileclose.png")); m_multDivResetButton->setToolTip(tr("Reset the current factor to 1x")); connect(m_multDivResetButton, SIGNAL(clicked()), this, SLOT(slotMultDivReset())); multFactorDivHBox->addWidget(m_multDivResetButton); vBox->addLayout(multFactorDivHBox); // Update labels slotMultDivChanged(); // Apply button m_applyButton = new QPushButton(); m_applyButton->setStyleSheet(presetBtnSS.arg("#DDDDDD")); m_applyButton->setText(tr("Apply")); m_applyButton->setToolTip(tr("Send the current value to the function now")); connect(m_applyButton, SIGNAL(clicked()), this, SLOT(slotFactoredValueChanged())); vBox->addWidget(m_applyButton); // Presets m_presetsLayout = new FlowLayout(3); vBox->addLayout(m_presetsLayout); // Don't show Infinite button: it's handled by presets setVisibilityMask(SpeedDial::defaultVisibilityMask() & ~SpeedDial::Infinite); /* Update timer */ m_updateTimer = new QTimer(this); connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(slotUpdate())); m_updateTimer->setSingleShot(true); slotModeChanged(m_doc->mode()); setLiveEdit(m_liveEdit); }
// Apply a simple variant type to a DOM property static bool applySimpleProperty(const QVariant &v, bool translateString, DomProperty *dom_prop) { switch (v.type()) { case QVariant::String: { DomString *str = new DomString(); str->setText(v.toString()); if (!translateString) str->setAttributeNotr(QStringLiteral("true")); dom_prop->setElementString(str); } return true; case QVariant::ByteArray: dom_prop->setElementCstring(QString::fromUtf8(v.toByteArray())); return true; case QVariant::Int: dom_prop->setElementNumber(v.toInt()); return true; case QVariant::UInt: dom_prop->setElementUInt(v.toUInt()); return true; case QVariant::LongLong: dom_prop->setElementLongLong(v.toLongLong()); return true; case QVariant::ULongLong: dom_prop->setElementULongLong(v.toULongLong()); return true; case QVariant::Double: dom_prop->setElementDouble(v.toDouble()); return true; case QVariant::Bool: dom_prop->setElementBool(v.toBool() ? QFormBuilderStrings::instance().trueValue : QFormBuilderStrings::instance().falseValue); return true; case QVariant::Char: { DomChar *ch = new DomChar(); const QChar character = v.toChar(); ch->setElementUnicode(character.unicode()); dom_prop->setElementChar(ch); } return true; case QVariant::Point: { DomPoint *pt = new DomPoint(); const QPoint point = v.toPoint(); pt->setElementX(point.x()); pt->setElementY(point.y()); dom_prop->setElementPoint(pt); } return true; case QVariant::PointF: { DomPointF *ptf = new DomPointF(); const QPointF pointf = v.toPointF(); ptf->setElementX(pointf.x()); ptf->setElementY(pointf.y()); dom_prop->setElementPointF(ptf); } return true; case QVariant::Color: { DomColor *clr = new DomColor(); const QColor color = qvariant_cast<QColor>(v); clr->setElementRed(color.red()); clr->setElementGreen(color.green()); clr->setElementBlue(color.blue()); const int alphaChannel = color.alpha(); if (alphaChannel != 255) clr->setAttributeAlpha(alphaChannel); dom_prop->setElementColor(clr); } return true; case QVariant::Size: { DomSize *sz = new DomSize(); const QSize size = v.toSize(); sz->setElementWidth(size.width()); sz->setElementHeight(size.height()); dom_prop->setElementSize(sz); } return true; case QVariant::SizeF: { DomSizeF *szf = new DomSizeF(); const QSizeF sizef = v.toSizeF(); szf->setElementWidth(sizef.width()); szf->setElementHeight(sizef.height()); dom_prop->setElementSizeF(szf); } return true; case QVariant::Rect: { DomRect *rc = new DomRect(); const QRect rect = v.toRect(); rc->setElementX(rect.x()); rc->setElementY(rect.y()); rc->setElementWidth(rect.width()); rc->setElementHeight(rect.height()); dom_prop->setElementRect(rc); } return true; case QVariant::RectF: { DomRectF *rcf = new DomRectF(); const QRectF rectf = v.toRectF(); rcf->setElementX(rectf.x()); rcf->setElementY(rectf.y()); rcf->setElementWidth(rectf.width()); rcf->setElementHeight(rectf.height()); dom_prop->setElementRectF(rcf); } return true; case QVariant::Font: { DomFont *fnt = new DomFont(); const QFont font = qvariant_cast<QFont>(v); const uint mask = font.resolve(); if (mask & QFont::WeightResolved) { fnt->setElementBold(font.bold()); fnt->setElementWeight(font.weight()); } if (mask & QFont::FamilyResolved) fnt->setElementFamily(font.family()); if (mask & QFont::StyleResolved) fnt->setElementItalic(font.italic()); if (mask & QFont::SizeResolved) fnt->setElementPointSize(font.pointSize()); if (mask & QFont::StrikeOutResolved) fnt->setElementStrikeOut(font.strikeOut()); if (mask & QFont::UnderlineResolved) fnt->setElementUnderline(font.underline()); if (mask & QFont::KerningResolved) fnt->setElementKerning(font.kerning()); if (mask & QFont::StyleStrategyResolved) { const QMetaEnum styleStrategy_enum = metaEnum<QAbstractFormBuilderGadget>("styleStrategy"); fnt->setElementStyleStrategy(QLatin1String(styleStrategy_enum.valueToKey(font.styleStrategy()))); } dom_prop->setElementFont(fnt); } return true; #ifndef QT_NO_CURSOR case QVariant::Cursor: { const QMetaEnum cursorShape_enum = metaEnum<QAbstractFormBuilderGadget>("cursorShape"); dom_prop->setElementCursorShape(QLatin1String(cursorShape_enum.valueToKey(qvariant_cast<QCursor>(v).shape()))); } return true; #endif case QVariant::KeySequence: { DomString *s = new DomString(); s->setText(qvariant_cast<QKeySequence>(v).toString(QKeySequence::PortableText)); dom_prop->setElementString(s); } return true; case QVariant::Locale: { DomLocale *dom = new DomLocale(); const QLocale locale = qvariant_cast<QLocale>(v); const QMetaEnum language_enum = metaEnum<QAbstractFormBuilderGadget>("language"); const QMetaEnum country_enum = metaEnum<QAbstractFormBuilderGadget>("country"); dom->setAttributeLanguage(QLatin1String(language_enum.valueToKey(locale.language()))); dom->setAttributeCountry(QLatin1String(country_enum.valueToKey(locale.country()))); dom_prop->setElementLocale(dom); } return true; case QVariant::SizePolicy: { DomSizePolicy *dom = new DomSizePolicy(); const QSizePolicy sizePolicy = qvariant_cast<QSizePolicy>(v); dom->setElementHorStretch(sizePolicy.horizontalStretch()); dom->setElementVerStretch(sizePolicy.verticalStretch()); const QMetaEnum sizeType_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType"); dom->setAttributeHSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.horizontalPolicy()))); dom->setAttributeVSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.verticalPolicy()))); dom_prop->setElementSizePolicy(dom); } return true; case QVariant::Date: { DomDate *dom = new DomDate(); const QDate date = qvariant_cast<QDate>(v); dom->setElementYear(date.year()); dom->setElementMonth(date.month()); dom->setElementDay(date.day()); dom_prop->setElementDate(dom); } return true; case QVariant::Time: { DomTime *dom = new DomTime(); const QTime time = qvariant_cast<QTime>(v); dom->setElementHour(time.hour()); dom->setElementMinute(time.minute()); dom->setElementSecond(time.second()); dom_prop->setElementTime(dom); } return true; case QVariant::DateTime: { DomDateTime *dom = new DomDateTime(); const QDateTime dateTime = qvariant_cast<QDateTime>(v); dom->setElementHour(dateTime.time().hour()); dom->setElementMinute(dateTime.time().minute()); dom->setElementSecond(dateTime.time().second()); dom->setElementYear(dateTime.date().year()); dom->setElementMonth(dateTime.date().month()); dom->setElementDay(dateTime.date().day()); dom_prop->setElementDateTime(dom); } return true; case QVariant::Url: { DomUrl *dom = new DomUrl(); const QUrl url = v.toUrl(); DomString *str = new DomString(); str->setText(url.toString()); dom->setElementString(str); dom_prop->setElementUrl(dom); } return true; case QVariant::StringList: { DomStringList *sl = new DomStringList; sl->setElementString(qvariant_cast<QStringList>(v)); dom_prop->setElementStringList(sl); } return true; default: break; } return false; }
QString AbstractPropertyModel::displayForProperty(const QModelIndex& index, const QVariant& value) const { const Property& settings = propertyForIndex(index); switch (settings.type) { case Type::BOOLEAN: case Type::INTEGER: case Type::UNSIGNED: case Type::STRING: case Type::IDSTRING: case Type::FILENAME: case Type::COLOR: case Type::COLOR_COMBO: { return value.toString(); } case Type::POINT: { QPoint p = value.toPoint(); return QString("%1, %2") .arg(p.x()) .arg(p.y()); } case Type::SIZE: { QSize s = value.toSize(); return QString("%1 x %2") .arg(s.width()) .arg(s.height()); } case Type::RECT: { QRect r = value.toRect(); return QString("%1, %2 : %3 x %4") .arg(r.x()) .arg(r.y()) .arg(r.width()) .arg(r.height()); } case Type::COMBO: { auto params = propertyParametersForIndex(index); int i = -1; if (params.second.canConvert(QVariant::List)) { i = params.second.toList().indexOf(value); } QStringList displayList = params.first.toStringList(); if (i >= 0 && i < displayList.size()) { return displayList.at(i); } else { return value.toString(); } } case Type::STRING_LIST: case Type::IDSTRING_LIST: case Type::FILENAME_LIST: { int listSize = 0; if (value.type() == QVariant::StringList) { listSize = value.toStringList().size(); } else if (value.type() == QVariant::List) { listSize = value.toList().size(); } if (listSize != 1) { return tr("(%1 items)").arg(listSize); } else { return tr("(1 item)"); } } } return QString(); }
VCSlider::VCSlider(QWidget* parent, Doc* doc) : VCWidget(parent, doc) { /* Set the class name "VCSlider" as the object name as well */ setObjectName(VCSlider::staticMetaObject.className()); m_hbox = NULL; m_topLabel = NULL; m_slider = NULL; m_bottomLabel = NULL; m_valueDisplayStyle = ExactValue; m_levelLowLimit = 0; m_levelHighLimit = UCHAR_MAX; m_levelValue = 0; m_levelValueChanged = false; m_monitorEnabled = false; m_monitorValue = 0; m_playbackFunction = Function::invalidId(); m_playbackValue = 0; m_playbackValueChanged = false; m_widgetMode = WSlider; setType(VCWidget::SliderWidget); setCaption(QString()); setFrameStyle(KVCFrameStyleSunken); /* Main VBox */ new QVBoxLayout(this); /* Top label */ m_topLabel = new QLabel(this); m_topLabel->setAlignment(Qt::AlignHCenter); layout()->addWidget(m_topLabel); /* Slider's HBox |stretch|slider|stretch| */ m_hbox = new QHBoxLayout(); /* Put stretchable space before the slider (to its left side) */ m_hbox->addStretch(); /* The slider */ m_slider = new ClickAndGoSlider(this); m_hbox->addWidget(m_slider); m_slider->setRange(0, 255); m_slider->setPageStep(1); m_slider->setInvertedAppearance(false); m_slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); m_slider->setMinimumWidth(32); m_slider->setMaximumWidth(80); m_slider->setStyleSheet(CNG_DEFAULT_STYLE); connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(slotSliderMoved(int))); m_externalMovement = false; /* Put stretchable space after the slider (to its right side) */ m_hbox->addStretch(); layout()->addItem(m_hbox); /* Click & Go button */ m_cngType = ClickAndGoWidget::None; m_cngButton = new QToolButton(this); m_cngButton->setFixedSize(48, 48); m_cngButton->setIconSize(QSize(42, 42)); m_menu = new QMenu(this); QWidgetAction* action = new QWidgetAction(this); m_cngWidget = new ClickAndGoWidget(); action->setDefaultWidget(m_cngWidget); m_menu->addAction(action); m_cngButton->setMenu(m_menu); m_cngButton->setPopupMode(QToolButton::InstantPopup); layout()->addWidget(m_cngButton); layout()->setAlignment(m_cngButton, Qt::AlignHCenter); m_cngButton->hide(); connect(m_cngWidget, SIGNAL(levelChanged(uchar)), this, SLOT(slotClickAndGoLevelChanged(uchar))); connect(m_cngWidget, SIGNAL(colorChanged(QRgb)), this, SLOT(slotClickAndGoColorChanged(QRgb))); connect(m_cngWidget, SIGNAL(levelAndPresetChanged(uchar,QImage)), this, SLOT(slotClickAndGoLevelAndPresetChanged(uchar, QImage))); connect(this, SIGNAL(monitorDMXValueChanged(int)), this, SLOT(slotMonitorDMXValueChanged(int))); /* Bottom label */ m_bottomLabel = new QLabel(this); layout()->addWidget(m_bottomLabel); m_bottomLabel->setAlignment(Qt::AlignCenter); m_bottomLabel->setWordWrap(true); m_bottomLabel->hide(); setMinimumSize(20, 20); QSettings settings; QVariant var = settings.value(SETTINGS_SLIDER_SIZE); if (var.isValid() == true) resize(var.toSize()); else resize(VCSlider::defaultSize); /* Initialize to playback mode by default */ setInvertedAppearance(false); m_sliderMode = SliderMode(-1); // avoid use of uninitialized value setSliderMode(Playback); /* Update the slider according to current mode */ slotModeChanged(m_doc->mode()); setLiveEdit(m_liveEdit); /* Listen to fixture removals so that LevelChannels can be removed when they no longer point to an existing fixture->channel */ connect(m_doc, SIGNAL(fixtureRemoved(quint32)), this, SLOT(slotFixtureRemoved(quint32))); }
void tvalue2json(rapidjson::Value & output, const QVariant & input, rapidjson::Value::AllocatorType & allocator) { switch(input.type()) { case QVariant::Invalid: { output.SetNull(); break; } case QVariant::Bool: { output.SetBool(input.toBool()); break; } case QVariant::Int: { output.SetInt64(input.toInt()); break; } case QVariant::LongLong: { output.SetInt64(input.toLongLong()); break; } case QVariant::Double: { output.SetDouble(input.toDouble()); break; } case QVariant::String: { QByteArray str = input.toString().toUtf8(); output.SetString(str.data(), str.size(), allocator); break; } case QVariant::StringList: { QStringList list = input.toStringList(); output.SetArray(); output.Reserve(list.size(), allocator); rapidjson::Value temp; for(QStringList::const_iterator it = list.begin(); it != list.end(); ++it) { QByteArray str = it->toUtf8(); temp.SetString(str.data(), str.size(), allocator); output.PushBack(temp, allocator); } break; } case QVariant::List: { QList<QVariant> list = input.toList(); output.SetArray(); output.Reserve(list.size(), allocator); rapidjson::Value temp; for(QList<QVariant>::const_iterator it = list.begin(); it != list.end(); ++it) { tvalue2json(temp, *it, allocator); output.PushBack(temp, allocator); } break; } case QVariant::Map: { output.SetObject(); rapidjson::Value tempK, tempV; QMap<QString, QVariant> qmap = input.toMap(); for(QMap<QString, QVariant>::const_iterator it = qmap.begin(); it != qmap.end(); ++it) { tvalue2json(tempK, it.key(), allocator); tvalue2json(tempV, it.value(), allocator); output.AddMember(tempK, tempV, allocator); } break; } case QVariant::Point: { QPoint pt = input.toPoint(); output.SetArray(); output.Reserve(2, allocator); output.PushBack(pt.x(), allocator); output.PushBack(pt.y(), allocator); break; } case QVariant::PointF: { QPointF pt = input.toPointF(); output.SetArray(); output.Reserve(2, allocator); output.PushBack(pt.x(), allocator); output.PushBack(pt.y(), allocator); break; } case QVariant::Size: { QSize pt = input.toSize(); output.SetArray(); output.Reserve(2, allocator); output.PushBack(pt.width(), allocator); output.PushBack(pt.height(), allocator); break; } case QVariant::SizeF: { QSizeF pt = input.toSizeF(); output.SetArray(); output.Reserve(2, allocator); output.PushBack(pt.width(), allocator); output.PushBack(pt.height(), allocator); break; } case QVariant::Rect: { QRect pt = input.toRect(); output.SetArray(); output.Reserve(4, allocator); output.PushBack(pt.x(), allocator); output.PushBack(pt.y(), allocator); output.PushBack(pt.width(), allocator); output.PushBack(pt.height(), allocator); break; } case QVariant::RectF: { QRectF pt = input.toRectF(); output.SetArray(); output.Reserve(4, allocator); output.PushBack(pt.x(), allocator); output.PushBack(pt.y(), allocator); output.PushBack(pt.width(), allocator); output.PushBack(pt.height(), allocator); break; } case QVariant::Vector2D: { QVector2D pt = input.value<QVector2D>(); output.SetArray(); output.Reserve(2, allocator); output.PushBack(pt.x(), allocator); output.PushBack(pt.y(), allocator); break; } case QVariant::Vector3D: { QVector3D pt = input.value<QVector3D>(); output.SetArray(); output.Reserve(3, allocator); output.PushBack(pt.x(), allocator); output.PushBack(pt.y(), allocator); output.PushBack(pt.z(), allocator); break; } case QVariant::Vector4D: { QVector4D pt = input.value<QVector4D>(); output.SetArray(); output.Reserve(4, allocator); output.PushBack(pt.x(), allocator); output.PushBack(pt.y(), allocator); output.PushBack(pt.z(), allocator); output.PushBack(pt.w(), allocator); break; } case QVariant::Color: { QColor pt = input.value<QColor>(); output.SetArray(); output.Reserve(4, allocator); output.PushBack(pt.red(), allocator); output.PushBack(pt.green(), allocator); output.PushBack(pt.blue(), allocator); output.PushBack(pt.alpha(), allocator); break; } default: { output.SetNull(); assert(false && "shuldn't execute to here."); } } }