コード例 #1
0
ファイル: Message_Tests.cpp プロジェクト: ArchangelSDY/Silica
void TestMessage::sendAndListen()
{
    int recvId1= 0;
    QByteArray recvPayload1;
    auto listener1 = [&recvId1, &recvPayload1](int id, const QByteArray &payload) {
        recvId1 = id;
        recvPayload1 = payload;
    };

    int recvId2= 0;
    QByteArray recvPayload2;
    auto listener2 = [&recvId2, &recvPayload2](int id, const QByteArray &payload) {
        recvId2 = id;
        recvPayload2 = payload;
    };

    sapi::message::addMessageListener("topic1", listener1);
    sapi::message::addMessageListener("topic1", listener2);
    sapi::message::sendMessage("topic1", "p1");
    sapi::message::sendMessage("topic2", "p2");

    QCOMPARE(recvId1, 0);
    QCOMPARE(recvPayload1, QByteArrayLiteral("p1"));

    QCOMPARE(recvId2, 0);
    QCOMPARE(recvPayload2, QByteArrayLiteral("p1"));
}
コード例 #2
0
void tst_QPauseAnimationJob::pauseAndPropertyAnimations()
{
    EnableConsistentTiming enabled;

    TestablePauseAnimation pause;
    pause.setDuration(200);

    TestableGenericAnimation animation;

    pause.start();

    QTest::qWait(100);
    animation.start();

    QCOMPARE(animation.state(), QAbstractAnimationJob::Running);

    QTRY_COMPARE(animation.state(), QAbstractAnimationJob::Running);
    QVERIFY(pause.state() == QAbstractAnimationJob::Running);
    QVERIFY2(pause.m_updateCurrentTimeCount >= 2,
             QByteArrayLiteral("pause.m_updateCurrentTimeCount=") + QByteArray::number(pause.m_updateCurrentTimeCount));

    QTRY_COMPARE(animation.state(), QAbstractAnimationJob::Stopped);
    QCOMPARE(pause.state(), QAbstractAnimationJob::Stopped);
    QVERIFY2(pause.m_updateCurrentTimeCount > 3,
             QByteArrayLiteral("pause.m_updateCurrentTimeCount=") + QByteArray::number(pause.m_updateCurrentTimeCount));
}
コード例 #3
0
void RenderMaterial::sceneChangeEvent(const QSceneChangePtr &e)
{
    QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);

    switch (e->type()) {
    case NodeUpdated: {
        if (propertyChange->propertyName() == QByteArrayLiteral("enabled"))
            m_enabled = propertyChange->value().toBool();
        break;
    }
        // Check for shader parameter
    case NodeAdded: {
        if (propertyChange->propertyName() == QByteArrayLiteral("parameter"))
            m_parameterPack.appendParameter(propertyChange->value().value<QNodeId>());
        else if (propertyChange->propertyName() == QByteArrayLiteral("effect"))
            m_effectUuid = propertyChange->value().value<QNodeId>();
        break;
    }
    case NodeRemoved: {
        if (propertyChange->propertyName() == QByteArrayLiteral("parameter"))
            m_parameterPack.removeParameter(propertyChange->value().value<QNodeId>());
        else if (propertyChange->propertyName() == QByteArrayLiteral("effect"))
            m_effectUuid = QNodeId();
        break;
    }

    default:
        break;
    }
}
コード例 #4
0
ファイル: tst_tojson.cpp プロジェクト: Subh1994/iotivity
void compareMetaData(QByteArray data, const QString &expected, int otherFlags = 0)
{
    QString decoded;

    // needs to be in in one map, with the entry called "v"
    data = "\xa1\x61v" + data;

    {
        CborParser parser;
        CborValue first;
        CborError err = cbor_parser_init(reinterpret_cast<const quint8 *>(data.constData()), data.length(), 0, &parser, &first);
        QVERIFY2(!err, QByteArrayLiteral(": Got error \"") + cbor_error_string(err) + "\"");

        err = parseOne(&first, &decoded, CborConvertAddMetadata | otherFlags);
        QVERIFY2(!err, QByteArrayLiteral(": Got error \"") + cbor_error_string(err) +
                 "\"; decoded stream:\n" + decoded.toLatin1());

        // check that we consumed everything
        QCOMPARE((void*)first.ptr, (void*)data.constEnd());
    }

    QVERIFY(decoded.startsWith("{\"v\":"));
    QVERIFY(decoded.endsWith('}'));
//    qDebug() << "was" << decoded;

    // extract just the metadata
    static const char needle[] = "\"v$cbor\":{";
    int pos = decoded.indexOf(needle);
    QCOMPARE(pos == -1, expected.isEmpty());
    if (pos != -1) {
        decoded.chop(2);
        decoded = std::move(decoded).mid(pos + strlen(needle));
        QCOMPARE(decoded, expected);
    }
}
コード例 #5
0
ファイル: channelmapper.cpp プロジェクト: RSATom/Qt
void ChannelMapper::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
    switch (e->type()) {
    case Qt3DCore::PropertyValueAdded: {
        const auto change = qSharedPointerCast<Qt3DCore::QPropertyNodeAddedChange>(e);
        if (change->propertyName() == QByteArrayLiteral("mappings")) {
            m_mappingIds.push_back(change->addedNodeId());
            setDirty(Handler::ChannelMappingsDirty);
            m_isDirty = true;
        }
        break;
    }

    case Qt3DCore::PropertyValueRemoved: {
        const auto change = qSharedPointerCast<Qt3DCore::QPropertyNodeRemovedChange>(e);
        if (change->propertyName() == QByteArrayLiteral("mappings")) {
            m_mappingIds.removeOne(change->removedNodeId());
            setDirty(Handler::ChannelMappingsDirty);
            m_isDirty = true;
        }
        break;
    }

    default:
        break;
    }
    QBackendNode::sceneChangeEvent(e);
}
コード例 #6
0
ファイル: ScreenModel.cpp プロジェクト: xgnata/sddm
QHash<int, QByteArray> ScreenModel::roleNames() const {
    // set role names
    QHash<int, QByteArray> roleNames;
    roleNames[NameRole] = QByteArrayLiteral("name");
    roleNames[GeometryRole] = QByteArrayLiteral("geometry");
    return roleNames;
}
コード例 #7
0
ファイル: main.cpp プロジェクト: qmlos/shell
int main(int argc, char *argv[])
{
    // Disable ptrace except for gdb
    disablePtrace();

    // Setup the environment
    qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("wayland"));
    qputenv("QT_WAYLAND_USE_BYPASSWINDOWMANAGERHINT", QByteArrayLiteral("1"));

    // Application
    QGuiApplication app(argc, argv);
    app.setApplicationName(QStringLiteral("Liri Shell Helper"));
    app.setApplicationVersion(QStringLiteral(LIRI_VERSION_STRING));
    app.setOrganizationName(QStringLiteral("Liri"));
    app.setOrganizationDomain(QStringLiteral("liri.io"));
    app.setFallbackSessionManagementEnabled(false);
    app.setQuitOnLastWindowClosed(false);

    // Print version information
    qDebug("== Liri Shell Helper v%s (Green Island v%s) ==\n"
           "** http://liri.io\n"
           "** Bug reports to: https://github.com/lirios/shell/issues\n"
           "** Build: %s-%s",
           LIRI_VERSION_STRING, GREENISLAND_VERSION_STRING,
           LIRI_VERSION_STRING, GIT_REV);

    // Create shell helper
    new ShellHelperApplication();

    return app.exec();
}
コード例 #8
0
void X11WindowedBackend::createWindow()
{
    Xcb::Atom protocolsAtom(QByteArrayLiteral("WM_PROTOCOLS"), false, m_connection);
    Xcb::Atom deleteWindowAtom(QByteArrayLiteral("WM_DELETE_WINDOW"), false, m_connection);
    for (int i = 0; i < initialOutputCount(); ++i) {
        Output o;
        o.window = xcb_generate_id(m_connection);
        uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
        const uint32_t values[] = {
            m_screen->black_pixel,
            XCB_EVENT_MASK_KEY_PRESS |
            XCB_EVENT_MASK_KEY_RELEASE |
            XCB_EVENT_MASK_BUTTON_PRESS |
            XCB_EVENT_MASK_BUTTON_RELEASE |
            XCB_EVENT_MASK_POINTER_MOTION |
            XCB_EVENT_MASK_ENTER_WINDOW |
            XCB_EVENT_MASK_LEAVE_WINDOW |
            XCB_EVENT_MASK_STRUCTURE_NOTIFY |
            XCB_EVENT_MASK_EXPOSURE
        };
        o.size = initialWindowSize();
        if (!m_windows.isEmpty()) {
            const auto &p = m_windows.last();
            o.internalPosition = QPoint(p.internalPosition.x() + p.size.width(), 0);
        }
        xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, o.window, m_screen->root,
                        0, 0, o.size.width(), o.size.height(),
                        0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, mask, values);

        o.winInfo = new NETWinInfo(m_connection, o.window, m_screen->root, NET::WMWindowType, NET::Properties2());
        o.winInfo->setWindowType(NET::Normal);
        o.winInfo->setPid(QCoreApplication::applicationPid());
        QIcon windowIcon = QIcon::fromTheme(QStringLiteral("kwin"));
        auto addIcon = [&o, &windowIcon] (const QSize &size) {
            if (windowIcon.actualSize(size) != size) {
                return;
            }
            NETIcon icon;
            icon.data = windowIcon.pixmap(size).toImage().bits();
            icon.size.width = size.width();
            icon.size.height = size.height();
            o.winInfo->setIcon(icon, false);
        };
        addIcon(QSize(16, 16));
        addIcon(QSize(32, 32));
        addIcon(QSize(48, 48));

        xcb_map_window(m_connection, o.window);

        m_protocols = protocolsAtom;
        m_deleteWindowProtocol = deleteWindowAtom;
        xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, o.window, m_protocols, XCB_ATOM_ATOM, 32, 1, &m_deleteWindowProtocol);

        m_windows << o;
    }

    updateWindowTitle();

    xcb_flush(m_connection);
}
コード例 #9
0
void PhysicsGeometry::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e){
    Qt3DCore::QScenePropertyChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QScenePropertyChange>(e);
    QByteArray propertyName = propertyChange->propertyName();
    switch (e->type()) {
    case Qt3DCore::NodeAdded: {
        if (propertyName == QByteArrayLiteral("attribute")) {
            m_attributes.push_back(propertyChange->value().value<Qt3DCore::QNodeId>());
        }
        break;
    }
    case Qt3DCore::NodeRemoved: {
        if (propertyName == QByteArrayLiteral("attribute")) {
            m_attributes.removeOne(propertyChange->value().value<Qt3DCore::QNodeId>());
        }
        break;
    }
    case Qt3DCore::NodeUpdated:
        if (propertyName == QByteArrayLiteral("enabled")){
            m_enabled = propertyChange->value().value<bool>();
        }
        else if (propertyName == QByteArrayLiteral("verticesPerPatch")) {
            m_verticesPerPatch = propertyChange->value().value<int>();
            break;
        }
    default:
        break;
    }
}
コード例 #10
0
bool QQnxButtonEventNotifier::parsePPS(const QByteArray &ppsData, QHash<QByteArray, QByteArray> *messageFields) const
{
    // tokenize pps data into lines
    QList<QByteArray> lines = ppsData.split('\n');

    // validate pps object
    if (lines.size() == 0 || !lines.at(0).contains(QByteArrayLiteral("@status"))) {
        qWarning("QQNX: unrecognized pps object, data=%s", ppsData.constData());
        return false;
    }

    // parse pps object attributes and extract values
    for (int i = 1; i < lines.size(); i++) {

        // tokenize current attribute
        const QByteArray &attr = lines.at(i);

        qButtonDebug() << Q_FUNC_INFO << "attr=" << attr;

        int doubleColon = attr.indexOf(QByteArrayLiteral("::"));
        if (doubleColon == -1) {
            // abort - malformed attribute
            continue;
        }

        QByteArray key = attr.left(doubleColon);
        QByteArray value = attr.mid(doubleColon + 2);
        messageFields->insert(key, value);
    }
    return true;
}
コード例 #11
0
ファイル: textureimage.cpp プロジェクト: 2gis/2gisqt5android
void TextureImage::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
    QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);

    if (e->type() == NodeUpdated) {
        if (propertyChange->propertyName() == QByteArrayLiteral("layer")) {
            m_layer = propertyChange->value().toInt();
            m_dirty = true;
        } else if (propertyChange->propertyName() == QByteArrayLiteral("mipmapLevel")) {
            m_mipmapLevel = propertyChange->value().toInt();
            m_dirty = true;
        } else if (propertyChange->propertyName() == QByteArrayLiteral("cubeMapFace")) {
            m_face = static_cast<QAbstractTextureProvider::CubeMapFace>(propertyChange->value().toInt());
            m_dirty = true;
        } else if (propertyChange->propertyName() == QByteArrayLiteral("dataFunctor")) {
            m_functor = propertyChange->value().value<QTextureDataFunctorPtr>();
            m_dirty = true;
        }
    }
    if (m_dirty) {// Notify the Texture that we were updated and request it to schedule an update job
        Texture *txt = m_textureManager->data(m_textureProvider);
        if (txt != Q_NULLPTR)
            txt->addToPendingTextureJobs();
    }
}
コード例 #12
0
MaterialPtr NormalMapScene::createTextureMaterial( const QString& diffuseFileName,
                                                   const QString& normalFileName )
{
    // Create a material and set the shaders
    MaterialPtr material( new Material );
#if !defined(Q_OS_MAC)
    material->setShaders( ":/shaders/normalmap.vert",
                          ":/shaders/normalmap.frag" );
#else
    material->setShaders( ":/shaders/normalmap_2_1.vert",
                          ":/shaders/normalmap_2_1.frag" );
#endif

    // Create a diffuse texture
    TexturePtr texture0( new Texture( Texture::Texture2D ) );
    texture0->create();
    texture0->bind();
    texture0->setImage( QImage( diffuseFileName ) );
    texture0->generateMipMaps();

    // Create a normal map
    TexturePtr texture1( new Texture( Texture::Texture2D ) );
    texture1->create();
    texture1->bind();
    texture1->setImage( QImage( normalFileName ) );
    texture1->generateMipMaps();

#if !defined(Q_OS_MAC)
    // Create a sampler. This can be shared by many textures
    SamplerPtr sampler( new Sampler );
    sampler->create();
    sampler->setWrapMode( Sampler::DirectionS, GL_CLAMP_TO_EDGE );
    sampler->setWrapMode( Sampler::DirectionT, GL_CLAMP_TO_EDGE );
    sampler->setMinificationFilter( GL_LINEAR_MIPMAP_LINEAR );
    sampler->setMagnificationFilter( GL_LINEAR );

    // Associate the textures with the first 2 texture units
    material->setTextureUnitConfiguration( 0, texture0, sampler, QByteArrayLiteral( "texture0" ) );
    material->setTextureUnitConfiguration( 1, texture1, sampler, QByteArrayLiteral( "texture1" ) );
#else
    texture0->bind();
    texture0->setWrapMode( Texture::DirectionS, GL_CLAMP_TO_EDGE );
    texture0->setWrapMode( Texture::DirectionT, GL_CLAMP_TO_EDGE );
    texture0->setMinificationFilter( GL_LINEAR_MIPMAP_LINEAR );
    texture0->setMagnificationFilter( GL_LINEAR );

    texture1->bind();
    texture1->setWrapMode( Texture::DirectionS, GL_CLAMP_TO_EDGE );
    texture1->setWrapMode( Texture::DirectionT, GL_CLAMP_TO_EDGE );
    texture1->setMinificationFilter( GL_LINEAR_MIPMAP_LINEAR );
    texture1->setMagnificationFilter( GL_LINEAR );

    // Associate the textures with the first 2 texture units
    material->setTextureUnitConfiguration( 0, texture0, QByteArrayLiteral( "texture0" ) );
    material->setTextureUnitConfiguration( 1, texture1, QByteArrayLiteral( "texture1" ) );
#endif

    return material;
}
コード例 #13
0
void deserializeInitDynamicPacket(QDataStream &in, QMetaObjectBuilder &builder, QVariantList &values)
{
    quint32 numSignals = 0;
    quint32 numMethods = 0;
    quint32 numProperties = 0;

    in >> numSignals;
    in >> numMethods;

    int curIndex = 0;

    for (quint32 i = 0; i < numSignals; ++i) {
        QByteArray signature;
        in >> signature;
        ++curIndex;
        builder.addSignal(signature);
    }

    for (quint32 i = 0; i < numMethods; ++i) {
        QByteArray signature, returnType;

        in >> signature;
        in >> returnType;
        ++curIndex;
        const bool isVoid = returnType.isEmpty() || returnType == QByteArrayLiteral("void");
        if (isVoid)
            builder.addMethod(signature);
        else
            builder.addMethod(signature, QByteArrayLiteral("QRemoteObjectPendingCall"));
    }

    in >> numProperties;
    const quint32 initialListSize = values.size();
    if (static_cast<quint32>(values.size()) < numProperties)
        values.reserve(numProperties);
    else if (static_cast<quint32>(values.size()) > numProperties)
        for (quint32 i = numProperties; i < initialListSize; ++i)
            values.removeLast();

    for (quint32 i = 0; i < numProperties; ++i) {
        QByteArray name;
        QByteArray typeName;
        QByteArray signalName;
        in >> name;
        in >> typeName;
        in >> signalName;
        if (signalName.isEmpty())
            builder.addProperty(name, typeName);
        else
            builder.addProperty(name, typeName, builder.indexOfSignal(signalName));
        QVariant value;
        in >> value;
        if (i < initialListSize)
            values[i] = value;
        else
            values.append(value);
    }
}
コード例 #14
0
void NetworkUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) {
  if (m_sendDNT) {
    info.setHttpHeader(QByteArrayLiteral("DNT"), QByteArrayLiteral("1"));
  }

  // NOTE: Here we can add custom headers for each webengine request, for example "User-Agent".

  foreach (UrlInterceptor* interceptor, m_interceptors) {
    interceptor->interceptRequest(info);
  }
コード例 #15
0
ファイル: clearbuffer.cpp プロジェクト: James-intern/Qt
void ClearBuffer::sceneChangeEvent(const QSceneChangePtr &e)
{
    if (e->type() == NodeUpdated) {
        QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
        if (propertyChange->propertyName() == QByteArrayLiteral("buffers"))
            m_type = static_cast<QClearBuffer::BufferType>(propertyChange->value().toInt());
        else if (propertyChange->propertyName() == QByteArrayLiteral("enabled"))
            setEnabled(propertyChange->value().toBool());
    }
}
コード例 #16
0
    //////////////////////////////////////////////////////////////////////////
    // TransparentScrollButton
    //////////////////////////////////////////////////////////////////////////
    TransparentScrollButton::TransparentScrollButton(QWidget *parent)
        : QWidget(parent)
        , transparentAnimation_(new TransparentAnimation(L::minOpacity, L::maxOpacity, this))
        , isHovered_(false)
    {
        maxSizeAnimation_ = new QPropertyAnimation(this, QByteArrayLiteral("maximumWidth"), this);
        minSizeAnimation_ = new QPropertyAnimation(this, QByteArrayLiteral("minimumWidth"), this);

        connect(transparentAnimation_, &TransparentAnimation::fadeOutStarted, this, &TransparentScrollButton::fadeOutStarted);
    }
コード例 #17
0
void tst_qmldiskcache::regenerateAfterChange()
{
    QQmlEngine engine;
    TestCompiler testCompiler(&engine);

    QVERIFY(testCompiler.tempDir.isValid());

    const QByteArray contents = QByteArrayLiteral("import QtQml 2.0\n"
                                                  "QtObject {\n"
                                                   "    property string blah: Qt.platform;\n"
                                                   "}");

    QVERIFY2(testCompiler.compile(contents), qPrintable(testCompiler.lastErrorString));

    {
        const QV4::CompiledData::Unit *testUnit = testCompiler.mapUnit();
        QVERIFY2(testUnit, qPrintable(testCompiler.lastErrorString));

        QCOMPARE(quint32(testUnit->nObjects), quint32(1));

        const QV4::CompiledData::Object *obj = testUnit->objectAt(0);
        QCOMPARE(quint32(obj->nBindings), quint32(1));
        QCOMPARE(quint32(obj->bindingTable()->type), quint32(QV4::CompiledData::Binding::Type_Script));
        QCOMPARE(quint32(obj->bindingTable()->value.compiledScriptIndex), quint32(1));

        QCOMPARE(quint32(testUnit->functionTableSize), quint32(2));

        const QV4::CompiledData::Function *bindingFunction = testUnit->functionAt(1);
        QVERIFY(bindingFunction->codeOffset > testUnit->unitSize);
    }

    {
        const QByteArray newContents = QByteArrayLiteral("import QtQml 2.0\n"
                                                         "QtObject {\n"
                                                         "    property string blah: Qt.platform;\n"
                                                         "    property int secondProperty: 42;\n"
                                                         "}");

        QVERIFY2(testCompiler.compile(newContents), qPrintable(testCompiler.lastErrorString));
        const QV4::CompiledData::Unit *testUnit = testCompiler.mapUnit();
        QVERIFY2(testUnit, qPrintable(testCompiler.lastErrorString));

        QCOMPARE(quint32(testUnit->nObjects), quint32(1));

        const QV4::CompiledData::Object *obj = testUnit->objectAt(0);
        QCOMPARE(quint32(obj->nBindings), quint32(2));
        QCOMPARE(quint32(obj->bindingTable()->type), quint32(QV4::CompiledData::Binding::Type_Number));
        QCOMPARE(obj->bindingTable()->valueAsNumber(), double(42));

        QCOMPARE(quint32(testUnit->functionTableSize), quint32(2));

        const QV4::CompiledData::Function *bindingFunction = testUnit->functionAt(1);
        QVERIFY(bindingFunction->codeOffset > testUnit->unitSize);
    }
}
コード例 #18
0
ファイル: parameter.cpp プロジェクト: 2gis/2gisqt5android
void Parameter::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
    QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);

    if (e->type() == NodeUpdated) {
        if (propertyChange->propertyName() == QByteArrayLiteral("name"))
            m_name = propertyChange->value().toString();
        else if (propertyChange->propertyName() == QByteArrayLiteral("value"))
            m_value = toBackendValue(propertyChange->value());
    }
}
コード例 #19
0
ファイル: UserModel.cpp プロジェクト: MartinBriza/sddm
    QHash<int, QByteArray> UserModel::roleNames() const {
        // set role names
        QHash<int, QByteArray> roleNames;
        roleNames[NameRole] = QByteArrayLiteral("name");
        roleNames[RealNameRole] = QByteArrayLiteral("realName");
        roleNames[HomeDirRole] = QByteArrayLiteral("homeDir");
        roleNames[IconRole] = QByteArrayLiteral("icon");
        roleNames[NeedsPasswordRole] = QByteArrayLiteral("needsPassword");

        return roleNames;
    }
コード例 #20
0
static bool isGPUTestBlacklisted(const char *slot, const char *data = 0)
{
    const QByteArray disableKey = QByteArrayLiteral("disable_") + QByteArray(slot);
    if (gpuFeatures->find(disableKey) != gpuFeatures->end()) {
        QByteArray msg = QByteArrayLiteral("Skipped due to GPU blacklist: ") + disableKey;
        if (data)
            msg += ':' + QByteArray(data);
        QTest::qSkip(msg.constData(), __FILE__, __LINE__);
        return true;
    }
    return false;
}
コード例 #21
0
ファイル: additiveclipblend.cpp プロジェクト: RSATom/Qt
void AdditiveClipBlend::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
    if (e->type() == Qt3DCore::PropertyUpdated) {
        Qt3DCore::QPropertyUpdatedChangePtr change = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
        if (change->propertyName() == QByteArrayLiteral("additiveFactor"))
            m_additiveFactor = change->value().toFloat();
        else if (change->propertyName() == QByteArrayLiteral("baseClip"))
            m_baseClipId = change->value().value<Qt3DCore::QNodeId>();
        else if (change->propertyName() == QByteArrayLiteral("additiveClip"))
            m_additiveClipId = change->value().value<Qt3DCore::QNodeId>();
    }
}
コード例 #22
0
static int resourceType(const QByteArray &key)
{
    static const QByteArray names[] = { // match ResourceType
        QByteArrayLiteral("egldisplay"),
        QByteArrayLiteral("eglwindow"),
        QByteArrayLiteral("eglcontext")
    };
    const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
    const QByteArray *result = std::find(names, end, key);
    if (result == end)
        result = std::find(names, end, key.toLower());
    return int(result - names);
}
コード例 #23
0
ファイル: tst_qicns.cpp プロジェクト: Drakey83/steamlink-sdk
void tst_qicns::readIcons_data()
{
    QTest::addColumn<QString>("fileName");
    QTest::addColumn<QSize>("size");
    QTest::addColumn<int>("imageCount");
    QTest::addColumn<QByteArray>("format");

    QTest::newRow("1") << QStringLiteral("test-png") << QSize(128, 128) << 7 << QByteArrayLiteral("png");
    QTest::newRow("2") << QStringLiteral("test-jp2") << QSize(128, 128) << 7 << QByteArrayLiteral("jp2");
    QTest::newRow("3") << QStringLiteral("test-32bit") << QSize(128, 128) << 4 << QByteArray();
    QTest::newRow("4") << QStringLiteral("test-legacy") << QSize(48, 48) << 12 << QByteArray();
    QTest::newRow("5") << QStringLiteral("test-variants") << QSize(128, 128) << 5 << QByteArrayLiteral("png");
}
コード例 #24
0
    //////////////////////////////////////////////////////////////////////////
    // TransparentScrollButtonH
    //////////////////////////////////////////////////////////////////////////
    TransparentScrollButtonH::TransparentScrollButtonH(QWidget *parent)
        : TransparentScrollButton(parent)
        , minScrollButtonHeight_(Utils::scale_value(L::minScrollButtonWidth_dip))
        , maxScrollButtonHeight_(Utils::scale_value(L::maxScrollButtonWidth_dip))
        , minScrollButtonWidth_(Utils::scale_value(L::minScrollButtonHeight_dip))
    {
        maxSizeAnimation_ = new QPropertyAnimation(this, QByteArrayLiteral("maximumHeight"), this);
        minSizeAnimation_ = new QPropertyAnimation(this, QByteArrayLiteral("minimumHeight"), this);

        setMaximumWidth(minScrollButtonWidth_);
        setMinimumWidth(minScrollButtonWidth_);
        setMaximumHeight(minScrollButtonHeight_);
        setMinimumHeight(minScrollButtonHeight_);
    }
コード例 #25
0
ファイル: axissetting.cpp プロジェクト: RSATom/Qt
void AxisSetting::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
    if (e->type() == Qt3DCore::PropertyUpdated) {
        Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
        if (propertyChange->propertyName() == QByteArrayLiteral("deadZoneRadius")) {
            m_deadZoneRadius = propertyChange->value().toFloat();
        } else if (propertyChange->propertyName() == QByteArrayLiteral("axes")) {
            m_axes = propertyChange->value().value<QVector<int>>();
        } else if (propertyChange->propertyName() == QByteArrayLiteral("smooth")) {
            m_smooth = propertyChange->value().toBool();
        }
    }
    QBackendNode::sceneChangeEvent(e);
}
コード例 #26
0
ファイル: kwingltexture.cpp プロジェクト: KDE/kwin
void GLTexturePrivate::initStatic()
{
    if (!GLPlatform::instance()->isGLES()) {
        s_supportsFramebufferObjects = hasGLVersion(3, 0) ||
            hasGLExtension("GL_ARB_framebuffer_object") || hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_object"));
        s_supportsTextureStorage = hasGLVersion(4, 2) || hasGLExtension(QByteArrayLiteral("GL_ARB_texture_storage"));
        s_supportsTextureSwizzle = hasGLVersion(3, 3) || hasGLExtension(QByteArrayLiteral("GL_ARB_texture_swizzle"));
        // see https://www.opengl.org/registry/specs/ARB/texture_rg.txt
        s_supportsTextureFormatRG = hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_ARB_texture_rg"));
        s_supportsARGB32 = true;
        s_supportsUnpack = true;
    } else {
        s_supportsFramebufferObjects = true;
        s_supportsTextureStorage = hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_EXT_texture_storage"));
        s_supportsTextureSwizzle = hasGLVersion(3, 0);
        // see https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_rg.txt
        s_supportsTextureFormatRG = hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_EXT_texture_rg"));

        // QImage::Format_ARGB32_Premultiplied is a packed-pixel format, so it's only
        // equivalent to GL_BGRA/GL_UNSIGNED_BYTE on little-endian systems.
        s_supportsARGB32 = QSysInfo::ByteOrder == QSysInfo::LittleEndian &&
            hasGLExtension(QByteArrayLiteral("GL_EXT_texture_format_BGRA8888"));

        s_supportsUnpack = hasGLExtension(QByteArrayLiteral("GL_EXT_unpack_subimage"));
    }
}
コード例 #27
0
void PhysicsGeometryRenderer::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e){
    switch (e->type()) {
        case Qt3DCore::NodeUpdated: {
            Qt3DCore::QScenePropertyChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QScenePropertyChange>(e);
            QByteArray propertyName = propertyChange->propertyName();
            if (propertyName == QByteArrayLiteral("geometryFunctor")){ // Mesh with source
                m_geometry_functor= propertyChange->value().value<Qt3DRender::QGeometryFunctorPtr>();
                m_dirty=true;
            }
            else if (propertyName == QByteArrayLiteral("enabled")){
                m_enabled = propertyChange->value().value<bool>();
            }else if (propertyChange->propertyName() == QByteArrayLiteral("instanceCount")) {
                m_instanceCount = propertyChange->value().value<int>();
                m_dirty = true;
            } else if (propertyName == QByteArrayLiteral("primitiveCount")) {
                m_primitiveCount = propertyChange->value().value<int>();
                m_dirty = true;
            } else if (propertyName == QByteArrayLiteral("baseVertex")) {
                m_baseVertex = propertyChange->value().value<int>();
                m_dirty = true;
            } else if (propertyName == QByteArrayLiteral("baseInstance")) {
                m_baseInstance = propertyChange->value().value<int>();
                m_dirty = true;
            } else if (propertyName == QByteArrayLiteral("restartIndex")) {
                m_restartIndex = propertyChange->value().value<int>();
                m_dirty = true;
            } else if (propertyName == QByteArrayLiteral("primitiveRestart")) {
                m_primitiveRestart = propertyChange->value().value<bool>();
                m_dirty = true;
            }
            break;
    }
    case Qt3DCore::NodeAdded: {
        Qt3DCore::QScenePropertyChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QScenePropertyChange>(e);
        if (propertyChange->propertyName() == QByteArrayLiteral("geometry")) {
            m_geometry = propertyChange->value().value<Qt3DCore::QNodeId>();
        }
        break;
    }
    case Qt3DCore::NodeRemoved: {
        Qt3DCore::QScenePropertyChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QScenePropertyChange>(e);
        if (propertyChange->propertyName() == QByteArrayLiteral("geometry")) {
            m_geometry = Qt3DCore::QNodeId();
        }
        break;
    }
    default:
        break;
    }
}
コード例 #28
0
ファイル: qsslkey_p.cpp プロジェクト: James-intern/Qt
/*!
    \internal
*/
QByteArray QSslKeyPrivate::pemHeader() const
{
    if (type == QSsl::PublicKey)
        return QByteArrayLiteral("-----BEGIN PUBLIC KEY-----");
    else if (algorithm == QSsl::Rsa)
        return QByteArrayLiteral("-----BEGIN RSA PRIVATE KEY-----");
    else if (algorithm == QSsl::Dsa)
        return QByteArrayLiteral("-----BEGIN DSA PRIVATE KEY-----");
    else if (algorithm == QSsl::Ec)
        return QByteArrayLiteral("-----BEGIN EC PRIVATE KEY-----");

    Q_UNREACHABLE();
    return QByteArray();
}
コード例 #29
0
ファイル: assimphelpers.cpp プロジェクト: 2gis/2gisqt5android
/*!
 * Builds a new instance of AssimpIOSystem.
 */
AssimpIOSystem::AssimpIOSystem() :
    Assimp::IOSystem()
{
    m_openModeMaps[QByteArrayLiteral("r")] = QIODevice::ReadOnly;
    m_openModeMaps[QByteArrayLiteral("r+")] = QIODevice::ReadWrite;
    m_openModeMaps[QByteArrayLiteral("w")] = QIODevice::WriteOnly | QIODevice::Truncate;
    m_openModeMaps[QByteArrayLiteral("w+")] = QIODevice::ReadWrite | QIODevice::Truncate;
    m_openModeMaps[QByteArrayLiteral("a")] = QIODevice::WriteOnly | QIODevice::Append;
    m_openModeMaps[QByteArrayLiteral("a+")] = QIODevice::ReadWrite | QIODevice::Append;
    m_openModeMaps[QByteArrayLiteral("wb")] = QIODevice::WriteOnly;
    m_openModeMaps[QByteArrayLiteral("wt")] = QIODevice::WriteOnly | QIODevice::Text;
    m_openModeMaps[QByteArrayLiteral("rb")] = QIODevice::ReadOnly;
    m_openModeMaps[QByteArrayLiteral("rt")] = QIODevice::ReadOnly | QIODevice::Text;
}
コード例 #30
0
void tst_qmldiskcache::fileSelectors()
{
    QQmlEngine engine;

    QTemporaryDir tempDir;
    QVERIFY(tempDir.isValid());

    const QString testFilePath = tempDir.path() + "/test.qml";
    {
        QFile f(testFilePath);
        QVERIFY2(f.open(QIODevice::WriteOnly), qPrintable(f.errorString()));
        f.write(QByteArrayLiteral("import QtQml 2.0\nQtObject { property int value: 42 }"));
    }

    const QString selector = QStringLiteral("testSelector");
    const QString selectorPath = tempDir.path() + "/+" + selector;
    const QString selectedTestFilePath = selectorPath + "/test.qml";
    {
        QVERIFY(QDir::root().mkpath(selectorPath));
        QFile f(selectorPath + "/test.qml");
        QVERIFY2(f.open(QIODevice::WriteOnly), qPrintable(f.errorString()));
        f.write(QByteArrayLiteral("import QtQml 2.0\nQtObject { property int value: 100 }"));
    }

    {
        QQmlComponent component(&engine, testFilePath);
        QScopedPointer<QObject> obj(component.create());
        QVERIFY(!obj.isNull());
        QCOMPARE(obj->property("value").toInt(), 42);

        QFile cacheFile(testFilePath + "c");
        QVERIFY2(cacheFile.exists(), qPrintable(cacheFile.fileName()));
    }

    QQmlFileSelector qmlSelector(&engine);
    qmlSelector.setExtraSelectors(QStringList() << selector);

    engine.clearComponentCache();

    {
        QQmlComponent component(&engine, testFilePath);
        QScopedPointer<QObject> obj(component.create());
        QVERIFY(!obj.isNull());
        QCOMPARE(obj->property("value").toInt(), 100);

        QFile cacheFile(selectedTestFilePath + "c");
        QVERIFY2(cacheFile.exists(), qPrintable(cacheFile.fileName()));
    }
}