LoginDialog::LoginDialog() : LoginDlgBase(NULL, "logindlg", false, WDestructiveClose) { SET_WNDPROC("login") setCaption(caption()); setButtonsPict(this); setIcon(Pict("licq")); bLogin = false; bMyInit = false; cmbUIN->setEditable(true); cmbUIN->lineEdit()->setValidator(new QIntValidator(100000, 0x7FFFFFFF, this)); loadUins(); edtPasswd->setEchoMode(QLineEdit::Password); connect(cmbUIN->lineEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(uinChanged(const QString&))); connect(edtPasswd, SIGNAL(textChanged(const QString&)), this, SLOT(pswdChanged(const QString&))); connect(btnClose, SIGNAL(clicked()), this, SLOT(close())); connect(btnLogin, SIGNAL(clicked()), this, SLOT(login())); connect(btnDelete, SIGNAL(clicked()), this, SLOT(deleteUin())); connect(btnProxy, SIGNAL(clicked()), this, SLOT(proxySetup())); connect(chkSave, SIGNAL(toggled(bool)), this, SLOT(saveChanged(bool))); QSize s = sizeHint(); QWidget *desktop = QApplication::desktop(); move((desktop->width() - s.width()) / 2, (desktop->height() - s.height()) / 2); chkSave->setChecked(pSplash->isSavePassword()); chkNoShow->setChecked(pSplash->isNoShowLogin()); uinChanged(""); bPswdChanged = true; if (pSplash->isSavePassword()){ unsigned long uin = cmbUIN->lineEdit()->text().toULong(); if (uin){ pClient->load(uin); QString pswd; for (const char *p = pClient->EncryptedPassword.c_str(); *p; p++){ if (*p == '\\') continue; pswd += '*'; } edtPasswd->setText(pswd); pswdChanged(""); if (!pswd.isEmpty()) bPswdChanged = false; } } bCloseMain = true; };
void LoginDialog::profileChanged(int) { if (m_client) return; int n = cmbProfile->currentItem(); if (n < 0){ clearInputs(); buttonOk->setEnabled(false); btnDelete->setEnabled(false); return; } buttonOk->setEnabled(true); if (n >= (int)cmbProfile->count() - 1){ lblPasswd->hide(); clearInputs(); btnDelete->setEnabled(false); }else{ clearInputs(); CorePlugin::m_plugin->setProfile(CorePlugin::m_plugin->m_profiles[n].c_str()); ClientList clients; CorePlugin::m_plugin->loadClients(clients); unsigned nClients = 0; unsigned i; for (i = 0; i < clients.size(); i++){ if (clients[i]->protocol()->description()->flags & PROTOCOL_NO_AUTH) continue; nClients++; } if (nClients > 1){ lblPasswd->show(); }else{ lblPasswd->hide(); } unsigned row = 2; if (nClients == 1){ makeInputs(row, clients[0], true); }else{ for (unsigned i = 0; i < clients.size(); i++){ if (clients[i]->protocol()->description()->flags & PROTOCOL_NO_AUTH) continue; makeInputs(row, clients[i], false); } } if (passwords.size()) passwords[0]->setFocus(); btnDelete->setEnabled(m_loginProfile == CorePlugin::m_plugin->m_profiles[n].c_str()); buttonOk->setEnabled(false); pswdChanged(""); } QTimer::singleShot(0, this, SLOT(adjust())); }
void LoginDialog::profileChanged(int) { if (m_client) return; int n = cmbProfile->currentItem(); if (n < 0){ clearInputs(); buttonOk->setEnabled(false); btnDelete->setEnabled(false); return; } buttonOk->setEnabled(true); if (n >= (int)cmbProfile->count() - 1){ lblPasswd->hide(); clearInputs(); btnDelete->setEnabled(false); }else{ clearInputs(); CorePlugin::m_plugin->setProfile(CorePlugin::m_plugin->m_profiles[n].c_str()); ClientList clients; CorePlugin::m_plugin->loadClients(clients); if (clients.size() > 1){ lblPasswd->show(); }else{ lblPasswd->hide(); } unsigned row = 2; if (clients.size() == 1){ makeInputs(row, clients[0], true); }else{ for (unsigned i = 0; i < clients.size(); i++) makeInputs(row, clients[i], false); } if (passwords.size()) passwords[0]->setFocus(); btnDelete->setEnabled(m_loginProfile == CorePlugin::m_plugin->m_profiles[n].c_str()); buttonOk->setEnabled(false); pswdChanged(""); } }
void LoginDialog::uinChanged(const QString&) { edtPasswd->setText(""); pswdChanged(""); }