コード例 #1
0
ファイル: passcodebox.cpp プロジェクト: MobinRanjbar/tdesktop
void PasscodeBox::onSubmit() {
	bool has = _cloudPwd ? (!_curSalt.isEmpty()) : cHasPasscode();
	if (_oldPasscode.hasFocus()) {
		if (_turningOff) {
			onSave();
		} else {
			_newPasscode.setFocus();
		}
	} else if (_newPasscode.hasFocus()) {
		_reenterPasscode.setFocus();
	} else if (_reenterPasscode.hasFocus()) {
		if (has && _oldPasscode.text().isEmpty()) {
			_oldPasscode.setFocus();
			_oldPasscode.showError();
		} else if (_newPasscode.text().isEmpty()) {
			_newPasscode.setFocus();
			_newPasscode.showError();
		} else if (_reenterPasscode.text().isEmpty()) {
			_reenterPasscode.showError();
		} else if (!_passwordHint.isHidden()) {
			_passwordHint.setFocus();
		} else {
			onSave();
		}
	} else if (_passwordHint.hasFocus()) {
		if (_recoverEmail.isHidden()) {
			onSave();
		} else {
			_recoverEmail.setFocus();
		}
	} else if (_recoverEmail.hasFocus()) {
		onSave();
	}
}
コード例 #2
0
ファイル: window.cpp プロジェクト: AarashFarahani/tdesktop
void Window::checkAutoLock() {
	if (!cHasPasscode() || App::passcoded()) return;

	App::app()->checkLocalTime();
	uint64 ms = getms(true), idle = psIdleTime(), should = cAutoLock() * 1000ULL;
	if (idle >= should || (_shouldLockAt > 0 && ms > _shouldLockAt + 3000ULL)) {
		setupPasscode(true);
	} else {
		_shouldLockAt = ms + (should - idle);
		_autoLockTimer.start(should - idle);
	}
}
コード例 #3
0
ファイル: shortcuts.cpp プロジェクト: AlexR1712/tdesktop
bool lock_telegram() {
	if (auto w = App::wnd()) {
		if (App::passcoded()) {
			w->passcodeWidget()->onSubmit();
			return true;
		} else if (cHasPasscode()) {
			w->setupPasscode(true);
			return true;
		}
	}
	return false;
}
コード例 #4
0
ファイル: title.cpp プロジェクト: NXij/tdesktop-dark
TitleWidget::TitleWidget(MainWindow *window) : TWidget(window)
, wnd(window)
, hideLevel(0)
, hider(0)
, _back(this, st::titleBackButton, lang(lng_menu_back))
, _cancel(this, lang(lng_cancel), st::titleTextButton)
, _settings(this, lang(lng_menu_settings), st::titleTextButton)
, _contacts(this, lang(lng_menu_contacts), st::titleTextButton)
, _about(this, lang(lng_menu_about), st::titleTextButton)
, _lock(this, window)
, _update(this, window, lang(lng_menu_update))
, _minimize(this, window)
, _maximize(this, window)
, _restore(this, window)
, _close(this, window)
, _a_update(animation(this, &TitleWidget::step_update))
, lastMaximized(!(window->windowState() & Qt::WindowMaximized))
{
	setGeometry(0, 0, wnd->width(), st::titleHeight);
	setAttribute(Qt::WA_OpaquePaintEvent);
	_lock.hide();
	_update.hide();
    _cancel.hide();
    _back.hide();
	if (
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
		Sandbox::updatingState() == Application::UpdatingReady ||
#endif
		cHasPasscode()
	) {
		showUpdateBtn();
	}
	stateChanged();

	connect(&_back, SIGNAL(clicked()), window, SLOT(hideSettings()));
	connect(&_cancel, SIGNAL(clicked()), this, SIGNAL(hiderClicked()));
	connect(&_settings, SIGNAL(clicked()), window, SLOT(showSettings()));
	connect(&_contacts, SIGNAL(clicked()), this, SLOT(onContacts()));
	connect(&_about, SIGNAL(clicked()), this, SLOT(onAbout()));
	connect(wnd->windowHandle(), SIGNAL(windowStateChanged(Qt::WindowState)), this, SLOT(stateChanged(Qt::WindowState)));

#ifndef TDESKTOP_DISABLE_AUTOUPDATE
	Sandbox::connect(SIGNAL(updateReady()), this, SLOT(showUpdateBtn()));
#endif

    if (cPlatform() != dbipWindows) {
        _minimize.hide();
        _maximize.hide();
        _restore.hide();
        _close.hide();
    }
}
コード例 #5
0
ファイル: title.cpp プロジェクト: NXij/tdesktop-dark
void TitleWidget::showUpdateBtn() {
	if (Adaptive::OneColumn() && App::main() && App::main()->selectingPeer()) {
		_cancel.show();
		_lock.hide();
		_update.hide();
		_minimize.hide();
		_restore.hide();
		_maximize.hide();
		_close.hide();
		return;
	}
	if (cHasPasscode()) {
		_lock.show();
	}
	else {
		_lock.hide();
	}
}
コード例 #6
0
ファイル: title.cpp プロジェクト: NotronXteam/tdesktop-plus
void TitleWidget::showUpdateBtn() {
	if (Adaptive::OneColumn() && App::main() && App::main()->selectingPeer()) {
		_cancel.show();
		_lock.hide();
		_update.hide();
		_minimize.hide();
		_restore.hide();
		_maximize.hide();
		_close.hide();
		return;
	}
	if (cHasPasscode()) {
		_lock.show();
	} else {
		_lock.hide();
	}
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
	bool updateReady = (Sandbox::updatingState() == Application::UpdatingReady);
#else
	bool updateReady = false;
#endif
	if (updateReady || cEvalScale(cConfigScale()) != cEvalScale(cRealScale())) {
		_update.setText(lang(updateReady ? lng_menu_update : lng_menu_restart));
		_update.show();
		resizeEvent(0);
		_minimize.hide();
		_restore.hide();
		_maximize.hide();
		_close.hide();
		_a_update.start();
	} else {
		_update.hide();
		if (cPlatform() == dbipWindows) {
			_minimize.show();
			maximizedChanged(lastMaximized, true);
			_close.show();
		}
		_a_update.stop();
	}
	resizeEvent(0);
	update();
}
コード例 #7
0
ファイル: passcodebox.cpp プロジェクト: MobinRanjbar/tdesktop
PasscodeBox::PasscodeBox(bool turningOff) : AbstractBox(st::boxWidth)
, _replacedBy(0)
, _turningOff(turningOff)
, _cloudPwd(false)
, _setRequest(0)
, _hasRecovery(false)
, _skipEmailWarning(false)
, _aboutHeight(0)
, _about(st::boxWidth - st::boxPadding.left() * 1.5)
, _saveButton(this, lang(_turningOff ? lng_passcode_remove_button : lng_settings_save), st::defaultBoxButton)
, _cancelButton(this, lang(lng_cancel), st::cancelBoxButton)
, _oldPasscode(this, st::defaultInputField, lang(lng_passcode_enter_old))
, _newPasscode(this, st::defaultInputField, lang(cHasPasscode() ? lng_passcode_enter_new : lng_passcode_enter_first))
, _reenterPasscode(this, st::defaultInputField, lang(lng_passcode_confirm_new))
, _passwordHint(this, st::defaultInputField, lang(lng_cloud_password_hint))
, _recoverEmail(this, st::defaultInputField, lang(lng_cloud_password_email))
, _recover(this, lang(lng_signin_recover)) {
	init();
	prepare();
}
コード例 #8
0
ファイル: passcodebox.cpp プロジェクト: MobinRanjbar/tdesktop
void PasscodeBox::init() {
	setBlueTitle(true);

	textstyleSet(&st::usernameTextStyle);
	_about.setRichText(st::normalFont, lang(_cloudPwd ? lng_cloud_password_about : lng_passcode_about));
	_aboutHeight = _about.countHeight(st::boxWidth - st::boxPadding.left() * 1.5);
	textstyleRestore();
	if (_turningOff) {
		_oldPasscode.show();
		_boxTitle = lang(_cloudPwd ? lng_cloud_password_remove : lng_passcode_remove);
		setMaxHeight(st::boxTitleHeight + st::passcodePadding.top() + _oldPasscode.height() + st::passcodeSkip + ((_hasRecovery && !_hintText.isEmpty()) ? st::passcodeSkip : 0) + _aboutHeight + st::passcodePadding.bottom() + st::boxButtonPadding.top() + _saveButton.height() + st::boxButtonPadding.bottom());
	} else {
		bool has = _cloudPwd ? (!_curSalt.isEmpty()) : cHasPasscode();
		if (has) {
			_oldPasscode.show();
			_boxTitle = lang(_cloudPwd ? lng_cloud_password_change : lng_passcode_change);
			setMaxHeight(st::boxTitleHeight + st::passcodePadding.top() + _oldPasscode.height() + st::passcodeSkip + ((_hasRecovery && !_hintText.isEmpty()) ? st::passcodeSkip : 0) + _newPasscode.height() + st::contactSkip + _reenterPasscode.height() + st::passcodeSkip + (_cloudPwd ? _passwordHint.height() + st::contactSkip : 0) + _aboutHeight + st::passcodePadding.bottom() + st::boxButtonPadding.top() + _saveButton.height() + st::boxButtonPadding.bottom());
		} else {
			_oldPasscode.hide();
			_boxTitle = lang(_cloudPwd ? lng_cloud_password_create : lng_passcode_create);
			setMaxHeight(st::boxTitleHeight + st::passcodePadding.top() + _newPasscode.height() + st::contactSkip + _reenterPasscode.height() + st::passcodeSkip + (_cloudPwd ? _passwordHint.height() + st::contactSkip : 0) + _aboutHeight + (_cloudPwd ? st::contactSkip + _recoverEmail.height() + st::passcodeSkip : st::passcodePadding.bottom()) + st::boxButtonPadding.top() + _saveButton.height() + st::boxButtonPadding.bottom());
		}
	}

	connect(&_saveButton, SIGNAL(clicked()), this, SLOT(onSave()));
	connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onClose()));

	connect(&_oldPasscode, SIGNAL(changed()), this, SLOT(onOldChanged()));
	connect(&_newPasscode, SIGNAL(changed()), this, SLOT(onNewChanged()));
	connect(&_reenterPasscode, SIGNAL(changed()), this, SLOT(onNewChanged()));
	connect(&_passwordHint, SIGNAL(changed()), this, SLOT(onNewChanged()));
	connect(&_recoverEmail, SIGNAL(changed()), this, SLOT(onEmailChanged()));

	connect(&_oldPasscode, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
	connect(&_newPasscode, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
	connect(&_reenterPasscode, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
	connect(&_passwordHint, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
	connect(&_recoverEmail, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));

	connect(&_recover, SIGNAL(clicked()), this, SLOT(onRecoverByEmail()));
}
コード例 #9
0
ファイル: passcodebox.cpp プロジェクト: MobinRanjbar/tdesktop
void PasscodeBox::showAll() {
	bool has = _cloudPwd ? (!_curSalt.isEmpty()) : cHasPasscode();
	if (_turningOff) {
		_oldPasscode.show();
		if (_cloudPwd && _hasRecovery) {
			_recover.show();
		} else {
			_recover.hide();
		}
		_passwordHint.hide();
		_newPasscode.hide();
		_reenterPasscode.hide();
	} else {
		if (has) {
			_oldPasscode.show();
			if (_cloudPwd && _hasRecovery) {
				_recover.show();
			} else {
				_recover.hide();
			}
		} else {
			_oldPasscode.hide();
			_recover.hide();
		}
		_newPasscode.show();
		_reenterPasscode.show();
		if (_cloudPwd) {
			_passwordHint.show();
		} else {
			_passwordHint.hide();
		}
		if (_cloudPwd && _curSalt.isEmpty()) {
			_recoverEmail.show();
		} else {
			_recoverEmail.hide();
		}
	}
	_saveButton.show();
	_cancelButton.show();
	AbstractBox::showAll();
}
コード例 #10
0
ファイル: title.cpp プロジェクト: neuroidss/tdesktop
void TitleWidget::showUpdateBtn() {
	if (!cWideMode() && App::main() && App::main()->selectingPeer()) {
		_cancel.show();
		_lock.hide();
		_update.hide();
		_minimize.hide();
		_restore.hide();
		_maximize.hide();
		_close.hide();
		return;
	}
	if (cHasPasscode()) {
		_lock.show();
	} else {
		_lock.hide();
	}
	bool updateReady = App::app()->updatingState() == Application::UpdatingReady;
	if (updateReady || cEvalScale(cConfigScale()) != cEvalScale(cRealScale())) {
		_update.setText(lang(updateReady ? lng_menu_update : lng_menu_restart));
		_update.show();
		resizeEvent(0);
		_minimize.hide();
		_restore.hide();
		_maximize.hide();
		_close.hide();
		anim::start(this);
	} else {
		_update.hide();
		if (cPlatform() == dbipWindows) {
			_minimize.show();
			maximizedChanged(lastMaximized, true);
			_close.show();
		}
		anim::stop(this);
	}
	resizeEvent(0);
	update();
}
コード例 #11
0
ファイル: passcodebox.cpp プロジェクト: MobinRanjbar/tdesktop
void PasscodeBox::resizeEvent(QResizeEvent *e) {
	bool has = _cloudPwd ? (!_curSalt.isEmpty()) : cHasPasscode();
	int32 w = st::boxWidth - st::boxPadding.left() - st::boxPadding.right();
	_oldPasscode.resize(w, _oldPasscode.height());
	_oldPasscode.moveToLeft(st::boxPadding.left(), st::boxTitleHeight + st::passcodePadding.top());
	_newPasscode.resize(w, _newPasscode.height());
	_newPasscode.moveToLeft(st::boxPadding.left(), _oldPasscode.y() + ((_turningOff || has) ? (_oldPasscode.height() + st::passcodeSkip + ((_hasRecovery && !_hintText.isEmpty()) ? st::passcodeSkip : 0)) : 0));
	_reenterPasscode.resize(w, _reenterPasscode.height());
	_reenterPasscode.moveToLeft(st::boxPadding.left(), _newPasscode.y() + _newPasscode.height() + st::contactSkip);
	_passwordHint.resize(w, _passwordHint.height());
	_passwordHint.moveToLeft(st::boxPadding.left(), _reenterPasscode.y() + _reenterPasscode.height() + st::passcodeSkip);
	_recoverEmail.resize(w, _passwordHint.height());
	_recoverEmail.moveToLeft(st::boxPadding.left(), _passwordHint.y() + _passwordHint.height() + st::contactSkip + _aboutHeight + st::contactSkip);

	if (!_recover.isHidden()) {
		_recover.moveToLeft(st::boxPadding.left(), _oldPasscode.y() + _oldPasscode.height() + (_hintText.isEmpty() ? ((st::passcodeSkip - _recover.height()) / 2) : st::passcodeSkip));
	}

	_saveButton.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _saveButton.height());
	_cancelButton.moveToRight(st::boxButtonPadding.right() + _saveButton.width() + st::boxButtonPadding.left(), _saveButton.y());

	AbstractBox::resizeEvent(e);
}
コード例 #12
0
ファイル: passcodebox.cpp プロジェクト: MobinRanjbar/tdesktop
void PasscodeBox::onSave(bool force) {
	if (_setRequest) return;

	QString old = _oldPasscode.text(), pwd = _newPasscode.text(), conf = _reenterPasscode.text();
	bool has = _cloudPwd ? (!_curSalt.isEmpty()) : cHasPasscode();
	if (!_cloudPwd && (_turningOff || has)) {
		if (!passcodeCanTry()) {
			_oldError = lang(lng_flood_error);
			_oldPasscode.setFocus();
			_oldPasscode.showError();
			update();
			return;
		}

		if (Local::checkPasscode(old.toUtf8())) {
			cSetPasscodeBadTries(0);
			if (_turningOff) pwd = conf = QString();
		} else {
			cSetPasscodeBadTries(cPasscodeBadTries() + 1);
			cSetPasscodeLastTry(getms(true));
			onBadOldPasscode();
			return;
		}
	}
	if (!_turningOff && pwd.isEmpty()) {
		_newPasscode.setFocus();
		_newPasscode.showError();
		if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
		return;
	}
	if (pwd != conf) {
		_reenterPasscode.selectAll();
		_reenterPasscode.setFocus();
		_reenterPasscode.showError();
		if (!conf.isEmpty()) {
			_newError = lang(_cloudPwd ? lng_cloud_password_differ : lng_passcode_differ);
			update();
		}
		if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
	} else if (!_turningOff && has && old == pwd) {
		_newPasscode.setFocus();
		_newPasscode.showError();
		_newError = lang(_cloudPwd ? lng_cloud_password_is_same : lng_passcode_is_same);
		update();
		if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
	} else if (_cloudPwd) {
		QString hint = _passwordHint.getLastText(), email = _recoverEmail.getLastText().trimmed();
		if (_cloudPwd && pwd == hint && !_passwordHint.isHidden() && !_newPasscode.isHidden()) {
			_newPasscode.setFocus();
			_newPasscode.showError();
			_newError = lang(lng_cloud_password_bad);
			update();
			if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
			return;
		}
		if (!_recoverEmail.isHidden() && email.isEmpty() && !force) {
			_skipEmailWarning = true;
			_replacedBy = new ConfirmBox(lang(lng_cloud_password_about_recover), lang(lng_cloud_password_skip_email), st::attentionBoxButton);
			connect(_replacedBy, SIGNAL(confirmed()), this, SLOT(onForceNoMail()));
			connect(_replacedBy, SIGNAL(destroyed(QObject*)), this, SLOT(onBoxDestroyed(QObject*)));
			Ui::showLayer(_replacedBy, KeepOtherLayers);
		} else {