diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index cc7c21be5..b3f7cf3e2 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,9,55,0 - PRODUCTVERSION 0,9,55,0 + FILEVERSION 0,9,56,0 + PRODUCTVERSION 0,9,56,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -51,10 +51,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "Telegram Messenger LLP" - VALUE "FileVersion", "0.9.55.0" + VALUE "FileVersion", "0.9.56.0" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.9.55.0" + VALUE "ProductVersion", "0.9.56.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index fa7b0058b..1cdd13d51 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,9,55,0 - PRODUCTVERSION 0,9,55,0 + FILEVERSION 0,9,56,0 + PRODUCTVERSION 0,9,56,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -43,10 +43,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram Messenger LLP" VALUE "FileDescription", "Telegram Updater" - VALUE "FileVersion", "0.9.55.0" + VALUE "FileVersion", "0.9.56.0" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.9.55.0" + VALUE "ProductVersion", "0.9.56.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index 212c50317..f26bbb6e3 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -1048,7 +1048,7 @@ void AppClass::checkMapVersion() { if ((cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 9055) { versionFeatures = QString::fromUtf8("\xe2\x80\x94 Main window position and size are saved between the launches in Windows\n\xe2\x80\x94 Dock and top bar hiding fixed in OS X\n\xe2\x80\x94 Various design improvements and other bug fixes"); // versionFeatures = langNewVersionText(); - } else if (Local::oldMapVersion() < 9050) { + } else if (Local::oldMapVersion() < 9056) { versionFeatures = langNewVersionText(); } else { versionFeatures = lang(lng_new_version_minor).trimmed(); diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index 3e698c0d2..68d7dbbd0 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #define BETA_VERSION_MACRO (0ULL) -constexpr int AppVersion = 9055; -constexpr str_const AppVersionStr = "0.9.55"; -constexpr bool AppAlphaVersion = true; +constexpr int AppVersion = 9056; +constexpr str_const AppVersionStr = "0.9.56"; +constexpr bool AppAlphaVersion = false; constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO; diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index ae585def9..2665065c4 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -2306,21 +2306,34 @@ void ReplyKeyboard::resize(int width, int height) { for (ButtonRow &row : _rows) { int s = row.size(); - int widthForText = _width - ((s - 1) * _st->buttonSkip()); + int widthForButtons = _width - ((s - 1) * _st->buttonSkip()); + int widthForText = widthForButtons; int widthOfText = 0; + int maxMinButtonWidth = 0; for_const (const Button &button, row) { widthOfText += qMax(button.text.maxWidth(), 1); - widthForText -= _st->minButtonWidth(button.type); + int minButtonWidth = _st->minButtonWidth(button.type); + widthForText -= minButtonWidth; + accumulate_max(maxMinButtonWidth, minButtonWidth); } bool exact = (widthForText == widthOfText); + bool enough = (widthForButtons - s * maxMinButtonWidth) >= widthOfText; float64 x = 0; for (Button &button : row) { int buttonw = qMax(button.text.maxWidth(), 1); - float64 textw = exact ? buttonw : (widthForText / float64(s)); - float64 minw = _st->minButtonWidth(button.type); - float64 w = minw + textw; - accumulate_max(w, 2 * float64(_st->buttonPadding())); + float64 textw = buttonw, minw = _st->minButtonWidth(button.type); + float64 w = textw; + if (exact) { + w += minw; + } else if (enough) { + w = (widthForButtons / float64(s)); + textw = w - minw; + } else { + textw = (widthForText / float64(s)); + w = minw + textw; + accumulate_max(w, 2 * float64(_st->buttonPadding())); + } int rectx = static_cast(std::floor(x)); int rectw = static_cast(std::floor(x + w)) - rectx; @@ -2358,10 +2371,14 @@ void ReplyKeyboard::setStyle(StylePtr &&st) { int ReplyKeyboard::naturalWidth() const { auto result = 0; - for_const (const auto &row, _rows) { + for_const (auto &row, _rows) { + auto maxMinButtonWidth = 0; + for_const (auto &button, row) { + accumulate_max(maxMinButtonWidth, _st->minButtonWidth(button.type)); + } auto rowMaxButtonWidth = 0; - for_const (const auto &button, row) { - accumulate_max(rowMaxButtonWidth, qMax(button.text.maxWidth(), 1) + _st->minButtonWidth(button.type)); + for_const (auto &button, row) { + accumulate_max(rowMaxButtonWidth, qMax(button.text.maxWidth(), 1) + maxMinButtonWidth); } auto rowSize = row.size(); @@ -4894,9 +4911,9 @@ public: protected: void onClickImpl() const override { - if (HistoryMedia *media = _item->getMedia()) { - if (DocumentData *document = media->getDocument()) { - if (StickerData *sticker = document->sticker()) { + if (auto media = _item->getMedia()) { + if (auto document = media->getDocument()) { + if (auto sticker = document->sticker()) { if (sticker->set.type() != mtpc_inputStickerSetEmpty && App::main()) { App::main()->stickersBox(sticker->set); } @@ -4918,13 +4935,15 @@ HistorySticker::HistorySticker(HistoryItem *parent, DocumentData *document) : Hi , _data(document) , _emoji(_data->sticker()->alt) { _data->thumb->load(); - if (EmojiPtr e = emojiFromText(_emoji)) { + if (auto e = emojiFromText(_emoji)) { _emoji = emojiString(e); } } void HistorySticker::initDimensions() { - if (!_packLink && _data->sticker() && _data->sticker()->set.type() != mtpc_inputStickerSetEmpty) { + auto sticker = _data->sticker(); + + if (!_packLink && sticker && sticker->set.type() != mtpc_inputStickerSetEmpty) { _packLink = ClickHandlerPtr(new StickerClickHandler(_parent)); } _pixw = _data->dimensions.width(); @@ -4968,6 +4987,9 @@ int HistorySticker::resizeGetHeight(int width) { // return new height } void HistorySticker::draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const { + auto sticker = _data->sticker(); + if (!sticker) return; + if (_width < st::msgPadding.left() + st::msgPadding.right() + 1) return; _data->checkSticker(); @@ -4989,16 +5011,16 @@ void HistorySticker::draw(Painter &p, const QRect &r, TextSelection selection, u if (rtl()) usex = _width - usex - usew; if (selected) { - if (_data->sticker()->img->isNull()) { + if (sticker->img->isNull()) { p.drawPixmap(QPoint(usex + (usew - _pixw) / 2, (_minh - _pixh) / 2), _data->thumb->pixBlurredColored(st::msgStickerOverlay, _pixw, _pixh)); } else { - p.drawPixmap(QPoint(usex + (usew - _pixw) / 2, (_minh - _pixh) / 2), _data->sticker()->img->pixColored(st::msgStickerOverlay, _pixw, _pixh)); + p.drawPixmap(QPoint(usex + (usew - _pixw) / 2, (_minh - _pixh) / 2), sticker->img->pixColored(st::msgStickerOverlay, _pixw, _pixh)); } } else { - if (_data->sticker()->img->isNull()) { + if (sticker->img->isNull()) { p.drawPixmap(QPoint(usex + (usew - _pixw) / 2, (_minh - _pixh) / 2), _data->thumb->pixBlurred(_pixw, _pixh)); } else { - p.drawPixmap(QPoint(usex + (usew - _pixw) / 2, (_minh - _pixh) / 2), _data->sticker()->img->pix(_pixw, _pixh)); + p.drawPixmap(QPoint(usex + (usew - _pixw) / 2, (_minh - _pixh) / 2), sticker->img->pix(_pixw, _pixh)); } } diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 0b4462b3a..cc0020b74 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -599,6 +599,10 @@ void MainWindow::setupIntro(bool anim) { cSetDialogsReceived(false); if (intro && !intro->isHidden() && !main) return; + if (_mediaView) { + _mediaView->clearData(); + } + QPixmap bg = anim ? grabInner() : QPixmap(); clearWidgets(); diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index 9f3d29fab..17669f57b 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -494,6 +494,28 @@ void MediaView::step_radial(uint64 ms, bool timer) { } } +void MediaView::clearData() { + if (!isHidden()) { + hide(); + } + if (!_animations.isEmpty()) { + _animations.clear(); + _a_state.stop(); + } + if (!_animOpacities.isEmpty()) _animOpacities.clear(); + delete _gif; + _gif = nullptr; + delete _menu; + _menu = nullptr; + _history = _migrated = nullptr; + _peer = _from = nullptr; + _user = nullptr; + _photo = _additionalChatPhoto = nullptr; + _doc = nullptr; + _saveMsgText.clear(); + _caption.clear(); +} + MediaView::~MediaView() { deleteAndMark(_gif); deleteAndMark(_menu); @@ -813,6 +835,7 @@ void MediaView::onCopy() { void MediaView::showPhoto(PhotoData *photo, HistoryItem *context) { _history = context ? context->history() : nullptr; + _migrated = nullptr; if (_history) { if (_history->peer->migrateFrom()) { _migrated = App::history(_history->peer->migrateFrom()->id); @@ -820,8 +843,6 @@ void MediaView::showPhoto(PhotoData *photo, HistoryItem *context) { _migrated = _history; _history = App::history(_history->peer->migrateTo()->id); } - } else { - _migrated = nullptr; } _additionalChatPhoto = nullptr; _firstOpenedPeerPhoto = false; @@ -932,6 +953,7 @@ void MediaView::showPhoto(PhotoData *photo, PeerData *context) { void MediaView::showDocument(DocumentData *doc, HistoryItem *context) { _photo = 0; _history = context ? context->history() : nullptr; + _migrated = nullptr; if (_history) { if (_history->peer->migrateFrom()) { _migrated = App::history(_history->peer->migrateFrom()->id); @@ -939,8 +961,6 @@ void MediaView::showDocument(DocumentData *doc, HistoryItem *context) { _migrated = _history; _history = App::history(_history->peer->migrateTo()->id); } - } else { - _migrated = 0; } _additionalChatPhoto = nullptr; _saveMsgStarted = 0; @@ -1674,7 +1694,7 @@ void MediaView::preloadData(int32 delta) { int indexInOverview = _index; bool indexOfMigratedItem = _msgmigrated; if (_index < 0) { - if (_overview != OverviewChatPhotos) return; + if (_overview != OverviewChatPhotos || !_history) return; indexInOverview = _history->overview[OverviewChatPhotos].size(); indexOfMigratedItem = false; } diff --git a/Telegram/SourceFiles/mediaview.h b/Telegram/SourceFiles/mediaview.h index ae07799ac..89ef007bc 100644 --- a/Telegram/SourceFiles/mediaview.h +++ b/Telegram/SourceFiles/mediaview.h @@ -74,6 +74,8 @@ public: void clipCallback(ClipReaderNotification notification); PeerData *ui_getPeerForMouseAction(); + void clearData(); + ~MediaView(); // ClickHandlerHost interface diff --git a/Telegram/Telegram.xcodeproj/project.pbxproj b/Telegram/Telegram.xcodeproj/project.pbxproj index d7742fd06..449edf2cf 100644 --- a/Telegram/Telegram.xcodeproj/project.pbxproj +++ b/Telegram/Telegram.xcodeproj/project.pbxproj @@ -2375,7 +2375,7 @@ SDKROOT = macosx; SYMROOT = ./../Mac; TDESKTOP_MAJOR_VERSION = 0.9; - TDESKTOP_VERSION = 0.9.55; + TDESKTOP_VERSION = 0.9.56; }; name = Release; }; @@ -2516,7 +2516,7 @@ SDKROOT = macosx; SYMROOT = ./../Mac; TDESKTOP_MAJOR_VERSION = 0.9; - TDESKTOP_VERSION = 0.9.55; + TDESKTOP_VERSION = 0.9.56; }; name = Debug; }; diff --git a/Telegram/build/version b/Telegram/build/version index f0fc1980b..25a0b65be 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,6 +1,6 @@ -AppVersion 9055 +AppVersion 9056 AppVersionStrMajor 0.9 -AppVersionStrSmall 0.9.55 -AppVersionStr 0.9.55 -AlphaChannel 1 +AppVersionStrSmall 0.9.56 +AppVersionStr 0.9.56 +AlphaChannel 0 BetaVersion 0