コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: dekomote/qtwitdget
MainWindow::MainWindow(QWidget *parent) :
    QmlApplicationViewer(parent),
    m_netManager(new QNetworkAccessManager(this)),
    m_oauthTwitter(new OAuthTwitter(this)),
    m_userStream(new QTweetUserStream(this))
{
    m_oauthTwitter->setNetworkAccessManager(m_netManager);
    m_userStream->setOAuthTwitter(m_oauthTwitter);

    qApp->setOrganizationName("QTwitdget");

    connect(m_oauthTwitter, SIGNAL(authorizeXAuthFinished()), this, SLOT(authorizationFinished()));
    connect(m_oauthTwitter, SIGNAL(authorizeXAuthError()), this, SLOT(authorizationFailed()));

    m_database = QSqlDatabase::addDatabase("QSQLITE");

    setupTrayIcon();

    readSettings();

    createDeclarativeView();
}
コード例 #2
0
/*!
    \internal
    Called with an incoming connection
*/
void QJsonServer::handleLocalConnection()
{
    QLocalServer *server = qobject_cast<QLocalServer *>(sender());
    if (!server)
        return;

    if (QLocalSocket *socket = server->nextPendingConnection()) {
        socket->setReadBufferSize(64*1024);
        Q_D(QJsonServer);
        QJsonAuthority *authority = d->m_localServers.value(server);
        QJsonServerClient *client = new QJsonServerClient(this);
        client->setAuthority(authority);
        client->setSocket(socket);
        connect(client, SIGNAL(authorized(const QString&)),
                this, SLOT(handleClientAuthorized(const QString&)));
        connect(client, SIGNAL(disconnected(const QString&)),
                this, SLOT(clientDisconnected(const QString&)));
        connect(client, SIGNAL(messageReceived(const QString&, const QJsonObject&)),
                this, SLOT(receiveMessage(const QString&, const QJsonObject&)));
        connect(client, SIGNAL(authorizationFailed()),
                this, SLOT(handleAuthorizationFailed()));
        client->start();
    }