mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-30 22:16:14 +00:00
links preview done
This commit is contained in:
@@ -62,7 +62,7 @@ bool AbstractBox::paint(QPainter &p) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void AbstractBox::paintTitle(QPainter &p, const QString &title, bool withShadow) {
|
||||
void AbstractBox::paintTitle(Painter &p, const QString &title, bool withShadow) {
|
||||
if (withShadow) {
|
||||
// paint shadow
|
||||
p.fillRect(0, st::boxTitleHeight, width(), st::scrollDef.topsh, st::scrollDef.shColor->b);
|
||||
@@ -71,7 +71,7 @@ void AbstractBox::paintTitle(QPainter &p, const QString &title, bool withShadow)
|
||||
// paint box title
|
||||
p.setFont(st::boxTitleFont->f);
|
||||
p.setPen(st::black->p);
|
||||
p.drawText(st::boxTitlePos.x(), st::boxTitlePos.y() + st::boxTitleFont->ascent, title);
|
||||
p.drawTextLeft(st::boxTitlePos.x(), st::boxTitlePos.y(), width() - 2 * st::boxTitlePos.x(), title);
|
||||
}
|
||||
|
||||
void AbstractBox::paintGrayTitle(QPainter &p, const QString &title) {
|
||||
|
@@ -39,7 +39,7 @@ protected:
|
||||
|
||||
void prepare();
|
||||
bool paint(QPainter &p);
|
||||
void paintTitle(QPainter &p, const QString &title, bool withShadow);
|
||||
void paintTitle(Painter &p, const QString &title, bool withShadow);
|
||||
void paintGrayTitle(QPainter &p, const QString &title);
|
||||
void setMaxHeight(int32 maxHeight);
|
||||
void resizeMaxHeight(int32 newWidth, int32 maxHeight);
|
||||
|
@@ -155,7 +155,7 @@ void AddContactBox::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
|
||||
void AddContactBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
if (_retryButton.isHidden()) {
|
||||
@@ -226,7 +226,8 @@ void AddContactBox::onSaveSelfDone(const MTPUser &user) {
|
||||
}
|
||||
|
||||
bool AddContactBox::onSaveSelfFail(const RPCError &error) {
|
||||
_addRequest = 0;
|
||||
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
|
||||
|
||||
QString err(error.type());
|
||||
QString firstName = textOneLine(_firstInput.text()), lastName = textOneLine(_lastInput.text());
|
||||
if (err == "NAME_NOT_MODIFIED") {
|
||||
@@ -247,6 +248,8 @@ bool AddContactBox::onSaveSelfFail(const RPCError &error) {
|
||||
}
|
||||
|
||||
bool AddContactBox::onSaveFail(const RPCError &error) {
|
||||
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
|
||||
|
||||
_addRequest = 0;
|
||||
QString err(error.type());
|
||||
QString firstName = _firstInput.text().trimmed(), lastName = _lastInput.text().trimmed();
|
||||
|
@@ -65,7 +65,7 @@ void AutoLockBox::showAll() {
|
||||
}
|
||||
|
||||
void AutoLockBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintTitle(p, lang(lng_passcode_autolock), true);
|
||||
|
@@ -29,9 +29,9 @@ TextParseOptions _confirmBoxTextOptions = {
|
||||
Qt::LayoutDirectionAuto, // dir
|
||||
};
|
||||
|
||||
ConfirmBox::ConfirmBox(const QString &text, const QString &doneText, const QString &cancelText) : _infoMsg(false),
|
||||
_confirm(this, doneText.isEmpty() ? lang(lng_continue) : doneText, st::btnSelectDone),
|
||||
_cancel(this, cancelText.isEmpty() ? lang(lng_cancel) : cancelText, st::btnSelectCancel),
|
||||
ConfirmBox::ConfirmBox(const QString &text, const QString &doneText, const QString &cancelText, const style::flatButton &doneStyle, const style::flatButton &cancelStyle) : _infoMsg(false),
|
||||
_confirm(this, doneText.isEmpty() ? lang(lng_continue) : doneText, doneStyle),
|
||||
_cancel(this, cancelText.isEmpty() ? lang(lng_cancel) : cancelText, cancelStyle),
|
||||
_close(this, QString(), st::btnInfoClose),
|
||||
_text(100) {
|
||||
init(text);
|
||||
|
@@ -24,7 +24,7 @@ class ConfirmBox : public AbstractBox, public RPCSender {
|
||||
|
||||
public:
|
||||
|
||||
ConfirmBox(const QString &text, const QString &doneText = QString(), const QString &cancelText = QString());
|
||||
ConfirmBox(const QString &text, const QString &doneText = QString(), const QString &cancelText = QString(), const style::flatButton &doneStyle = st::btnSelectDone, const style::flatButton &cancelStyle = st::btnSelectCancel);
|
||||
ConfirmBox(const QString &text, bool noDone, const QString &cancelText = QString());
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
@@ -94,7 +94,7 @@ void ConnectionBox::showDone() {
|
||||
}
|
||||
|
||||
void ConnectionBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintTitle(p, lang(lng_connection_header), true);
|
||||
|
@@ -942,6 +942,8 @@ void ContactsBox::peopleReceived(const MTPcontacts_Found &result, mtpRequestId r
|
||||
}
|
||||
|
||||
bool ContactsBox::peopleFailed(const RPCError &error, mtpRequestId req) {
|
||||
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
|
||||
|
||||
if (_peopleRequest == req) {
|
||||
_peopleRequest = 0;
|
||||
_peopleFull = true;
|
||||
@@ -1000,7 +1002,7 @@ void ContactsBox::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
|
||||
void ContactsBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
if (_inner.chat() || _inner.creatingChat()) {
|
||||
@@ -1104,7 +1106,7 @@ void CreateGroupBox::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
|
||||
void CreateGroupBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintTitle(p, lang(lng_create_group_title), true);
|
||||
@@ -1161,12 +1163,14 @@ void CreateGroupBox::created(const MTPUpdates &updates) {
|
||||
}
|
||||
}
|
||||
|
||||
bool CreateGroupBox::failed(const RPCError &e) {
|
||||
bool CreateGroupBox::failed(const RPCError &error) {
|
||||
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
|
||||
|
||||
_createRequestId = 0;
|
||||
if (e.type() == "NO_CHAT_TITLE") {
|
||||
if (error.type() == "NO_CHAT_TITLE") {
|
||||
_name.setFocus();
|
||||
return true;
|
||||
} else if (e.type() == "USERS_TOO_FEW") {
|
||||
} else if (error.type() == "USERS_TOO_FEW") {
|
||||
emit closed();
|
||||
return true;
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ void DownloadPathBox::showAll() {
|
||||
}
|
||||
|
||||
void DownloadPathBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintTitle(p, lang(lng_download_path_header), true);
|
||||
|
@@ -94,7 +94,7 @@ void LanguageBox::mousePressEvent(QMouseEvent *e) {
|
||||
}
|
||||
|
||||
void LanguageBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintTitle(p, lang(lng_languages), true);
|
||||
|
@@ -24,7 +24,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
||||
|
||||
#include "localstorage.h"
|
||||
|
||||
PasscodeBox::PasscodeBox(bool turningOff) : _turningOff(turningOff), _cloudPwd(false),
|
||||
PasscodeBox::PasscodeBox(bool turningOff) : _replacedBy(0), _turningOff(turningOff), _cloudPwd(false),
|
||||
_setRequest(0), _hasRecovery(false), _aboutHeight(0),
|
||||
_about(st::boxWidth - st::addContactPadding.left() - st::addContactPadding.right()),
|
||||
_saveButton(this, lang(_turningOff ? lng_passcode_remove_button : lng_settings_save), st::btnSelectDone),
|
||||
@@ -39,7 +39,7 @@ _recover(this, lang(lng_signin_recover)) {
|
||||
prepare();
|
||||
}
|
||||
|
||||
PasscodeBox::PasscodeBox(const QByteArray &newSalt, const QByteArray &curSalt, bool hasRecovery, const QString &hint, bool turningOff) : _turningOff(turningOff), _cloudPwd(true),
|
||||
PasscodeBox::PasscodeBox(const QByteArray &newSalt, const QByteArray &curSalt, bool hasRecovery, const QString &hint, bool turningOff) : _replacedBy(0), _turningOff(turningOff), _cloudPwd(true),
|
||||
_setRequest(0), _newSalt(newSalt), _curSalt(curSalt), _hasRecovery(hasRecovery), _hint(hint), _aboutHeight(0),
|
||||
_about(st::boxWidth - st::addContactPadding.left() - st::addContactPadding.right()),
|
||||
_saveButton(this, lang(_turningOff ? lng_passcode_remove_button : lng_settings_save), st::btnSelectDone),
|
||||
@@ -81,13 +81,12 @@ void PasscodeBox::init() {
|
||||
connect(&_saveButton, SIGNAL(clicked()), this, SLOT(onSave()));
|
||||
connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
|
||||
_badOldTimer.setSingleShot(true);
|
||||
connect(&_badOldTimer, SIGNAL(timeout()), this, SLOT(onBadOldPasscode()));
|
||||
|
||||
connect(&_oldPasscode, SIGNAL(changed()), this, SLOT(onOldChanged()));
|
||||
connect(&_newPasscode, SIGNAL(changed()), this, SLOT(onNewChanged()));
|
||||
connect(&_reenterPasscode, SIGNAL(changed()), this, SLOT(onNewChanged()));
|
||||
connect(&_recoverEmail, SIGNAL(changed()), this, SLOT(onEmailChanged()));
|
||||
|
||||
connect(&_recover, SIGNAL(clicked()), this, SLOT(onRecoverByEmail()));
|
||||
}
|
||||
|
||||
void PasscodeBox::hideAll() {
|
||||
@@ -182,7 +181,7 @@ void PasscodeBox::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
|
||||
void PasscodeBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintTitle(p, _boxTitle, true);
|
||||
@@ -252,11 +251,12 @@ void PasscodeBox::showDone() {
|
||||
void PasscodeBox::setPasswordDone(const MTPBool &result) {
|
||||
_setRequest = 0;
|
||||
emit reloadPassword();
|
||||
ConfirmBox *box = new ConfirmBox(lang(_reenterPasscode.isHidden() ? lng_cloud_password_removed : lng_cloud_password_was_set), true, lang(lng_about_done));
|
||||
ConfirmBox *box = new ConfirmBox(lang(_reenterPasscode.isHidden() ? lng_cloud_password_removed : (_oldPasscode.isHidden() ? lng_cloud_password_was_set : lng_cloud_password_updated)), true, lang(lng_about_done));
|
||||
App::wnd()->showLayer(box, true);
|
||||
}
|
||||
|
||||
bool PasscodeBox::setPasswordFail(const RPCError &error) {
|
||||
if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
|
||||
_setRequest = 0;
|
||||
QString err = error.type();
|
||||
if (err == "PASSWORD_HASH_INVALID") {
|
||||
@@ -283,6 +283,13 @@ bool PasscodeBox::setPasswordFail(const RPCError &error) {
|
||||
ConfirmBox *box = new ConfirmBox(lang(lng_cloud_password_almost), true, lang(lng_about_done));
|
||||
App::wnd()->showLayer(box, true);
|
||||
emit reloadPassword();
|
||||
} else if (error.type().startsWith(qsl("FLOOD_WAIT_"))) {
|
||||
if (_oldPasscode.isHidden()) return false;
|
||||
|
||||
_oldPasscode.selectAll();
|
||||
_oldPasscode.setFocus();
|
||||
_oldPasscode.notaBene();
|
||||
_oldError = lang(lng_flood_error);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -293,22 +300,28 @@ void PasscodeBox::onSave(bool force) {
|
||||
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.notaBene();
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Local::checkPasscode(old.toUtf8())) {
|
||||
cSetPasscodeBadTries(0);
|
||||
if (_turningOff) pwd = conf = QString();
|
||||
} else {
|
||||
_oldPasscode.setDisabled(true);
|
||||
_newPasscode.setDisabled(true);
|
||||
_reenterPasscode.setDisabled(true);
|
||||
_saveButton.setDisabled(true);
|
||||
_oldError = QString();
|
||||
update();
|
||||
_badOldTimer.start(WrongPasscodeTimeout);
|
||||
cSetPasscodeBadTries(cPasscodeBadTries() + 1);
|
||||
cSetPasscodeLastTry(getms(true));
|
||||
onBadOldPasscode();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!_turningOff && pwd.isEmpty()) {
|
||||
_newPasscode.setFocus();
|
||||
_newPasscode.notaBene();
|
||||
if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
|
||||
return;
|
||||
}
|
||||
if (pwd != conf) {
|
||||
@@ -318,18 +331,28 @@ void PasscodeBox::onSave(bool force) {
|
||||
_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.notaBene();
|
||||
_newError = lang(_cloudPwd ? lng_cloud_password_differ : lng_passcode_is_same);
|
||||
_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.text(), email = _recoverEmail.text().trimmed();
|
||||
if (_cloudPwd && pwd == hint && !_passwordHint.isHidden() && !_newPasscode.isHidden()) {
|
||||
_newPasscode.setFocus();
|
||||
_newPasscode.notaBene();
|
||||
_newError = lang(lng_cloud_password_bad);
|
||||
update();
|
||||
if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
|
||||
return;
|
||||
}
|
||||
if (!_recoverEmail.isHidden() && email.isEmpty() && !force) {
|
||||
ConfirmBox *box = new ConfirmBox(lang(lng_cloud_password_about_recover));
|
||||
connect(box, SIGNAL(confirmed()), this, SLOT(onForceNoMail()));
|
||||
connect(box, SIGNAL(confirmed()), box, SLOT(onClose()));
|
||||
App::wnd()->replaceLayer(box);
|
||||
_replacedBy = new ConfirmBox(lang(lng_cloud_password_about_recover));
|
||||
connect(_replacedBy, SIGNAL(confirmed()), this, SLOT(onForceNoMail()));
|
||||
connect(_replacedBy, SIGNAL(destroyed(QObject*)), this, SLOT(onBoxDestroyed(QObject*)));
|
||||
App::wnd()->replaceLayer(_replacedBy);
|
||||
} else {
|
||||
QByteArray newPasswordData = pwd.isEmpty() ? QByteArray() : (_newSalt + pwd.toUtf8() + _newSalt);
|
||||
QByteArray newPasswordHash = pwd.isEmpty() ? QByteArray() : QByteArray(32, Qt::Uninitialized);
|
||||
@@ -352,6 +375,7 @@ void PasscodeBox::onSave(bool force) {
|
||||
_setRequest = MTP::send(MTPaccount_UpdatePasswordSettings(MTP_string(oldPasswordHash), settings), rpcDone(&PasscodeBox::setPasswordDone), rpcFail(&PasscodeBox::setPasswordFail));
|
||||
}
|
||||
} else {
|
||||
cSetPasscodeBadTries(0);
|
||||
Local::setPasscode(pwd.toUtf8());
|
||||
App::wnd()->checkAutoLock();
|
||||
App::wnd()->getTitle()->showUpdateBtn();
|
||||
@@ -360,10 +384,6 @@ void PasscodeBox::onSave(bool force) {
|
||||
}
|
||||
|
||||
void PasscodeBox::onBadOldPasscode() {
|
||||
_oldPasscode.setDisabled(false);
|
||||
_newPasscode.setDisabled(false);
|
||||
_reenterPasscode.setDisabled(false);
|
||||
_saveButton.setDisabled(false);
|
||||
_oldPasscode.selectAll();
|
||||
_oldPasscode.setFocus();
|
||||
_oldPasscode.notaBene();
|
||||
@@ -396,6 +416,12 @@ void PasscodeBox::onForceNoMail() {
|
||||
onSave(true);
|
||||
}
|
||||
|
||||
void PasscodeBox::onBoxDestroyed(QObject *obj) {
|
||||
if (obj == _replacedBy) {
|
||||
_replacedBy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void PasscodeBox::onRecoverByEmail() {
|
||||
if (_pattern.isEmpty()) {
|
||||
_pattern = "-";
|
||||
@@ -412,10 +438,11 @@ void PasscodeBox::onRecoverExpired() {
|
||||
void PasscodeBox::recover() {
|
||||
if (_pattern == "-") return;
|
||||
|
||||
RecoverBox *box = new RecoverBox(_pattern);
|
||||
connect(box, SIGNAL(reloadPassword()), this, SIGNAL(reloadPassword()));
|
||||
connect(box, SIGNAL(recoveryExpired()), this, SLOT(onRecoverExpired()));
|
||||
App::wnd()->replaceLayer(box);
|
||||
_replacedBy = new RecoverBox(_pattern);
|
||||
connect(_replacedBy, SIGNAL(reloadPassword()), this, SIGNAL(reloadPassword()));
|
||||
connect(_replacedBy, SIGNAL(recoveryExpired()), this, SLOT(onRecoverExpired()));
|
||||
connect(_replacedBy, SIGNAL(destroyed(QObject*)), this, SLOT(onBoxDestroyed(QObject*)));
|
||||
App::wnd()->replaceLayer(_replacedBy);
|
||||
}
|
||||
|
||||
void PasscodeBox::recoverStarted(const MTPauth_PasswordRecovery &result) {
|
||||
@@ -424,6 +451,8 @@ void PasscodeBox::recoverStarted(const MTPauth_PasswordRecovery &result) {
|
||||
}
|
||||
|
||||
bool PasscodeBox::recoverStartFail(const RPCError &error) {
|
||||
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
|
||||
|
||||
_pattern = QString();
|
||||
onClose();
|
||||
return true;
|
||||
@@ -470,7 +499,7 @@ void RecoverBox::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
|
||||
void RecoverBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintTitle(p, lang(lng_signin_recover), true);
|
||||
@@ -478,8 +507,9 @@ void RecoverBox::paintEvent(QPaintEvent *e) {
|
||||
// paint shadow
|
||||
p.fillRect(0, height() - st::btnSelectCancel.height - st::scrollDef.bottomsh, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b);
|
||||
|
||||
p.setFont(st::usernameFont->f);
|
||||
int32 w = width() - st::addContactPadding.left() - st::addContactPadding.right();
|
||||
p.drawText(QRect(st::addContactPadding.left(), _recoverCode.y() - st::usernameSkip, w, st::usernameSkip), st::usernameFont->m.elidedText(_pattern, Qt::ElideRight, w), style::al_center);
|
||||
p.drawText(QRect(st::addContactPadding.left(), _recoverCode.y() - st::usernameSkip - st::addContactPadding.top(), w, st::addContactPadding.top() + st::usernameSkip), st::usernameFont->m.elidedText(_pattern, Qt::ElideRight, w), style::al_center);
|
||||
|
||||
if (!_error.isEmpty()) {
|
||||
p.setPen(st::setErrColor->p);
|
||||
@@ -548,8 +578,7 @@ bool RecoverBox::codeSubmitFail(const RPCError &error) {
|
||||
update();
|
||||
_recoverCode.notaBene();
|
||||
return true;
|
||||
}
|
||||
if (QRegularExpression("^FLOOD_WAIT_(\\d+)$").match(err).hasMatch()) {
|
||||
} else if (error.type().startsWith(qsl("FLOOD_WAIT_"))) {
|
||||
_error = lang(lng_flood_error);
|
||||
update();
|
||||
_recoverCode.notaBene();
|
||||
|
@@ -39,6 +39,7 @@ public slots:
|
||||
void onNewChanged();
|
||||
void onEmailChanged();
|
||||
void onForceNoMail();
|
||||
void onBoxDestroyed(QObject *obj);
|
||||
void onRecoverByEmail();
|
||||
void onRecoverExpired();
|
||||
|
||||
@@ -63,6 +64,7 @@ private:
|
||||
void recover();
|
||||
QString _pattern;
|
||||
|
||||
AbstractBox *_replacedBy;
|
||||
bool _turningOff, _cloudPwd;
|
||||
mtpRequestId _setRequest;
|
||||
|
||||
@@ -79,7 +81,6 @@ private:
|
||||
FlatInput _oldPasscode, _newPasscode, _reenterPasscode, _passwordHint, _recoverEmail;
|
||||
LinkButton _recover;
|
||||
|
||||
QTimer _badOldTimer;
|
||||
QString _oldError, _newError, _emailError;
|
||||
};
|
||||
|
||||
|
@@ -210,6 +210,7 @@ void PhotoSendBox::onSend(bool ctrlShiftEnter) {
|
||||
if (App::main()) App::main()->confirmSendImageUncompressed(ctrlShiftEnter, _replyTo);
|
||||
}
|
||||
}
|
||||
emit confirmed();
|
||||
emit closed();
|
||||
}
|
||||
|
||||
|
@@ -32,6 +32,10 @@ public:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
~PhotoSendBox();
|
||||
|
||||
signals:
|
||||
|
||||
void confirmed();
|
||||
|
||||
public slots:
|
||||
|
||||
void onSend(bool ctrlShiftEnter = false);
|
||||
|
@@ -106,6 +106,8 @@ void SessionsInner::terminateDone(uint64 hash, const MTPBool &result) {
|
||||
}
|
||||
|
||||
bool SessionsInner::terminateFail(uint64 hash, const RPCError &error) {
|
||||
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
|
||||
|
||||
TerminateButtons::iterator i = _terminateButtons.find(hash);
|
||||
if (i != _terminateButtons.end()) {
|
||||
i.value()->show();
|
||||
@@ -257,18 +259,18 @@ void SessionsBox::gotAuthorizations(const MTPaccount_Authorizations &result) {
|
||||
SessionData data;
|
||||
data.hash = d.vhash.v;
|
||||
|
||||
QString appName, systemVer = qs(d.vsystem_version);
|
||||
if (d.vapi_id.v == 2040 || d.vapi_id.v == 17349) {
|
||||
appName = (d.vapi_id.v == 2040) ? qsl("Telegram Desktop") : qsl("Telegram Desktop (GitHub)");
|
||||
QString appName, systemVer = qs(d.vsystem_version), deviceModel = qs(d.vdevice_model);
|
||||
if (d.vapi_id.v == 17349) {
|
||||
appName = qs(d.vapp_name);// (d.vapi_id.v == 2040) ? qsl("Telegram Desktop") : qsl("Telegram Desktop (GitHub)");
|
||||
if (systemVer == QLatin1String("windows")) {
|
||||
systemVer = qsl("Windows");
|
||||
deviceModel = qsl("Windows");
|
||||
} else if (systemVer == QLatin1String("os x")) {
|
||||
systemVer = qsl("Mac OS X");
|
||||
deviceModel = qsl("Mac OS X");
|
||||
} else if (systemVer == QLatin1String("linux")) {
|
||||
systemVer = qsl("Linux");
|
||||
deviceModel = qsl("Linux");
|
||||
}
|
||||
} else {
|
||||
appName = qs(d.vapp_name);
|
||||
appName = qs(d.vapp_name);// +qsl(" for ") + qs(d.vplatform);
|
||||
}
|
||||
data.name = appName;
|
||||
data.nameWidth = st::sessionNameFont->m.width(data.name);
|
||||
@@ -277,7 +279,7 @@ void SessionsBox::gotAuthorizations(const MTPaccount_Authorizations &result) {
|
||||
CountriesByISO2::const_iterator j = countries.constFind(country);
|
||||
if (j != countries.cend()) country = QString::fromUtf8(j.value()->name);
|
||||
|
||||
data.info = country + QLatin1String(" (") + qs(d.vip) + QLatin1String("), ") + systemVer;
|
||||
data.info = country + QLatin1String(" (") + qs(d.vip) + QLatin1String("), ") + deviceModel;
|
||||
if (!data.hash || (d.vflags.v & 1)) {
|
||||
data.active = QString();
|
||||
data.activeWidth = 0;
|
||||
@@ -292,7 +294,16 @@ void SessionsBox::gotAuthorizations(const MTPaccount_Authorizations &result) {
|
||||
}
|
||||
_current = data;
|
||||
} else {
|
||||
data.active = date(d.vdate_active.v ? d.vdate_active : d.vdate_created).toString(qsl("hh:mm"));
|
||||
QDateTime now(QDateTime::currentDateTime()), lastTime(date(d.vdate_active.v ? d.vdate_active : d.vdate_created));
|
||||
QDate nowDate(now.date()), lastDate(lastTime.date());
|
||||
QString dt;
|
||||
if (lastDate == nowDate) {
|
||||
data.active = lastTime.toString(cTimeFormat());
|
||||
} else if (lastDate.year() == nowDate.year() && lastDate.weekNumber() == nowDate.weekNumber()) {
|
||||
data.active = langDayOfWeek(lastDate);
|
||||
} else {
|
||||
data.active = lastDate.toString(qsl("d.MM.yy"));
|
||||
}
|
||||
data.activeWidth = st::sessionActiveFont->m.width(data.active);
|
||||
int32 availForName = availOther - st::sessionPadding.right() - data.activeWidth;
|
||||
if (data.nameWidth > availForName) {
|
||||
@@ -381,6 +392,8 @@ void SessionsBox::terminateAllDone(const MTPBool &result) {
|
||||
}
|
||||
|
||||
bool SessionsBox::terminateAllFail(const RPCError &error) {
|
||||
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
|
||||
|
||||
MTP::send(MTPaccount_GetAuthorizations(), rpcDone(&SessionsBox::gotAuthorizations));
|
||||
if (_shortPollRequest) {
|
||||
MTP::cancel(_shortPollRequest);
|
||||
|
@@ -99,7 +99,7 @@ void UsernameBox::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
|
||||
void UsernameBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintTitle(p, lang(lng_username_title), true);
|
||||
@@ -194,6 +194,8 @@ void UsernameBox::onUpdateDone(const MTPUser &user) {
|
||||
}
|
||||
|
||||
bool UsernameBox::onUpdateFail(const RPCError &error) {
|
||||
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
|
||||
|
||||
_saveRequest = 0;
|
||||
QString err(error.type()), name = getName();
|
||||
if (err == "USERNAME_NOT_MODIFIED" || _sentUsername == App::self()->username) {
|
||||
@@ -227,6 +229,8 @@ void UsernameBox::onCheckDone(const MTPBool &result) {
|
||||
}
|
||||
|
||||
bool UsernameBox::onCheckFail(const RPCError &error) {
|
||||
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
|
||||
|
||||
_checkRequest = 0;
|
||||
QString err(error.type());
|
||||
if (err == "USERNAME_INVALID") {
|
||||
|
Reference in New Issue
Block a user