mirror of https://github.com/procxx/kepka.git
preparing new dev version, date tooltip on timestamp hover, year marks in old day labels, new auth code / sms algo
This commit is contained in:
parent
84436a34b0
commit
d840ec37db
|
@ -60,6 +60,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
||||||
"lng_weekday7_full" = "Sunday";
|
"lng_weekday7_full" = "Sunday";
|
||||||
|
|
||||||
"lng_month_day" = "{month} {day}";
|
"lng_month_day" = "{month} {day}";
|
||||||
|
"lng_month_day_year" = "{month} {day}, {year}";
|
||||||
|
|
||||||
"lng_cancel" = "Cancel";
|
"lng_cancel" = "Cancel";
|
||||||
"lng_continue" = "Continue";
|
"lng_continue" = "Continue";
|
||||||
|
@ -117,6 +118,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
||||||
|
|
||||||
"lng_code_ph" = "Your code";
|
"lng_code_ph" = "Your code";
|
||||||
"lng_code_desc" = "We have sent you a message with activation\ncode to your phone. Please enter it below.";
|
"lng_code_desc" = "We have sent you a message with activation\ncode to your phone. Please enter it below.";
|
||||||
|
"lng_code_telegram" = "Please enter the code you've just\nreceived in your previous [b]Telegram[/b] app.";
|
||||||
|
"lng_code_no_telegram" = "Send code via SMS";
|
||||||
"lng_code_call" = "Telegram will dial your number in {minutes}:{seconds}";
|
"lng_code_call" = "Telegram will dial your number in {minutes}:{seconds}";
|
||||||
"lng_code_calling" = "Requesting a call from Telegram..";
|
"lng_code_calling" = "Requesting a call from Telegram..";
|
||||||
"lng_code_called" = "Telegram dialed your number";
|
"lng_code_called" = "Telegram dialed your number";
|
||||||
|
|
|
@ -340,6 +340,10 @@ introHeaderFont: font(24px);
|
||||||
introHeaderSkip: 14px;
|
introHeaderSkip: 14px;
|
||||||
introIconSkip: 54px;
|
introIconSkip: 54px;
|
||||||
introFont: font(16px);
|
introFont: font(16px);
|
||||||
|
introLink: linkButton(btnDefLink) {
|
||||||
|
font: introFont;
|
||||||
|
overFont: font(16px underline);
|
||||||
|
}
|
||||||
introColor: black;
|
introColor: black;
|
||||||
introLabel: flatLabel(labelDefFlat) {
|
introLabel: flatLabel(labelDefFlat) {
|
||||||
font: introFont;
|
font: introFont;
|
||||||
|
|
|
@ -542,7 +542,27 @@ public:
|
||||||
flags(0),
|
flags(0),
|
||||||
lnkIndex(0),
|
lnkIndex(0),
|
||||||
stopAfterWidth(QFIXED_MAX) {
|
stopAfterWidth(QFIXED_MAX) {
|
||||||
lnkRanges = links;
|
if ((options.flags & TextParseLinks) && !links.isEmpty()) {
|
||||||
|
bool parseMentions = (options.flags & TextParseMentions);
|
||||||
|
bool parseHashtags = (options.flags & TextParseHashtags);
|
||||||
|
bool parseBotCommands = (options.flags & TextParseBotCommands);
|
||||||
|
if (parseMentions && parseHashtags && parseBotCommands) {
|
||||||
|
lnkRanges = links;
|
||||||
|
} else {
|
||||||
|
int32 i = 0, l = links.size();
|
||||||
|
lnkRanges.reserve(l);
|
||||||
|
const QChar *p = text.constData(), s = text.size();
|
||||||
|
for (; i < l; ++i) {
|
||||||
|
LinkInTextType t = links.at(i).type;
|
||||||
|
if ((t == LinkInTextMention && !parseMentions) ||
|
||||||
|
(t == LinkInTextHashtag && !parseHashtags) ||
|
||||||
|
(t == LinkInTextBotCommand && !parseBotCommands)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
lnkRanges.push_back(links.at(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
parse(options);
|
parse(options);
|
||||||
}
|
}
|
||||||
void parse(const TextParseOptions &options) {
|
void parse(const TextParseOptions &options) {
|
||||||
|
|
|
@ -2015,19 +2015,37 @@ void HistoryPhoto::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x
|
||||||
return fwd->getForwardedState(lnk, state, x - st::mediaPadding.left(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
return fwd->getForwardedState(lnk, state, x - st::mediaPadding.left(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
height -= st::mediaPadding.bottom();
|
height -= skipy + st::mediaPadding.bottom();
|
||||||
width -= st::mediaPadding.left() + st::mediaPadding.right();
|
width -= st::mediaPadding.left() + st::mediaPadding.right();
|
||||||
if (!_caption.isEmpty()) {
|
if (!_caption.isEmpty()) {
|
||||||
|
int32 dateX = skipx + width + st::msgDateDelta.x() - parent->timeWidth(true) + st::msgDateSpace;
|
||||||
|
int32 dateY = _height - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->height;
|
||||||
|
bool inDate = QRect(dateX, dateY, parent->timeWidth(true) - st::msgDateSpace, st::msgDateFont->height).contains(x, y);
|
||||||
|
if (inDate) {
|
||||||
|
state = HistoryInDateCursorState;
|
||||||
|
}
|
||||||
|
|
||||||
height -= _caption.countHeight(width) + st::webPagePhotoSkip;
|
height -= _caption.countHeight(width) + st::webPagePhotoSkip;
|
||||||
if (x >= skipx && y >= height + st::webPagePhotoSkip && x < skipx + width && y < _height) {
|
if (x >= skipx && y >= skipy + height + st::webPagePhotoSkip && x < skipx + width && y < _height) {
|
||||||
bool inText = false;
|
bool inText = false;
|
||||||
_caption.getState(lnk, inText, x - skipx, y - height - st::webPagePhotoSkip, width);
|
_caption.getState(lnk, inText, x - skipx, y - skipy - height - st::webPagePhotoSkip, width);
|
||||||
state = inText ? HistoryInTextCursorState : HistoryDefaultCursorState;
|
state = inDate ? HistoryInDateCursorState : (inText ? HistoryInTextCursorState : HistoryDefaultCursorState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (x >= skipx && y >= skipy && x < skipx + width && y < height) {
|
if (x >= skipx && y >= skipy && x < skipx + width && y < skipy + height) {
|
||||||
lnk = openl;
|
lnk = openl;
|
||||||
|
if (_caption.isEmpty()) {
|
||||||
|
int32 dateX = skipx + width - parent->timeWidth(false) - st::msgDateImgDelta - st::msgDateImgPadding.x();
|
||||||
|
int32 dateY = skipy + height - st::msgDateFont->height - st::msgDateImgDelta - st::msgDateImgPadding.y();
|
||||||
|
if (parent->out()) {
|
||||||
|
dateX -= st::msgCheckRect.pxWidth() + st::msgDateImgCheckSpace;
|
||||||
|
}
|
||||||
|
bool inDate = QRect(dateX, dateY, parent->timeWidth(true) - st::msgDateSpace, st::msgDateFont->height).contains(x, y);
|
||||||
|
if (inDate) {
|
||||||
|
state = HistoryInDateCursorState;
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2422,6 +2440,13 @@ void HistoryVideo::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 dateX = width - st::msgPadding.right() + st::msgDateDelta.x() - parent->timeWidth(true) + st::msgDateSpace;
|
||||||
|
int32 dateY = _height - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->height;
|
||||||
|
bool inDate = QRect(dateX, dateY, parent->timeWidth(true) - st::msgDateSpace, st::msgDateFont->height).contains(x, y);
|
||||||
|
if (inDate) {
|
||||||
|
state = HistoryInDateCursorState;
|
||||||
|
}
|
||||||
|
|
||||||
int32 tw = width - st::mediaPadding.left() - st::mediaPadding.right();
|
int32 tw = width - st::mediaPadding.left() - st::mediaPadding.right();
|
||||||
if (x >= st::mediaPadding.left() && y >= skipy + st::mediaPadding.top() && x < st::mediaPadding.left() + tw && y < skipy + st::mediaPadding.top() + st::mediaThumbSize && !data->loader && data->access) {
|
if (x >= st::mediaPadding.left() && y >= skipy + st::mediaPadding.top() && x < st::mediaPadding.left() + tw && y < skipy + st::mediaPadding.top() + st::mediaThumbSize && !data->loader && data->access) {
|
||||||
lnk = _openl;
|
lnk = _openl;
|
||||||
|
@ -2430,7 +2455,7 @@ void HistoryVideo::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x
|
||||||
if (!_caption.isEmpty() && x >= st::mediaPadding.left() && x < st::mediaPadding.left() + tw && y >= skipy + st::mediaPadding.top() + st::mediaThumbSize + st::webPagePhotoSkip) {
|
if (!_caption.isEmpty() && x >= st::mediaPadding.left() && x < st::mediaPadding.left() + tw && y >= skipy + st::mediaPadding.top() + st::mediaThumbSize + st::webPagePhotoSkip) {
|
||||||
bool inText = false;
|
bool inText = false;
|
||||||
_caption.getState(lnk, inText, x - st::mediaPadding.left(), y - skipy - st::mediaPadding.top() - st::mediaThumbSize - st::webPagePhotoSkip, tw);
|
_caption.getState(lnk, inText, x - st::mediaPadding.left(), y - skipy - st::mediaPadding.top() - st::mediaThumbSize - st::webPagePhotoSkip, tw);
|
||||||
state = inText ? HistoryInTextCursorState : HistoryDefaultCursorState;
|
state = inDate ? HistoryInDateCursorState : (inText ? HistoryInTextCursorState : HistoryDefaultCursorState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2918,6 +2943,14 @@ void HistoryAudio::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x
|
||||||
|
|
||||||
if (x >= 0 && y >= skipy && x < width && y < _height && !data->loader && data->access) {
|
if (x >= 0 && y >= skipy && x < width && y < _height && !data->loader && data->access) {
|
||||||
lnk = _openl;
|
lnk = _openl;
|
||||||
|
|
||||||
|
int32 dateX = width - st::msgPadding.right() + st::msgDateDelta.x() - parent->timeWidth(true) + st::msgDateSpace;
|
||||||
|
int32 dateY = _height - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->height;
|
||||||
|
bool inDate = QRect(dateX, dateY, parent->timeWidth(true) - st::msgDateSpace, st::msgDateFont->height).contains(x, y);
|
||||||
|
if (inDate) {
|
||||||
|
state = HistoryInDateCursorState;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3430,6 +3463,14 @@ void HistoryDocument::getState(TextLinkPtr &lnk, HistoryCursorState &state, int3
|
||||||
|
|
||||||
if (x >= 0 && y >= skipy && x < width && y < _height && !data->loader && data->access) {
|
if (x >= 0 && y >= skipy && x < width && y < _height && !data->loader && data->access) {
|
||||||
lnk = _openl;
|
lnk = _openl;
|
||||||
|
|
||||||
|
int32 dateX = width - st::msgPadding.right() + st::msgDateDelta.x() - parent->timeWidth(true) + st::msgDateSpace;
|
||||||
|
int32 dateY = _height - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->height;
|
||||||
|
bool inDate = QRect(dateX, dateY, parent->timeWidth(true) - st::msgDateSpace, st::msgDateFont->height).contains(x, y);
|
||||||
|
if (inDate) {
|
||||||
|
state = HistoryInDateCursorState;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3602,6 +3643,10 @@ void HistorySticker::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32
|
||||||
const HistoryReply *reply = toHistoryReply(parent);
|
const HistoryReply *reply = toHistoryReply(parent);
|
||||||
if (reply) {
|
if (reply) {
|
||||||
usew -= reply->replyToWidth();
|
usew -= reply->replyToWidth();
|
||||||
|
if (parent->out()) {
|
||||||
|
usex = width - usew;
|
||||||
|
}
|
||||||
|
|
||||||
int32 rw = width - usew, rh = st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
int32 rw = width - usew, rh = st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||||
int32 rx = parent->out() ? 0 : usew, ry = _height - rh;
|
int32 rx = parent->out() ? 0 : usew, ry = _height - rh;
|
||||||
if (x >= rx && y >= ry && x < rx + rw && y < ry + rh) {
|
if (x >= rx && y >= ry && x < rx + rw && y < ry + rh) {
|
||||||
|
@ -3609,6 +3654,15 @@ void HistorySticker::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int32 dateX = usex + usew - parent->timeWidth(false) - st::msgDateImgDelta - st::msgDateImgPadding.x();
|
||||||
|
int32 dateY = _height - st::msgDateFont->height - st::msgDateImgDelta - st::msgDateImgPadding.y();
|
||||||
|
if (parent->out()) {
|
||||||
|
dateX -= st::msgCheckRect.pxWidth() + st::msgDateImgCheckSpace;
|
||||||
|
}
|
||||||
|
bool inDate = QRect(dateX, dateY, parent->timeWidth(true) - st::msgDateSpace, st::msgDateFont->height).contains(x, y);
|
||||||
|
if (inDate) {
|
||||||
|
state = HistoryInDateCursorState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryMedia *HistorySticker::clone() const {
|
HistoryMedia *HistorySticker::clone() const {
|
||||||
|
@ -5159,11 +5213,22 @@ void HistoryImageLink::getState(TextLinkPtr &lnk, HistoryCursorState &state, int
|
||||||
return fwd->getForwardedState(lnk, state, x - st::mediaPadding.left(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
return fwd->getForwardedState(lnk, state, x - st::mediaPadding.left(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
height -= st::mediaPadding.bottom();
|
height -= skipy + st::mediaPadding.bottom();
|
||||||
width -= st::mediaPadding.left() + st::mediaPadding.right();
|
width -= st::mediaPadding.left() + st::mediaPadding.right();
|
||||||
}
|
}
|
||||||
if (x >= skipx && y >= skipy && x < skipx + width && y < height && data) {
|
if (x >= skipx && y >= skipy && x < skipx + width && y < skipy + height && data) {
|
||||||
lnk = link;
|
lnk = link;
|
||||||
|
|
||||||
|
int32 dateX = skipx + width - parent->timeWidth(false) - st::msgDateImgDelta - st::msgDateImgPadding.x();
|
||||||
|
int32 dateY = skipy + height - st::msgDateFont->height - st::msgDateImgDelta - st::msgDateImgPadding.y();
|
||||||
|
if (parent->out()) {
|
||||||
|
dateX -= st::msgCheckRect.pxWidth() + st::msgDateImgCheckSpace;
|
||||||
|
}
|
||||||
|
bool inDate = QRect(dateX, dateY, parent->timeWidth(true) - st::msgDateSpace, st::msgDateFont->height).contains(x, y);
|
||||||
|
if (inDate) {
|
||||||
|
state = HistoryInDateCursorState;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -559,10 +559,10 @@ void HistoryList::onDragExec() {
|
||||||
QDrag *drag = new QDrag(App::wnd());
|
QDrag *drag = new QDrag(App::wnd());
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
|
|
||||||
if (dragSticker || dragByDate) {
|
if (lnkPhoto || lnkVideo || lnkAudio || lnkDocument || lnkContact) {
|
||||||
mimeData->setData(qsl("application/x-td-forward-pressed"), "1");
|
|
||||||
} else {
|
|
||||||
mimeData->setData(qsl("application/x-td-forward-pressed-link"), "1");
|
mimeData->setData(qsl("application/x-td-forward-pressed-link"), "1");
|
||||||
|
} else {
|
||||||
|
mimeData->setData(qsl("application/x-td-forward-pressed"), "1");
|
||||||
}
|
}
|
||||||
if (lnkDocument) {
|
if (lnkDocument) {
|
||||||
QString already = static_cast<DocumentOpenLink*>(textlnkDown().data())->document()->already(true);
|
QString already = static_cast<DocumentOpenLink*>(textlnkDown().data())->document()->already(true);
|
||||||
|
@ -1346,7 +1346,6 @@ void HistoryList::onUpdateSelected() {
|
||||||
if (_dragItem && _dragItem->detached()) {
|
if (_dragItem && _dragItem->detached()) {
|
||||||
dragActionCancel();
|
dragActionCancel();
|
||||||
}
|
}
|
||||||
linkTipTimer.start(1000);
|
|
||||||
|
|
||||||
Qt::CursorShape cur = style::cur_default;
|
Qt::CursorShape cur = style::cur_default;
|
||||||
HistoryCursorState cursorState = HistoryDefaultCursorState;
|
HistoryCursorState cursorState = HistoryDefaultCursorState;
|
||||||
|
@ -1383,6 +1382,12 @@ void HistoryList::onUpdateSelected() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (lnk || cursorState == HistoryInDateCursorState) {
|
||||||
|
linkTipTimer.start(1000);
|
||||||
|
}
|
||||||
|
if (_dragCursorState == HistoryInDateCursorState && cursorState != HistoryInDateCursorState) {
|
||||||
|
QToolTip::showText(_dragPos, QString(), App::wnd());
|
||||||
|
}
|
||||||
|
|
||||||
if (_dragAction == NoDrag) {
|
if (_dragAction == NoDrag) {
|
||||||
_dragCursorState = cursorState;
|
_dragCursorState = cursorState;
|
||||||
|
@ -1546,6 +1551,10 @@ void HistoryList::showLinkTip() {
|
||||||
TextLinkPtr lnk = textlnkOver();
|
TextLinkPtr lnk = textlnkOver();
|
||||||
if (lnk && !lnk->fullDisplayed()) {
|
if (lnk && !lnk->fullDisplayed()) {
|
||||||
QToolTip::showText(_dragPos, lnk->readable(), App::wnd());
|
QToolTip::showText(_dragPos, lnk->readable(), App::wnd());
|
||||||
|
} else if (_dragCursorState == HistoryInDateCursorState && _dragAction == NoDrag) {
|
||||||
|
if (App::hoveredItem()) {
|
||||||
|
QToolTip::showText(_dragPos, App::hoveredItem()->date.toString(QLocale::system().dateTimeFormat(QLocale::LongFormat)), App::wnd());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3416,7 +3425,7 @@ void HistoryWidget::shareContact(const PeerId &peer, const QString &phone, const
|
||||||
fastShowAtEnd(h);
|
fastShowAtEnd(h);
|
||||||
|
|
||||||
PeerData *p = App::peer(peer);
|
PeerData *p = App::peer(peer);
|
||||||
int32 flags = newMessageFlags(p); // unread, out
|
int32 flags = newMessageFlags(p) | MTPDmessage::flag_media; // unread, out
|
||||||
|
|
||||||
bool lastKeyboardUsed = lastForceReplyReplied(replyTo);
|
bool lastKeyboardUsed = lastForceReplyReplied(replyTo);
|
||||||
|
|
||||||
|
@ -4296,14 +4305,15 @@ void HistoryWidget::confirmSendImage(const ReadyLocalMedia &img) {
|
||||||
|
|
||||||
fastShowAtEnd(h);
|
fastShowAtEnd(h);
|
||||||
|
|
||||||
int32 flags = newMessageFlags(h->peer); // unread, out
|
int32 flags = newMessageFlags(h->peer) | MTPDmessage::flag_media; // unread, out
|
||||||
if (img.replyTo) flags |= MTPDmessage::flag_reply_to_msg_id;
|
if (img.replyTo) flags |= MTPDmessage::flag_reply_to_msg_id;
|
||||||
if (img.type == ToPreparePhoto) {
|
if (img.type == ToPreparePhoto) {
|
||||||
h->addToBack(MTP_message(MTP_int(flags), MTP_int(newId), MTP_int(MTP::authedId()), App::peerToMTP(img.peer), MTPint(), MTPint(), MTP_int(img.replyTo), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaPhoto(img.photo, MTP_string("")), MTPnullMarkup, MTPnullEntities));
|
h->addToBack(MTP_message(MTP_int(flags), MTP_int(newId), MTP_int(MTP::authedId()), App::peerToMTP(img.peer), MTPint(), MTPint(), MTP_int(img.replyTo), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaPhoto(img.photo, MTP_string("")), MTPnullMarkup, MTPnullEntities));
|
||||||
} else if (img.type == ToPrepareDocument) {
|
} else if (img.type == ToPrepareDocument) {
|
||||||
h->addToBack(MTP_message(MTP_int(flags), MTP_int(newId), MTP_int(MTP::authedId()), App::peerToMTP(img.peer), MTPint(), MTPint(), MTP_int(img.replyTo), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaDocument(img.document), MTPnullMarkup, MTPnullEntities));
|
h->addToBack(MTP_message(MTP_int(flags), MTP_int(newId), MTP_int(MTP::authedId()), App::peerToMTP(img.peer), MTPint(), MTPint(), MTP_int(img.replyTo), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaDocument(img.document), MTPnullMarkup, MTPnullEntities));
|
||||||
} else if (img.type == ToPrepareAudio) {
|
} else if (img.type == ToPrepareAudio) {
|
||||||
h->addToBack(MTP_message(MTP_int(flags | MTPDmessage_flag_media_unread), MTP_int(newId), MTP_int(MTP::authedId()), App::peerToMTP(img.peer), MTPint(), MTPint(), MTP_int(img.replyTo), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaAudio(img.audio), MTPnullMarkup, MTPnullEntities));
|
flags |= MTPDmessage_flag_media_unread;
|
||||||
|
h->addToBack(MTP_message(MTP_int(flags), MTP_int(newId), MTP_int(MTP::authedId()), App::peerToMTP(img.peer), MTPint(), MTPint(), MTP_int(img.replyTo), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaAudio(img.audio), MTPnullMarkup, MTPnullEntities));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_peer && img.peer == _peer->id) {
|
if (_peer && img.peer == _peer->id) {
|
||||||
|
@ -4902,7 +4912,7 @@ void HistoryWidget::onStickerSend(DocumentData *sticker) {
|
||||||
bool lastKeyboardUsed = lastForceReplyReplied();
|
bool lastKeyboardUsed = lastForceReplyReplied();
|
||||||
|
|
||||||
bool out = (_peer->input.type() != mtpc_inputPeerSelf), unread = (_peer->input.type() != mtpc_inputPeerSelf);
|
bool out = (_peer->input.type() != mtpc_inputPeerSelf), unread = (_peer->input.type() != mtpc_inputPeerSelf);
|
||||||
int32 flags = newMessageFlags(_peer); // unread, out
|
int32 flags = newMessageFlags(_peer) | MTPDmessage::flag_media; // unread, out
|
||||||
int32 sendFlags = 0;
|
int32 sendFlags = 0;
|
||||||
if (replyToId()) {
|
if (replyToId()) {
|
||||||
flags |= MTPDmessage::flag_reply_to_msg_id;
|
flags |= MTPDmessage::flag_reply_to_msg_id;
|
||||||
|
|
|
@ -65,6 +65,7 @@ visibilityChanging(0),
|
||||||
_callTimeout(60),
|
_callTimeout(60),
|
||||||
_registered(false),
|
_registered(false),
|
||||||
_hasRecovery(false),
|
_hasRecovery(false),
|
||||||
|
_codeByTelegram(false),
|
||||||
_back(this, st::setClose),
|
_back(this, st::setClose),
|
||||||
_backFrom(0), _backTo(0) {
|
_backFrom(0), _backTo(0) {
|
||||||
setGeometry(QRect(0, st::titleHeight, wnd->width(), wnd->height() - st::titleHeight));
|
setGeometry(QRect(0, st::titleHeight, wnd->width(), wnd->height() - st::titleHeight));
|
||||||
|
@ -335,6 +336,11 @@ void IntroWidget::setPwdHint(const QString &hint) {
|
||||||
_pwdHint = hint;
|
_pwdHint = hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IntroWidget::setCodeByTelegram(bool byTelegram) {
|
||||||
|
_codeByTelegram = byTelegram;
|
||||||
|
if (code) code->updateDescText();
|
||||||
|
}
|
||||||
|
|
||||||
void IntroWidget::setCallTimeout(int32 callTimeout) {
|
void IntroWidget::setCallTimeout(int32 callTimeout) {
|
||||||
_callTimeout = callTimeout;
|
_callTimeout = callTimeout;
|
||||||
}
|
}
|
||||||
|
@ -367,6 +373,10 @@ const QString &IntroWidget::getPwdHint() const {
|
||||||
return _pwdHint;
|
return _pwdHint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IntroWidget::codeByTelegram() const {
|
||||||
|
return _codeByTelegram;
|
||||||
|
}
|
||||||
|
|
||||||
void IntroWidget::resizeEvent(QResizeEvent *e) {
|
void IntroWidget::resizeEvent(QResizeEvent *e) {
|
||||||
QRect r(innerRect());
|
QRect r(innerRect());
|
||||||
if (steps) steps->setGeometry(r);
|
if (steps) steps->setGeometry(r);
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
void setPwdSalt(const QByteArray &salt);
|
void setPwdSalt(const QByteArray &salt);
|
||||||
void setHasRecovery(bool hasRecovery);
|
void setHasRecovery(bool hasRecovery);
|
||||||
void setPwdHint(const QString &hint);
|
void setPwdHint(const QString &hint);
|
||||||
|
void setCodeByTelegram(bool byTelegram);
|
||||||
|
|
||||||
const QString &getPhone() const;
|
const QString &getPhone() const;
|
||||||
const QString &getPhoneHash() const;
|
const QString &getPhoneHash() const;
|
||||||
|
@ -60,6 +61,7 @@ public:
|
||||||
const QByteArray &getPwdSalt() const;
|
const QByteArray &getPwdSalt() const;
|
||||||
bool getHasRecovery() const;
|
bool getHasRecovery() const;
|
||||||
const QString &getPwdHint() const;
|
const QString &getPwdHint() const;
|
||||||
|
bool codeByTelegram() const;
|
||||||
|
|
||||||
void finish(const MTPUser &user, const QImage &photo = QImage());
|
void finish(const MTPUser &user, const QImage &photo = QImage());
|
||||||
|
|
||||||
|
@ -114,7 +116,7 @@ private:
|
||||||
QString _code;
|
QString _code;
|
||||||
|
|
||||||
QByteArray _pwdSalt;
|
QByteArray _pwdSalt;
|
||||||
bool _hasRecovery;
|
bool _hasRecovery, _codeByTelegram;
|
||||||
QString _pwdHint;
|
QString _pwdHint;
|
||||||
|
|
||||||
QString _firstname, _lastname;
|
QString _firstname, _lastname;
|
||||||
|
|
|
@ -69,6 +69,9 @@ void CodeInput::correctValue(QKeyEvent *e, const QString &was) {
|
||||||
|
|
||||||
IntroCode::IntroCode(IntroWidget *parent) : IntroStage(parent), errorAlpha(0),
|
IntroCode::IntroCode(IntroWidget *parent) : IntroStage(parent), errorAlpha(0),
|
||||||
next(this, lang(lng_intro_next), st::btnIntroNext),
|
next(this, lang(lng_intro_next), st::btnIntroNext),
|
||||||
|
_desc(st::introTextSize.width()),
|
||||||
|
_noTelegramCode(this, lang(lng_code_no_telegram), st::introLink),
|
||||||
|
_noTelegramCodeRequestId(0),
|
||||||
code(this, st::inpIntroCode, lang(lng_code_ph)), waitTillCall(intro()->getCallTimeout()) {
|
code(this, st::inpIntroCode, lang(lng_code_ph)), waitTillCall(intro()->getCallTimeout()) {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
setGeometry(parent->innerRect());
|
setGeometry(parent->innerRect());
|
||||||
|
@ -78,6 +81,24 @@ IntroCode::IntroCode(IntroWidget *parent) : IntroStage(parent), errorAlpha(0),
|
||||||
connect(&code, SIGNAL(changed()), this, SLOT(onInputChange()));
|
connect(&code, SIGNAL(changed()), this, SLOT(onInputChange()));
|
||||||
connect(&callTimer, SIGNAL(timeout()), this, SLOT(onSendCall()));
|
connect(&callTimer, SIGNAL(timeout()), this, SLOT(onSendCall()));
|
||||||
connect(&checkRequest, SIGNAL(timeout()), this, SLOT(onCheckRequest()));
|
connect(&checkRequest, SIGNAL(timeout()), this, SLOT(onCheckRequest()));
|
||||||
|
connect(&_noTelegramCode, SIGNAL(clicked()), this, SLOT(onNoTelegramCode()));
|
||||||
|
|
||||||
|
updateDescText();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntroCode::updateDescText() {
|
||||||
|
_desc.setRichText(st::introFont, lang(intro()->codeByTelegram() ? lng_code_telegram : lng_code_desc));
|
||||||
|
if (intro()->codeByTelegram()) {
|
||||||
|
_noTelegramCode.show();
|
||||||
|
callTimer.stop();
|
||||||
|
} else {
|
||||||
|
_noTelegramCode.hide();
|
||||||
|
waitTillCall = intro()->getCallTimeout();
|
||||||
|
if (!callTimer.isActive()) {
|
||||||
|
callTimer.start(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntroCode::paintEvent(QPaintEvent *e) {
|
void IntroCode::paintEvent(QPaintEvent *e) {
|
||||||
|
@ -87,21 +108,25 @@ void IntroCode::paintEvent(QPaintEvent *e) {
|
||||||
if (!trivial) {
|
if (!trivial) {
|
||||||
p.setClipRect(e->rect());
|
p.setClipRect(e->rect());
|
||||||
}
|
}
|
||||||
|
bool codeByTelegram = intro()->codeByTelegram();
|
||||||
if (trivial || e->rect().intersects(textRect)) {
|
if (trivial || e->rect().intersects(textRect)) {
|
||||||
p.setFont(st::introHeaderFont->f);
|
p.setFont(st::introHeaderFont->f);
|
||||||
p.drawText(textRect, intro()->getPhone(), style::al_top);
|
p.drawText(textRect, intro()->getPhone(), style::al_top);
|
||||||
p.setFont(st::introFont->f);
|
p.setFont(st::introFont->f);
|
||||||
p.drawText(textRect, lang(lng_code_desc), style::al_bottom);
|
_desc.draw(p, textRect.x(), textRect.y() + textRect.height() - 2 * st::introFont->height, textRect.width(), style::al_top);
|
||||||
}
|
}
|
||||||
QString callText = lang(lng_code_calling);
|
if (codeByTelegram) {
|
||||||
if (waitTillCall >= 3600) {
|
} else {
|
||||||
callText = lng_code_call(lt_minutes, qsl("%1:%2").arg(waitTillCall / 3600).arg((waitTillCall / 60) % 60, 2, 10, QChar('0')), lt_seconds, qsl("%1").arg(waitTillCall % 60, 2, 10, QChar('0')));
|
QString callText = lang(lng_code_calling);
|
||||||
} else if (waitTillCall > 0) {
|
if (waitTillCall >= 3600) {
|
||||||
callText = lng_code_call(lt_minutes, QString::number(waitTillCall / 60), lt_seconds, qsl("%1").arg(waitTillCall % 60, 2, 10, QChar('0')));
|
callText = lng_code_call(lt_minutes, qsl("%1:%2").arg(waitTillCall / 3600).arg((waitTillCall / 60) % 60, 2, 10, QChar('0')), lt_seconds, qsl("%1").arg(waitTillCall % 60, 2, 10, QChar('0')));
|
||||||
} else if (waitTillCall < 0) {
|
} else if (waitTillCall > 0) {
|
||||||
callText = lang(lng_code_called);
|
callText = lng_code_call(lt_minutes, QString::number(waitTillCall / 60), lt_seconds, qsl("%1").arg(waitTillCall % 60, 2, 10, QChar('0')));
|
||||||
|
} else if (waitTillCall < 0) {
|
||||||
|
callText = lang(lng_code_called);
|
||||||
|
}
|
||||||
|
p.drawText(QRect(textRect.left(), code.y() + code.height() + st::introCallSkip, st::introTextSize.width(), st::introErrHeight), callText, style::al_center);
|
||||||
}
|
}
|
||||||
p.drawText(QRect(textRect.left(), code.y() + code.height() + st::introCallSkip, st::introTextSize.width(), st::introErrHeight), callText, style::al_center);
|
|
||||||
if (animating() || error.length()) {
|
if (animating() || error.length()) {
|
||||||
p.setOpacity(errorAlpha.current());
|
p.setOpacity(errorAlpha.current());
|
||||||
p.setFont(st::introErrFont->f);
|
p.setFont(st::introErrFont->f);
|
||||||
|
@ -116,6 +141,7 @@ void IntroCode::resizeEvent(QResizeEvent *e) {
|
||||||
code.move((width() - code.width()) / 2, st::introTextTop + st::introTextSize.height() + st::introCountry.top);
|
code.move((width() - code.width()) / 2, st::introTextTop + st::introTextSize.height() + st::introCountry.top);
|
||||||
}
|
}
|
||||||
textRect = QRect((width() - st::introTextSize.width()) / 2, st::introTextTop, st::introTextSize.width(), st::introTextSize.height());
|
textRect = QRect((width() - st::introTextSize.width()) / 2, st::introTextTop, st::introTextSize.width(), st::introTextSize.height());
|
||||||
|
_noTelegramCode.move(textRect.left() + (st::introTextSize.width() - _noTelegramCode.width()) / 2, code.y() + code.height() + st::introCallSkip + (st::introErrHeight - _noTelegramCode.height()) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntroCode::showError(const QString &err) {
|
void IntroCode::showError(const QString &err) {
|
||||||
|
@ -150,7 +176,9 @@ bool IntroCode::animStep(float64 ms) {
|
||||||
|
|
||||||
void IntroCode::activate() {
|
void IntroCode::activate() {
|
||||||
waitTillCall = intro()->getCallTimeout();
|
waitTillCall = intro()->getCallTimeout();
|
||||||
callTimer.start(1000);
|
if (!intro()->codeByTelegram()) {
|
||||||
|
callTimer.start(1000);
|
||||||
|
}
|
||||||
error = "";
|
error = "";
|
||||||
errorAlpha = anim::fvalue(0);
|
errorAlpha = anim::fvalue(0);
|
||||||
sentCode = QString();
|
sentCode = QString();
|
||||||
|
@ -300,6 +328,31 @@ void IntroCode::onSubmitCode(bool force) {
|
||||||
sentRequest = MTP::send(MTPauth_SignIn(MTP_string(intro()->getPhone()), MTP_string(intro()->getPhoneHash()), MTP_string(sentCode)), rpcDone(&IntroCode::codeSubmitDone), rpcFail(&IntroCode::codeSubmitFail));
|
sentRequest = MTP::send(MTPauth_SignIn(MTP_string(intro()->getPhone()), MTP_string(intro()->getPhoneHash()), MTP_string(sentCode)), rpcDone(&IntroCode::codeSubmitDone), rpcFail(&IntroCode::codeSubmitFail));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IntroCode::onNoTelegramCode() {
|
||||||
|
if (_noTelegramCodeRequestId) return;
|
||||||
|
_noTelegramCodeRequestId = MTP::send(MTPauth_SendSms(MTP_string(intro()->getPhone()), MTP_string(intro()->getPhoneHash())), rpcDone(&IntroCode::noTelegramCodeDone), rpcFail(&IntroCode::noTelegramCodeFail));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntroCode::noTelegramCodeDone(const MTPBool &result) {
|
||||||
|
intro()->setCodeByTelegram(false);
|
||||||
|
updateDescText();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IntroCode::noTelegramCodeFail(const RPCError &error) {
|
||||||
|
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) {
|
||||||
|
showError(lang(lng_flood_error));
|
||||||
|
code.setFocus();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (cDebug()) { // internal server error
|
||||||
|
showError(error.type() + ": " + error.description());
|
||||||
|
} else {
|
||||||
|
showError(lang(lng_server_error));
|
||||||
|
}
|
||||||
|
code.setFocus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void IntroCode::onNext() {
|
void IntroCode::onNext() {
|
||||||
onSubmitCode();
|
onSubmitCode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,12 @@ public:
|
||||||
void codeSubmitDone(const MTPauth_Authorization &result);
|
void codeSubmitDone(const MTPauth_Authorization &result);
|
||||||
bool codeSubmitFail(const RPCError &error);
|
bool codeSubmitFail(const RPCError &error);
|
||||||
|
|
||||||
|
void updateDescText();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void onSubmitCode(bool force = false);
|
void onSubmitCode(bool force = false);
|
||||||
|
void onNoTelegramCode();
|
||||||
void onInputChange();
|
void onInputChange();
|
||||||
void onSendCall();
|
void onSendCall();
|
||||||
void onCheckRequest();
|
void onCheckRequest();
|
||||||
|
@ -84,8 +87,14 @@ private:
|
||||||
|
|
||||||
FlatButton next;
|
FlatButton next;
|
||||||
|
|
||||||
|
Text _desc;
|
||||||
|
LinkButton _noTelegramCode;
|
||||||
|
mtpRequestId _noTelegramCodeRequestId;
|
||||||
QRect textRect;
|
QRect textRect;
|
||||||
|
|
||||||
|
void noTelegramCodeDone(const MTPBool &result);
|
||||||
|
bool noTelegramCodeFail(const RPCError &result);
|
||||||
|
|
||||||
CodeInput code;
|
CodeInput code;
|
||||||
QString sentCode;
|
QString sentCode;
|
||||||
mtpRequestId sentRequest;
|
mtpRequestId sentRequest;
|
||||||
|
|
|
@ -231,7 +231,7 @@ void IntroPhone::phoneCheckDone(const MTPauth_CheckedPhone &result) {
|
||||||
|
|
||||||
checkRequest.start(1000);
|
checkRequest.start(1000);
|
||||||
|
|
||||||
sentRequest = MTP::send(MTPauth_SendCode(MTP_string(sentPhone), MTP_int(0), MTP_int(ApiId), MTP_string(ApiHash), MTP_string(Application::language())), rpcDone(&IntroPhone::phoneSubmitDone), rpcFail(&IntroPhone::phoneSubmitFail));
|
sentRequest = MTP::send(MTPauth_SendCode(MTP_string(sentPhone), MTP_int(5), MTP_int(ApiId), MTP_string(ApiHash), MTP_string(Application::language())), rpcDone(&IntroPhone::phoneSubmitDone), rpcFail(&IntroPhone::phoneSubmitFail));
|
||||||
} else {
|
} else {
|
||||||
showError(lang(lng_bad_phone_noreg), true);
|
showError(lang(lng_bad_phone_noreg), true);
|
||||||
enableAll(true);
|
enableAll(true);
|
||||||
|
@ -250,6 +250,7 @@ void IntroPhone::phoneSubmitDone(const MTPauth_SentCode &result) {
|
||||||
const MTPDauth_sentAppCode &d(result.c_auth_sentAppCode());
|
const MTPDauth_sentAppCode &d(result.c_auth_sentAppCode());
|
||||||
intro()->setPhone(sentPhone, d.vphone_code_hash.c_string().v.c_str(), d.vphone_registered.v);
|
intro()->setPhone(sentPhone, d.vphone_code_hash.c_string().v.c_str(), d.vphone_registered.v);
|
||||||
intro()->setCallTimeout(d.vsend_call_timeout.v);
|
intro()->setCallTimeout(d.vsend_call_timeout.v);
|
||||||
|
intro()->setCodeByTelegram(true);
|
||||||
}
|
}
|
||||||
intro()->onIntroNext();
|
intro()->onIntroNext();
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,13 @@ LangString langCounted(ushort key0, ushort tag, float64 value);
|
||||||
const char *langKeyName(LangKey key);
|
const char *langKeyName(LangKey key);
|
||||||
|
|
||||||
inline LangString langDayOfMonth(const QDate &date) {
|
inline LangString langDayOfMonth(const QDate &date) {
|
||||||
int32 month = date.month(), day = date.day();
|
QDate c(QDate::currentDate());
|
||||||
|
int32 month = date.month(), day = date.day(), year = date.year(), cyear = c.year(), cmonth = c.month();
|
||||||
|
if (year != cyear) {
|
||||||
|
if (year > cyear + 1 || cyear > year + 1 || (year == cyear + 1 && month + 12 > cmonth + 3) || (cyear == year + 1 && cmonth + 12 > month + 3)) {
|
||||||
|
return (month > 0 && month <= 12) ? lng_month_day_year(lt_month, lang(LangKey(lng_month1 + month - 1)), lt_day, QString::number(day), lt_year, QString::number(year)) : qsl("MONTH_ERR");
|
||||||
|
}
|
||||||
|
}
|
||||||
return (month > 0 && month <= 12) ? lng_month_day(lt_month, lang(LangKey(lng_month1 + month - 1)), lt_day, QString::number(day)) : qsl("MONTH_ERR");
|
return (month > 0 && month <= 12) ? lng_month_day(lt_month, lang(LangKey(lng_month1 + month - 1)), lt_day, QString::number(day)) : qsl("MONTH_ERR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1064,6 +1064,7 @@ void MainWidget::sendPreparedText(History *hist, const QString &text, MsgId repl
|
||||||
} else if (webPageId) {
|
} else if (webPageId) {
|
||||||
WebPageData *page = App::webPage(webPageId);
|
WebPageData *page = App::webPage(webPageId);
|
||||||
media = MTP_messageMediaWebPage(MTP_webPagePending(MTP_long(page->id), MTP_int(page->pendingTill)));
|
media = MTP_messageMediaWebPage(MTP_webPagePending(MTP_long(page->id), MTP_int(page->pendingTill)));
|
||||||
|
flags |= MTPDmessage::flag_media;
|
||||||
}
|
}
|
||||||
MTPVector<MTPMessageEntity> localEntities = linksToMTP(textParseLinks(sendingText, itemTextParseOptions(hist, App::self()).flags));
|
MTPVector<MTPMessageEntity> localEntities = linksToMTP(textParseLinks(sendingText, itemTextParseOptions(hist, App::self()).flags));
|
||||||
hist->addToBack(MTP_message(MTP_int(flags), MTP_int(newId), MTP_int(MTP::authedId()), App::peerToMTP(hist->peer->id), MTPint(), MTPint(), MTP_int(replyTo), MTP_int(unixtime()), msgText, media, MTPnullMarkup, localEntities));
|
hist->addToBack(MTP_message(MTP_int(flags), MTP_int(newId), MTP_int(MTP::authedId()), App::peerToMTP(hist->peer->id), MTPint(), MTPint(), MTP_int(replyTo), MTP_int(unixtime()), msgText, media, MTPnullMarkup, localEntities));
|
||||||
|
|
Loading…
Reference in New Issue