void WDClient::connected()
{
	qDebug() << "Connected to automatron.";

	connect(mSocket, SIGNAL(disconnected()), this, SLOT(conDisconnected()));
}
void WDClient::socketError(QAbstractSocket::SocketError theError)
{
	qDebug() << "Socket Error! " << theError;
	conDisconnected();
}
Exemple #3
0
void PlayerSetupDialog::setCurrentPlayer(PlayerConnection* con)
{
    if(con == m_con)
        return;

    m_stickyConnectionMessage = false;
    if(m_con)
    {
        disconnect(ui->playerName, 0, m_con, 0);
        disconnect(ui->playerHost, 0, m_con, 0);
        disconnect(ui->playerUser, 0, m_con, 0);
        disconnect(ui->playerPass, 0, m_con, 0);
        disconnect(m_con, 0, this, 0);
    }

    if(m_subviewModel)
    {
        delete m_subviewModel;
        m_subviewModel = 0;
    }

    m_con = con;

    if(!con)
    {
        ui->boxConnection->setEnabled(false);
        ui->boxOutput->setEnabled(false);
        ui->boxSubviewOpts->setEnabled(false);
        ui->boxSubviews->setEnabled(false);
        ui->boxKeystone->setEnabled(true);
        return;
    }

    if(con->isConnected())
        conConnected();
    else
        conDisconnected();

    // Set up the UI with values from the player before connecting slots so we dont needlessly update the object
    ui->playerName->setText(con->name());
    ui->playerHost->setText(con->host());
    ui->playerUser->setText(con->user());
    ui->playerPass->setText(con->pass());
    ui->autoconnectBox->setChecked(con->autoconnect());
    ui->optIgnoreAR->setChecked(con->aspectRatioMode() == Qt::IgnoreAspectRatio);

    QRect screen = con->screenRect();
    if(screen.isEmpty())
        con->setScreenRect(screen = QRect(0,0,1024,768));
    ui->outputX->setValue(screen.x());
    ui->outputY->setValue(screen.y());
    ui->outputWidth->setValue(screen.width());
    ui->outputHeight->setValue(screen.height());

    QRect view = con->viewportRect();
    if(view.isEmpty())
        con->setViewportRect(view = QRect(0,0,1000,750));
    ui->viewportX->setValue(view.x());
    ui->viewportY->setValue(view.y());
    ui->viewportWidth->setValue(view.width());
    ui->viewportHeight->setValue(view.height());

    connect(ui->playerName, SIGNAL(textChanged(QString)), con, SLOT(setName(QString)));
    connect(ui->playerHost, SIGNAL(textChanged(QString)), con, SLOT(setHost(QString)));
    connect(ui->playerUser, SIGNAL(textChanged(QString)), con, SLOT(setUser(QString)));
    connect(ui->playerPass, SIGNAL(textChanged(QString)), con, SLOT(setPass(QString)));

    connect(con, SIGNAL(connected()), this, SLOT(conConnected()));
    connect(con, SIGNAL(disconnected()), this, SLOT(conDisconnected()));
    connect(con, SIGNAL(loginSuccess()), this, SLOT(conLoginSuccess()));
    connect(con, SIGNAL(loginFailure()), this, SLOT(conLoginFailure()));
    connect(con, SIGNAL(playerError(QString)), this, SLOT(conPlayerError(QString)));
    connect(con, SIGNAL(pingResponseReceived(QString)), this, SLOT(conPingResponseReceived(QString)));
    connect(con, SIGNAL(testStarted()), this, SLOT(conTestStarted()));
    connect(con, SIGNAL(testEnded()), this, SLOT(conTestEnded()));
    connect(con, SIGNAL(testResults(bool)), this, SLOT(conTestResults(bool)));

    ui->boxConnection->setEnabled(true);
    ui->boxOutput->setEnabled(true);

    m_subviewModel = new PlayerSubviewsModel(con);

    ui->subviewListview->setModel(m_subviewModel);
    ui->subviewListview->setCurrentIndex(m_subviewModel->index(0,0));

    GLWidgetSubview *sub = !con->subviews().isEmpty() ? con->subviews().at(0) : 0;
    if(!sub)
        con->addSubview(sub = new GLWidgetSubview());
    if(sub->title().isEmpty())
        sub->setTitle("Default Subview");

    setCurrentSubview(sub);
}