0.9.56 stable. Crash fixed in MediaView after logout and login again.

Buttons layout improved in bot inline keyboard.
This commit is contained in:
John Preston 2016-06-26 18:37:47 +03:00
parent 7ec2c833f2
commit a89185565a
10 changed files with 89 additions and 41 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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();

View File

@ -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;

View File

@ -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<int>(std::floor(x));
int rectw = static_cast<int>(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));
}
}

View File

@ -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();

View File

@ -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;
}

View File

@ -74,6 +74,8 @@ public:
void clipCallback(ClipReaderNotification notification);
PeerData *ui_getPeerForMouseAction();
void clearData();
~MediaView();
// ClickHandlerHost interface

View File

@ -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;
};

View File

@ -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