Пример #1
0
    void LoginPage::getSmsResult(int64_t _seq, int result, int _code_length)
    {
        if (_seq != send_seq_)
            return;

        country_code_->setEnabled(true);
        phone_->setEnabled(true);
        setErrorText(result);
        error_label_->setVisible(result);
        if (result == core::le_success)
        {
            if (_code_length != 0)
                code_length_ = _code_length;
            clearErrors();
            return initLoginSubPage(SUBPAGE_PHONE_CONF_INDEX);
        }

        phone_widget_->setProperty("EnterPhoneWidgetError", true);
        phone_widget_->setProperty("EnterPhoneWidgetFocused", false);
        phone_widget_->setProperty("EnterPhoneWidget", false);
        phone_widget_->setStyle(QApplication::style());
        phone_->setProperty("PhoneNumberError", true);
        phone_->setStyle(QApplication::style());
        emit country(country_code_->text());
    }
Пример #2
0
    void LoginPage::init()
    {
        QMap<QString, QString> countryCodes = Utils::GetCountryCodes();
        combobox_->setEditBoxClass("CountrySearchEdit");
        combobox_->setComboboxViewClass("CountrySearchView");
        combobox_->setClass("CountySearchWidgetInternal");
        combobox_->setPlaceholder(QT_TRANSLATE_NOOP("login_page","Type country or code"));
        country_search_widget_->layout()->addWidget(combobox_);
        combobox_->setSources(countryCodes);

        connect(combobox_, SIGNAL(selected(QString)), this, SLOT(countrySelected(QString)), Qt::QueuedConnection);
        connect(this, SIGNAL(country(QString)), this, SLOT(redrawCountryCode()), Qt::QueuedConnection);
        connect(next_page_link_, SIGNAL(clicked()), this, SLOT(nextPage()), Qt::QueuedConnection);
        connect(prev_page_link_, SIGNAL(clicked()), this, SLOT(prevPage()), Qt::QueuedConnection);
        connect(edit_phone_button_, SIGNAL(clicked()), this, SLOT(prevPage()), Qt::QueuedConnection);
        connect(edit_phone_button_, SIGNAL(clicked()), this, SLOT(stats_edit_phone()), Qt::QueuedConnection);
        connect(switch_login_link_, SIGNAL(clicked()), this, SLOT(switchLoginType()), Qt::QueuedConnection);
        connect(resend_button_, SIGNAL(clicked()), this, SLOT(sendCode()), Qt::QueuedConnection);
        connect(resend_button_, SIGNAL(clicked()), this, SLOT(stats_resend_sms()), Qt::QueuedConnection);
        connect(timer_, SIGNAL(timeout()), this, SLOT(updateTimer()), Qt::QueuedConnection);

        connect(proxy_settings_link_, SIGNAL(clicked()), this, SLOT(openProxySettings()), Qt::QueuedConnection);

        country_code_->setProperty("CountryCodeEdit", true);
        phone_->setProperty("PhoneNumberEdit", true);
        phone_->setAttribute(Qt::WA_MacShowFocusRect, false);
        phone_->setPlaceholderText(QT_TRANSLATE_NOOP("login_page","your phone number"));
        phone_widget_->layout()->addWidget(country_code_);
        phone_widget_->layout()->addWidget(phone_);
        Testing::setAccessibleName(phone_, "StartWindowPhoneNumberField");

        connect(country_code_, SIGNAL(focusIn()), this, SLOT(setPhoneFocusIn()), Qt::QueuedConnection);
        connect(country_code_, SIGNAL(focusOut()), this, SLOT(setPhoneFocusOut()), Qt::QueuedConnection);
        connect(phone_, SIGNAL(focusIn()), this, SLOT(setPhoneFocusIn()), Qt::QueuedConnection);
        connect(phone_, SIGNAL(focusOut()), this, SLOT(setPhoneFocusOut()), Qt::QueuedConnection);

        connect(uin_login_edit_, SIGNAL(textChanged(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(uin_password_edit_, SIGNAL(textEdited(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(code_edit_, SIGNAL(textChanged(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(code_edit_, SIGNAL(textChanged(QString)), this, SLOT(codeEditChanged(QString)), Qt::QueuedConnection);
        connect(country_code_, SIGNAL(textChanged(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(country_code_, SIGNAL(textEdited(QString)), this, SLOT(countryCodeChanged(QString)), Qt::QueuedConnection);
        connect(phone_, SIGNAL(textChanged(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(phone_, SIGNAL(emptyTextBackspace()), this, SLOT(emptyPhoneRemove()), Qt::QueuedConnection);

        QObject::connect(Ui::GetDispatcher(), SIGNAL(getSmsResult(int64_t, int, int)), this, SLOT(getSmsResult(int64_t, int, int)), Qt::DirectConnection);
        QObject::connect(Ui::GetDispatcher(), SIGNAL(loginResult(int64_t, int)), this, SLOT(loginResult(int64_t, int)), Qt::DirectConnection);
        QObject::connect(Ui::GetDispatcher(), SIGNAL(loginResultAttachUin(int64_t, int)), this, SLOT(loginResultAttachUin(int64_t, int)), Qt::DirectConnection);
        QObject::connect(Ui::GetDispatcher(), SIGNAL(loginResultAttachPhone(int64_t, int)), this, SLOT(loginResultAttachPhone(int64_t, int)), Qt::DirectConnection);

        country_code_->setValidator(new QRegExpValidator(QRegExp("[\\+\\d]\\d*")));
        phone_->setValidator(new QRegExpValidator(QRegExp("\\d*")));
        code_edit_->setValidator(new QRegExpValidator(QRegExp("\\d*")));

        combobox_->selectItem(Utils::GetTranslator()->getCurrentPhoneCode());
        error_label_->hide();
        phone_->setFocus();
        country_code_->setFocusPolicy(Qt::ClickFocus);
        initLoginSubPage(SUBPAGE_PHONE_LOGIN_INDEX);
    }
Пример #3
0
 void LoginPage::switchLoginType()
 {
     setFocus();
     clearErrors();
     initLoginSubPage(login_staked_widget_->currentIndex() == SUBPAGE_UIN_LOGIN_INDEX ? SUBPAGE_PHONE_LOGIN_INDEX : SUBPAGE_UIN_LOGIN_INDEX);
     GetDispatcher()->post_stats_to_core(login_staked_widget_->currentIndex() == SUBPAGE_UIN_LOGIN_INDEX 
         ? core::stats::stats_event_names::reg_page_uin : core::stats::stats_event_names::reg_page_phone);
 }
Пример #4
0
	void LoginPage::getSmsResult(int result)
	{
		country_code_->setEnabled(true);
		phone_->setEnabled(true);
		setErrorText(result);
		error_label_->setVisible(result);
		if (result == core::le_success)
		{
			clearErrors();
			return initLoginSubPage(SUBPAGE_PHONE_CONF_INDEX);
		}

		phone_widget_->setProperty("EnterPhoneWidgetError", true);
		phone_widget_->setProperty("EnterPhoneWidgetFocused", false);
		phone_widget_->setProperty("EnterPhoneWidget", false);
		phone_widget_->setStyle(QApplication::style());
		emit country(country_code_->text());
	}
Пример #5
0
    void LoginPage::loginResult(int64_t _seq, int result)
    {
        if (_seq != send_seq_)
            return;

        updateErrors(result);
        if (result == 0)
        {
            if (login_staked_widget_->currentIndex() == SUBPAGE_PHONE_CONF_INDEX)
            {
                code_edit_->setText("");
                initLoginSubPage(SUBPAGE_PHONE_LOGIN_INDEX);
            }

            GetDispatcher()->post_stats_to_core(login_staked_widget_->currentIndex() == SUBPAGE_UIN_LOGIN_INDEX 
                ? core::stats::stats_event_names::reg_login_uin
                : core::stats::stats_event_names::reg_login_phone);

            clearErrors();
            emit loggedIn();
        }
    }
Пример #6
0
	void LoginPage::loginResult(int result)
	{
		code_edit_->setEnabled(true);
		uin_login_edit_->setEnabled(true);
		uin_password_edit_->setEnabled(true);
		setErrorText(result);
		error_label_->setVisible(result);

		if (login_staked_widget_->currentIndex() == SUBPAGE_UIN_LOGIN_INDEX)
		{
			uin_login_edit_->setProperty("UinError", true);
			uin_login_edit_->setProperty("Uin", false);
			uin_login_edit_->setStyle(QApplication::style());
			uin_password_edit_->clear();
		}
		else
		{
			code_edit_->setProperty("EnteredCodeError", true);
			code_edit_->setProperty("EnteredCode", false);
			code_edit_->setStyle(QApplication::style());
		}

		if (result == 0)
        {
            if (login_staked_widget_->currentIndex() == SUBPAGE_PHONE_CONF_INDEX)
            {
                code_edit_->setText("");
                initLoginSubPage(SUBPAGE_PHONE_LOGIN_INDEX);
            }
                        
            GetDispatcher()->post_stats_to_core(login_staked_widget_->currentIndex() == SUBPAGE_UIN_LOGIN_INDEX 
                ? core::stats::stats_event_names::reg_login_uin
                : core::stats::stats_event_names::reg_login_phone);

            clearErrors();
			emit loggedIn();
        }
	}
Пример #7
0
 void LoginPage::prevPage()
 {
     clearErrors();
     initLoginSubPage(SUBPAGE_PHONE_LOGIN_INDEX);
 }