From 8b2c3519337e02486f3a6099f47ad869149c67dc Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 8 Jun 2016 19:40:33 +0300 Subject: [PATCH] Phone numbers starting with '0' are not formatted with '+'. Sticker with reply layout fixed. Report box title corrected. Elided text display sometimes didn't restore last block, fixed. Removed non-existent class diagram file from MSVC project. --- Telegram/SourceFiles/app.cpp | 2 ++ Telegram/SourceFiles/boxes/report_box.cpp | 2 +- Telegram/SourceFiles/history.cpp | 15 +++++++-------- Telegram/SourceFiles/ui/text/text.cpp | 13 +++++++++---- Telegram/Telegram.vcxproj | 1 - Telegram/Telegram.vcxproj.filters | 1 - 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 6aefddfa92..84b9de3fdb 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -123,6 +123,8 @@ namespace App { QString formatPhone(QString phone) { if (phone.isEmpty()) return QString(); + if (phone.at(0) == '0') return phone; + QString number = phone; for (const QChar *ch = phone.constData(), *e = ch + phone.size(); ch != e; ++ch) { if (ch->unicode() < '0' || ch->unicode() > '9') { diff --git a/Telegram/SourceFiles/boxes/report_box.cpp b/Telegram/SourceFiles/boxes/report_box.cpp index af048e2d81..97c50f2253 100644 --- a/Telegram/SourceFiles/boxes/report_box.cpp +++ b/Telegram/SourceFiles/boxes/report_box.cpp @@ -50,7 +50,7 @@ void ReportBox::paintEvent(QPaintEvent *e) { Painter p(this); if (paint(p)) return; - paintTitle(p, lang(_channel->isMegagroup() ? lng_report_title : lng_report_group_title)); + paintTitle(p, lang(_channel->isMegagroup() ? lng_report_group_title : lng_report_title)); } void ReportBox::resizeEvent(QResizeEvent *e) { diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 9399aacc19..7ce86f253b 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -4728,20 +4728,21 @@ void HistorySticker::initDimensions() { if (_pixh < 1) _pixh = 1; _maxw = qMax(_pixw, int16(st::minPhotoSize)); _minh = qMax(_pixh, int16(st::minPhotoSize)); - if (_parent->getMedia() == this) { - _maxw += additionalWidth(); - } + _height = _minh; } int HistorySticker::resizeGetHeight(int width) { // return new height - _width = qMin(width, _maxw); + int maxWidth = _maxw; + if (_parent->getMedia() == this) { + maxWidth += additionalWidth(); + } + _width = qMin(width, maxWidth); if (_parent->getMedia() == this) { auto via = _parent->Get(); auto reply = _parent->Get(); if (via || reply) { - int usew = _maxw - additionalWidth(via, reply); - int availw = _width - usew - st::msgReplyPadding.left() - st::msgReplyPadding.left() - st::msgReplyPadding.left(); + int availw = _width - _maxw - st::msgReplyPadding.left() - st::msgReplyPadding.left() - st::msgReplyPadding.left(); if (via) { via->resize(availw); } @@ -4766,7 +4767,6 @@ void HistorySticker::draw(Painter &p, const QRect &r, TextSelection selection, u auto via = childmedia ? nullptr : _parent->Get(); auto reply = childmedia ? nullptr : _parent->Get(); if (via || reply) { - usew -= additionalWidth(via, reply); if (isPost) { } else if (out) { usex = _width - usew; @@ -4836,7 +4836,6 @@ HistoryTextState HistorySticker::getState(int x, int y, HistoryStateRequest requ auto via = childmedia ? nullptr : _parent->Get(); auto reply = childmedia ? nullptr : _parent->Get(); if (via || reply) { - usew -= additionalWidth(via, reply); if (isPost) { } else if (out) { usex = _width - usew; diff --git a/Telegram/SourceFiles/ui/text/text.cpp b/Telegram/SourceFiles/ui/text/text.cpp index d7d822ef95..6368d6421d 100644 --- a/Telegram/SourceFiles/ui/text/text.cpp +++ b/Telegram/SourceFiles/ui/text/text.cpp @@ -860,6 +860,10 @@ public: TextPainter(QPainter *p, const Text *t) : _p(p), _t(t) { } + ~TextPainter() { + restoreAfterElided(); + } + void initNextParagraph(Text::TextBlocks::const_iterator i) { _parStartBlock = i; Text::TextBlocks::const_iterator e = _t->_blocks.cend(); @@ -1292,7 +1296,6 @@ public: int firstItem = engine.findItem(line.from), lastItem = engine.findItem(line.from + line.length - 1); int nItems = (firstItem >= 0 && lastItem >= firstItem) ? (lastItem - firstItem + 1) : 0; if (!nItems) { - if (elidedLine) restoreAfterElided(); return true; } @@ -1546,12 +1549,14 @@ public: x += itemWidth; } - - if (elidedLine) restoreAfterElided(); return true; } void elideSaveBlock(int32 blockIndex, ITextBlock *&_endBlock, int32 elideStart, int32 elideWidth) { + if (_elideSavedBlock) { + restoreAfterElided(); + } + _elideSavedIndex = blockIndex; _elideSavedBlock = _t->_blocks[blockIndex]; const_cast(_t)->_blocks[blockIndex] = new TextBlock(_t->_font, _t->_text, QFIXED_MAX, elideStart, 0, _elideSavedBlock->flags(), _elideSavedBlock->color(), _elideSavedBlock->lnkIndex()); @@ -1681,7 +1686,7 @@ public: if (_elideSavedBlock) { delete _t->_blocks[_elideSavedIndex]; const_cast(_t)->_blocks[_elideSavedIndex] = _elideSavedBlock; - _elideSavedBlock = 0; + _elideSavedBlock = nullptr; } } diff --git a/Telegram/Telegram.vcxproj b/Telegram/Telegram.vcxproj index 19b2024277..0f0dc03c6c 100644 --- a/Telegram/Telegram.vcxproj +++ b/Telegram/Telegram.vcxproj @@ -2686,7 +2686,6 @@ - .\GeneratedFiles\lang_auto.h diff --git a/Telegram/Telegram.vcxproj.filters b/Telegram/Telegram.vcxproj.filters index c874e07879..7ca1713785 100644 --- a/Telegram/Telegram.vcxproj.filters +++ b/Telegram/Telegram.vcxproj.filters @@ -1839,7 +1839,6 @@ Resources\langs -