예제 #1
0
void WSChat::initiateLoginDlg()
{
    login = new LoginDlg(this);

    QObject::connect(login,SIGNAL(sendUserName(QString)),this, SLOT(sendUserName(QString)));
    QObject::connect(login,SIGNAL(requestReconnect()),this, SLOT(reconnectSocket()));
    QObject::connect(this,SIGNAL(setDlgSocketState(QString)),login, SLOT(setDlgSocketState(QString)));

    //can not close the process when close the login dialog
    setDlgSocketState(currentSocketState(websocket->state()));

    login->show();

}
예제 #2
0
void WSChat::checkSocketState()
{
    socketState = currentSocketState(websocket->state());
    ui->infoLabel->setText(socketState);
    //login->msgWarning("hhh");
    if(!loginSuccess)
        setDlgSocketState(socketState);
    else
    {
        if (socketState == tr("Connected"))
        {
            if(flag != 1)
            {
                flag = 1;
                sendUserName(login->getUserName());
            }
        }
        else /* if(websocket->state() == QAbstractSocket::UnconnectedState)*/
        {
            if(flag == 1)
            {
                flag = 0;
                QMessageBox::warning(this,tr(""),tr("socket is unconnected, please wait until it is connected"),
                                     QMessageBox::Yes);
            }
            reconnectSocket();
        }
    }
}
예제 #3
0
UserNameDialog::UserNameDialog(QWidget *parent)
    : QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint), ui_(new Ui::UserNameDialog)
{
    ui_->setupUi(this);
    ui_->buttonBox_->button(QDialogButtonBox::Ok)->setEnabled(false);

    connect(ui_->lineEdit_, SIGNAL(textChanged(QString)),
            this, SLOT(textChanged(QString)));
    connect(ui_->buttonBox_, SIGNAL(accepted()), this, SLOT(sendUserName()));
}