Exemplo n.º 1
0
void TestSimpleQmlLoad::loadSignal3()
{
    QQmlEngine *engine = new QQmlEngine;
    const QString TEST_FILE(":/testqml/testsignal3.qml");
    QQmlComponent* component = load(engine, TEST_FILE);
    QVERIFY(component);

    SignalTester st;

    engine->rootContext()->setContextProperty("st", &st);

    QObject *myObject = component->create();
    QVERIFY(myObject != NULL);

    st.sendSig();

    QVariant ret;
    QMetaObject::invokeMethod(myObject, "getSubWidth1", Q_RETURN_ARG(QVariant, ret));
    QVERIFY(ret.toInt() == 10);

    st.sendSig();

    QMetaObject::invokeMethod(myObject, "getSubWidth1", Q_RETURN_ARG(QVariant, ret));
    QVERIFY(ret.toInt() == 20);

    delete component;
    delete engine;
}
Exemplo n.º 2
0
void tst_qmldiskcache::cppRegisteredSingletonDependency()
{
    qmlClearTypeRegistrations();
    QScopedPointer<QQmlEngine> engine(new QQmlEngine);

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

    const auto writeTempFile = [&tempDir](const QString &fileName, const char *contents) {
        QFile f(tempDir.path() + '/' + fileName);
        const bool ok = f.open(QIODevice::WriteOnly | QIODevice::Truncate);
        Q_ASSERT(ok);
        f.write(contents);
        return f.fileName();
    };

    writeTempFile("MySingleton.qml", "import QtQml 2.0\npragma Singleton\nQtObject { property int value: 42 }");

    qmlRegisterSingletonType(QUrl::fromLocalFile(tempDir.path() + QLatin1String("/MySingleton.qml")), "CppRegisteredSingletonDependency", 1, 0, "Singly");

    const QString testFilePath = writeTempFile("main.qml", "import QtQml 2.0\nimport CppRegisteredSingletonDependency 1.0\nQtObject {\n"
                                                           "    function getValue() { return Singly.value; }\n"
                                                           "}");

    {
        CleanlyLoadingComponent component(engine.data(), QUrl::fromLocalFile(testFilePath));
        QScopedPointer<QObject> obj(component.create());
        QVERIFY(!obj.isNull());
        QVariant value;
        QVERIFY(QMetaObject::invokeMethod(obj.data(), "getValue", Q_RETURN_ARG(QVariant, value)));
        QCOMPARE(value.toInt(), 42);
    }

    const QString testFileCachePath = testFilePath + QLatin1Char('c');
    QVERIFY(QFile::exists(testFileCachePath));
    QDateTime initialCacheTimeStamp = QFileInfo(testFileCachePath).lastModified();

    engine.reset(new QQmlEngine);
    waitForFileSystem();

    writeTempFile("MySingleton.qml", "import QtQml 2.0\npragma Singleton\nQtObject { property int value: 100 }");
    waitForFileSystem();

    {
        CleanlyLoadingComponent component(engine.data(), QUrl::fromLocalFile(testFilePath));
        QScopedPointer<QObject> obj(component.create());
        QVERIFY(!obj.isNull());

        {
            QVERIFY(QFile::exists(testFileCachePath));
            QDateTime newCacheTimeStamp = QFileInfo(testFileCachePath).lastModified();
            QVERIFY2(newCacheTimeStamp > initialCacheTimeStamp, qPrintable(newCacheTimeStamp.toString()));
        }

        QVariant value;
        QVERIFY(QMetaObject::invokeMethod(obj.data(), "getValue", Q_RETURN_ARG(QVariant, value)));
        QCOMPARE(value.toInt(), 100);
    }
}
Exemplo n.º 3
0
AudioLayer::AudioLayer(QQmlApplicationEngine *engine, QObject *parent):
    QObject(parent),
    m_engine(nullptr)
{
    this->m_inputState = AkElement::ElementStateNull;
    this->setQmlEngine(engine);
    this->m_pipeline = AkElement::create("Bin", "pipeline");

    if (this->m_pipeline) {
        QFile jsonFile(":/Webcamoid/share/audiopipeline.json");
        jsonFile.open(QFile::ReadOnly);
        QString description(jsonFile.readAll());
        jsonFile.close();

        this->m_pipeline->setProperty("description", description);

        QMetaObject::invokeMethod(this->m_pipeline.data(),
                                  "element",
                                  Q_RETURN_ARG(AkElementPtr, this->m_audioOut),
                                  Q_ARG(QString, "audioOut"));
        QMetaObject::invokeMethod(this->m_pipeline.data(),
                                  "element",
                                  Q_RETURN_ARG(AkElementPtr, this->m_audioIn),
                                  Q_ARG(QString, "audioIn"));
        QMetaObject::invokeMethod(this->m_pipeline.data(),
                                  "element",
                                  Q_RETURN_ARG(AkElementPtr, this->m_audioGenerator),
                                  Q_ARG(QString, "audioGenerator"));
        QMetaObject::invokeMethod(this->m_pipeline.data(),
                                  "element",
                                  Q_RETURN_ARG(AkElementPtr, this->m_audioSwitch),
                                  Q_ARG(QString, "audioSwitch"));
    }

    if (this->m_audioOut) {
        QString device = this->m_audioOut->property("defaultOutput").toString();
        this->m_audioOut->setProperty("device", device);
        this->m_outputDeviceCaps = this->m_audioOut->property("caps").value<AkCaps>();

        QObject::connect(this->m_audioOut.data(),
                         SIGNAL(deviceChanged(const QString &)),
                         this,
                         SIGNAL(audioOutputChanged(const QString &)));
        QObject::connect(this->m_audioOut.data(),
                         SIGNAL(capsChanged(const AkCaps &)),
                         this,
                         SLOT(setOutputDeviceCaps(const AkCaps &)));
        QObject::connect(this->m_audioOut.data(),
                         SIGNAL(outputsChanged(const QStringList &)),
                         this,
                         SIGNAL(outputsChanged(const QStringList &)));
        QObject::connect(this->m_audioOut.data(),
                         SIGNAL(stateChanged(AkElement::ElementState)),
                         this,
                         SIGNAL(outputStateChanged(AkElement::ElementState)));
    }
Exemplo n.º 4
0
void FileIO::read()
{
    if (m_source.isEmpty()){
        emit error("source is empty");
        return;
    } else if (m_target == 0){
        emit error("target is not set");
        return;
    }

    QFile file(m_source);
    if ( file.open(QIODevice::ReadOnly) ) {
        QString line;
        QTextStream t( &file );
        QVariant length = m_target->property("length");
        QVariant returnedValue;

        if(length>0){
            QMetaObject::invokeMethod(m_target, "remove",
                                      Q_RETURN_ARG(QVariant, returnedValue),
                                      Q_ARG(QVariant, QVariant(0)),
                                      Q_ARG(QVariant, length));
            m_lineOffsets.clear();
            m_lineOffsets.push_back(1);
        }
        do {
            line = t.readLine();
            line.replace("\t","        ");
            m_lineOffsets.push_back(line.length()+1);
            line.replace("<","&lt;").replace(">","&gt;").replace(" ","&nbsp;");
            QMetaObject::invokeMethod(m_target, "append",
                                      Q_RETURN_ARG(QVariant, returnedValue),
                                      Q_ARG(QVariant, QVariant(line)));
        } while (!t.atEnd());

        file.close();
        QVariant doc = m_target->property("textDocument");
        if (doc.canConvert<QQuickTextDocument*>()) {
            QQuickTextDocument *qqdoc = doc.value<QQuickTextDocument*>();
            if (qqdoc)
                m_doc = qqdoc->textDocument();
            m_highlighter = new Highlighter(m_doc);
            m_highlighter->setStyle(12);
        }
    } else {
        emit error("Unable to open the file");
        return;
    }
}
void SocketController::getPortStatusCountersList()
{
    if (!connectionLost)
    {
        QMetaObject::invokeMethod(portStatusCountersModel, "clear");
        QVariant retValue;
        //QString data = "1        0              0               0            0              0               0 \n2        0              0               0            0              0               0 \n3        0              0               0            0              0               0 \n4         0              0               0            0              0               0  \n5         0              0               0            0              0               0  \n6         0              0               0            0              0               0  \n7         0              0               0            0              0               0  \n8         0              0               0            0              0               0  \n";
        QString data = getParamInfo("PortStatusCountersList");

        if(data == emptyString)
        {
            logOutSignal();
            return;
        }

        PortStatusCountersParser* parser = new PortStatusCountersParser();
        PortStatusCountParseResult result;
        result = parser->parsePortStatusCountData(data);
        int portsCount = result.params[0].length();

        for(int i = 0; i < portsCount; i++)
        {
            QMetaObject::invokeMethod(portStatusCountersModel, "addPortStatusCounter",
                                      Q_RETURN_ARG(QVariant, retValue),
                                      Q_ARG(QVariant, result.params[result.columnIndexes["port"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["rx_packets_count"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["rx_bytes_count"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["error_count"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["tx_packets_count"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["tx_bytes_count"]].at(i)),
                    Q_ARG(QVariant, result.params[result.columnIndexes["collisions"]].at(i)));
        }
    }
}
Exemplo n.º 6
0
QScriptValue WindowScriptingInterface::s3Browse(const QString& nameFilter) {
    QScriptValue retVal;
    QMetaObject::invokeMethod(this, "showS3Browse", Qt::BlockingQueuedConnection,
                              Q_RETURN_ARG(QScriptValue, retVal),
                              Q_ARG(const QString&, nameFilter));
    return retVal;
}
Exemplo n.º 7
0
QScriptValue WindowScriptingInterface::form(const QString& title, QScriptValue form) {
    QScriptValue retVal;
    QMetaObject::invokeMethod(this, "showForm", Qt::BlockingQueuedConnection,
                              Q_RETURN_ARG(QScriptValue, retVal),
                              Q_ARG(const QString&, title), Q_ARG(QScriptValue, form));
    return retVal;
}
Exemplo n.º 8
0
void
IrcQmlChannelGroup::AddChannel (IrcAbstractChannel * newchan)
{
  qDebug () << __PRETTY_FUNCTION__ << newchan << " in " << qmlObject;
  if (newchan == 0) {
    return;
  }
  QVariant chanObjVar;
  QMetaObject::invokeMethod (qmlObject, "addChannel",
              Qt::DirectConnection,
              Q_RETURN_ARG (QVariant, chanObjVar));
  QObject *chanObj = chanObjVar.value<QObject*>();
  qDebug () << __PRETTY_FUNCTION__ << " addChannel from qml returns " << chanObj;
  if (chanObj) {
    chanObj->setProperty ("boxLabel",newchan->Name());
    QObject * model = qobject_cast<QObject*>(newchan->userNamesModel());
    QMetaObject::invokeMethod (chanObj, "setModel",
        Q_ARG (QVariant, qVariantFromValue (model)));
    newchan->SetQmlItem (qobject_cast<QDeclarativeItem*>(chanObj));
    channelList << newchan;
    SetTopmostChannel (newchan);
    SetChannelList ();
  }
  newchan->UpdateCooked ();
  newchan->RefreshNames();
  newchan->RefreshTopic();
}
QStringList SharingAdaptor::GetServicesForType(const QString &type)
{
    // handle method call com.meego.ux.sharing.GetServicesForType
    QStringList services;
    QMetaObject::invokeMethod(parent(), "GetServicesForType", Q_RETURN_ARG(QStringList, services), Q_ARG(QString, type));
    return services;
}
Exemplo n.º 10
0
AnimationPointer AnimationCache::getAnimation(const QUrl& url) {
    if (QThread::currentThread() != thread()) {
        AnimationPointer result;
        QMetaObject::invokeMethod(this, "getAnimation", Qt::BlockingQueuedConnection,
            Q_RETURN_ARG(AnimationPointer, result), Q_ARG(const QUrl&, url));
        return result;
    }
Exemplo n.º 11
0
void VrMenu::addMenu(QMenu* menu) {
    Q_ASSERT(!MenuUserData::hasData(menu->menuAction()));
    QObject* parent = menu->parent();
    QObject* qmlParent = nullptr;
    QMenu* parentMenu = dynamic_cast<QMenu*>(parent);
    if (parentMenu) {
        MenuUserData* userData = MenuUserData::forObject(parentMenu->menuAction());
        if (!userData) {
            return;
        }
        qmlParent = findMenuObject(userData->uuid.toString());
    } else if (dynamic_cast<QMenuBar*>(parent)) {
        qmlParent = _rootMenu;
    } else {
        Q_ASSERT(false);
    }
    QVariant returnedValue;
    bool invokeResult = QMetaObject::invokeMethod(qmlParent, "addMenu", Qt::DirectConnection,
                                                  Q_RETURN_ARG(QVariant, returnedValue),
                                                  Q_ARG(QVariant, QVariant::fromValue(menu->title())));
    Q_ASSERT(invokeResult);
    Q_UNUSED(invokeResult); // FIXME - apparently we haven't upgraded the Qt on our unix Jenkins environments to 5.5.x
    QObject* result = returnedValue.value<QObject*>();
    Q_ASSERT(result);
    if (!result) {
        qWarning() << "Unable to create QML menu for widget menu: " << menu->title();
        return;
    }

    // Bind the QML and Widget together
    new MenuUserData(menu->menuAction(), result);
}
Exemplo n.º 12
0
QString DemoIfAdaptor::SayBye()
{
    // handle method call com.nokia.Demo.SayBye
    QString strret;
    QMetaObject::invokeMethod(parent(), "SayBye", Q_RETURN_ARG(QString, strret));
    return strret;
}
Exemplo n.º 13
0
QDBusObjectPath IBusFactoryAdaptor::CreateEngine(const QString &engine_name)
{
    // handle method call org.freedesktop.IBus.EngineFactory.CreateEngine
    QDBusObjectPath out0;
    QMetaObject::invokeMethod(parent(), "CreateEngine", Q_RETURN_ARG(QDBusObjectPath, out0), Q_ARG(QString, engine_name));
    return out0;
}
Exemplo n.º 14
0
QString EAPDaemonAdapter::LoginUser()
{
    // handle method call com.qh3client.EAPDaemon.LoginUser
    QString out0;
    QMetaObject::invokeMethod(parent(), "LoginUser", Q_RETURN_ARG(QString, out0));
    return out0;
}
Exemplo n.º 15
0
int PresentationDisplayTask::getPanelHeight()
{
    QVariant ret_arg = QVariant::fromValue(0);
    QMetaObject::invokeMethod(m_panel, "getPresentationPanelHeight", Q_RETURN_ARG(QVariant, ret_arg));

    return ret_arg.toInt();
}
Exemplo n.º 16
0
QString ContextdAdaptor::register_for_domain_changes_updates()
{
    // handle method call com.piga.contextd.register_for_domain_changes_updates
    QString out0;
    QMetaObject::invokeMethod(parent(), "register_for_domain_changes_updates", Q_RETURN_ARG(QString, out0));
    return out0;
}
Exemplo n.º 17
0
QString ContextdAdaptor::required_domain(const QString &xml_context)
{
    // handle method call com.piga.contextd.required_domain
    QString out0;
    QMetaObject::invokeMethod(parent(), "required_domain", Q_RETURN_ARG(QString, out0), Q_ARG(QString, xml_context));
    return out0;
}
Exemplo n.º 18
0
ConflictInfo ConflictAdaptor::AskRetry(const QString &in0, const QString &in1, const QString &in2)
{
    // handle method call com.deepin.dde.Desktop.conflict.AskRetry
    ConflictInfo out0;
    QMetaObject::invokeMethod(parent(), "AskRetry", Q_RETURN_ARG(ConflictInfo, out0), Q_ARG(QString, in0), Q_ARG(QString, in1), Q_ARG(QString, in2));
    return out0;
}
QStringList SharingAdaptor::GetAllServices()
{
    // handle method call com.meego.ux.sharing.GetAllServices
    QStringList services;
    QMetaObject::invokeMethod(parent(), "GetAllServices", Q_RETURN_ARG(QStringList, services));
    return services;
}
Exemplo n.º 20
0
ConflictInfo ConflictAdaptor::AskSkip(const QString &in0, const QString &in1, const QString &in2, bool in3, bool in4)
{
    // handle method call com.deepin.dde.Desktop.conflict.AskSkip
    ConflictInfo out0;
    QMetaObject::invokeMethod(parent(), "AskSkip", Q_RETURN_ARG(ConflictInfo, out0), Q_ARG(QString, in0), Q_ARG(QString, in1), Q_ARG(QString, in2), Q_ARG(bool, in3), Q_ARG(bool, in4));
    return out0;
}
Exemplo n.º 21
0
SharedSoundPointer SoundCache::getSound(const QUrl& url) {
    if (QThread::currentThread() != thread()) {
        SharedSoundPointer result;
        QMetaObject::invokeMethod(this, "getSound", Qt::BlockingQueuedConnection,
                                  Q_RETURN_ARG(SharedSoundPointer, result), Q_ARG(const QUrl&, url));
        return result;
    }
Exemplo n.º 22
0
ConflictInfo ConflictAdaptor::ConflictDialog()
{
    // handle method call com.deepin.dde.Desktop.conflict.ConflictDialog
    ConflictInfo out0;
    QMetaObject::invokeMethod(parent(), "ConflictDialog", Q_RETURN_ARG(ConflictInfo, out0));
    return out0;
}
Exemplo n.º 23
0
void Eyrie::process() {
	if(recbin == NULL) {
		return;
	}
	if(GST_BUFFER_SIZE(buf) == 0) {
		endRecording();
		QVariant ret;
		QMetaObject::invokeMethod(parent(), "setStatus", Q_RETURN_ARG(QVariant, ret), Q_ARG(QVariant, "Sorry, the recording failed."));
		return;
	}
	mutex->lock();
	const float *pcm = (const float *) GST_BUFFER_DATA(buf);
	Codegen *codegen = new Codegen(pcm, GST_BUFFER_SIZE(buf) / sizeof(float), 0);
	mutex->unlock();
	std::string code = codegen->getCodeString();
	QNetworkAccessManager *networkManager = new QNetworkAccessManager();
	QUrl url("http://developer.echonest.com/api/v4/song/identify");
	QByteArray params;
	params.append("api_key=RIUKSNTIPKUMPHPEO");
	params.append("&query=[{\"metadata\":{\"version\":4.12},\"code\":\""); params.append(code.c_str()); params.append("\"}]");
	QNetworkRequest request;
	request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded;charset=UTF-8");
	request.setUrl(url);
	connect(networkManager, SIGNAL(finished(QNetworkReply *)), this, SLOT(parseResponse(QNetworkReply *)));
	networkManager->post(request, params);
}
Exemplo n.º 24
0
QString ContextdAdaptor::current_domain()
{
    // handle method call com.piga.contextd.current_domain
    QString out0;
    QMetaObject::invokeMethod(parent(), "current_domain", Q_RETURN_ARG(QString, out0));
    return out0;
}
Exemplo n.º 25
0
void
IrcAbstractChannel::UserSend ()
{
  qDebug () << " User sending " ;
  bool sendout (true);
  if (qmlItem) {
    QVariant userData;
    QMetaObject::invokeMethod (qmlItem, "userData",
        Q_RETURN_ARG (QVariant, userData));
    QString data = userData.toString();
    qDebug () << "   user data " << data;
    if (data.trimmed().length() > 0) {
      QMetaObject::invokeMethod (qmlItem, "clearUserData");
      if (raw) {
        AlmostRaw (data);
      } else if (data == "/part") {
        Part ();
        sendout = false;
      } else if (data.startsWith ("/whois")) {
        data.remove (0, 6);
        Whois (data.trimmed());
        sendout = false;
      }
      if (sendout) {
        emit Outgoing (chanName, data);
      }
      history.append (data);
      history.removeDuplicates ();
      historyIndex = history.size();
    }
  }
}
Exemplo n.º 26
0
QString ContextdAdaptor::domain_changed(const QString &xml_context)
{
    // handle method call com.piga.contextd.domain_changed
    QString out0;
    QMetaObject::invokeMethod(parent(), "domain_changed", Q_RETURN_ARG(QString, out0), Q_ARG(QString, xml_context));
    return out0;
}
Exemplo n.º 27
0
QScriptValue WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) {
    QScriptValue retVal;
    QMetaObject::invokeMethod(this, "showPrompt", Qt::BlockingQueuedConnection,
                              Q_RETURN_ARG(QScriptValue, retVal),
                              Q_ARG(const QString&, message), Q_ARG(const QString&, defaultText));
    return retVal;
}
Exemplo n.º 28
0
QString ContextdAdaptor::is_registered()
{
    // handle method call com.piga.contextd.is_registered
    QString out0;
    QMetaObject::invokeMethod(parent(), "is_registered", Q_RETURN_ARG(QString, out0));
    return out0;
}
Exemplo n.º 29
0
bool
Panto::event (QEvent *evt)
{
  //qDebug () << PANTO_PRETTY_FUNCTION << evt;
  if (evt) {
    QEvent::Type tipo = evt->type ();
    if (tipo ==QEvent::Gesture ) {
      qDebug () << "GESTURE event in " << this;
      QGestureEvent * gev = dynamic_cast <QGestureEvent*> (evt);
      if (gev) {
        qDebug () << " gev " << gev;
      }
      return true;
    } else if (tipo == QEvent::GestureOverride) {
      QGestureEvent * gev = dynamic_cast <QGestureEvent*> (evt);
      if (gev) {
        QDeclarativeItem * dItem = qobject_cast<QDeclarativeItem*>(gev->widget());
        qDebug () << " override what? gev " << gev << gev->widget() << dItem;
        if (dItem) {
          QVariant retVar;
          QMetaObject::invokeMethod (dItem,"handleLoopGesture",
             Q_RETURN_ARG(QVariant, retVar));
          if (retVar.isValid()) {
            return retVar.toBool();
          }
        }
      }
    }
  }
  bool handled = QDeclarativeView::event (evt);
  //qDebug () << PANTO_PRETTY_FUNCTION << " returning " << handled;
  return handled;
}
Exemplo n.º 30
0
QString ContextdAdaptor::register_application(const QString &app_name, uint app_pid)
{
    // handle method call com.piga.contextd.register_application
    QString out0;
    QMetaObject::invokeMethod(parent(), "register_application", Q_RETURN_ARG(QString, out0), Q_ARG(QString, app_name), Q_ARG(uint, app_pid));
    return out0;
}