stable version 0.9.16 - new design of media, gifs and inline bots

This commit is contained in:
John Preston 2016-01-04 19:13:25 +08:00
parent 839ce20b88
commit b201a5a975
10 changed files with 64 additions and 39 deletions

View File

@ -708,7 +708,7 @@ void Application::checkMapVersion() {
if (cDevVersion() && Local::oldMapVersion() < 9016) { if (cDevVersion() && Local::oldMapVersion() < 9016) {
// versionFeatures = QString::fromUtf8("\xe2\x80\x94 Sticker management: manually rearrange your sticker packs, pack order is now synced across all your devices\n\xe2\x80\x94 Click and hold on a sticker to preview it before sending\n\xe2\x80\x94 New context menu for chats in chats list\n\xe2\x80\x94 Support for all existing emoji");// .replace('@', qsl("@") + QChar(0x200D)); // versionFeatures = QString::fromUtf8("\xe2\x80\x94 Sticker management: manually rearrange your sticker packs, pack order is now synced across all your devices\n\xe2\x80\x94 Click and hold on a sticker to preview it before sending\n\xe2\x80\x94 New context menu for chats in chats list\n\xe2\x80\x94 Support for all existing emoji");// .replace('@', qsl("@") + QChar(0x200D));
versionFeatures = lng_new_version_text(lt_gifs_link, qsl("https://telegram.org/blog/gif-revolution"), lt_bots_link, qsl("https://telegram.org/blog/inline-bots")).trimmed(); versionFeatures = lng_new_version_text(lt_gifs_link, qsl("https://telegram.org/blog/gif-revolution"), lt_bots_link, qsl("https://telegram.org/blog/inline-bots")).trimmed();
} else if (Local::oldMapVersion() < 9015) { } else if (Local::oldMapVersion() < 9016) {
versionFeatures = lng_new_version_text(lt_gifs_link, qsl("https://telegram.org/blog/gif-revolution"), lt_bots_link, qsl("https://telegram.org/blog/inline-bots")).trimmed(); versionFeatures = lng_new_version_text(lt_gifs_link, qsl("https://telegram.org/blog/gif-revolution"), lt_bots_link, qsl("https://telegram.org/blog/inline-bots")).trimmed();
} else { } else {
versionFeatures = lang(lng_new_version_minor).trimmed(); versionFeatures = lang(lng_new_version_minor).trimmed();

View File

@ -20,10 +20,10 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
*/ */
#pragma once #pragma once
static const int32 AppVersion = 9015; static const int32 AppVersion = 9016;
static const wchar_t *AppVersionStr = L"0.9.15"; static const wchar_t *AppVersionStr = L"0.9.16";
static const bool DevVersion = false; static const bool DevVersion = false;
#define BETA_VERSION (9015008ULL) // just comment this line to build public version //#define BETA_VERSION (9015008ULL) // just comment this line to build public version
static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)"; static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)";
static const wchar_t *AppName = L"Telegram Desktop"; static const wchar_t *AppName = L"Telegram Desktop";

View File

@ -1663,14 +1663,14 @@ void StickerPanInner::refreshStickers() {
updateSelected(); updateSelected();
} }
void StickerPanInner::inlineRowsAddItem(DocumentData *savedGif, InlineResult *result, InlineRow &row, int32 &sumWidth) { bool StickerPanInner::inlineRowsAddItem(DocumentData *savedGif, InlineResult *result, InlineRow &row, int32 &sumWidth) {
LayoutInlineItem *layout = 0; LayoutInlineItem *layout = 0;
if (savedGif) { if (savedGif) {
layout = layoutPrepareSavedGif(savedGif, (_inlineRows.size() * MatrixRowShift) + row.items.size()); layout = layoutPrepareSavedGif(savedGif, (_inlineRows.size() * MatrixRowShift) + row.items.size());
} else if (result) { } else if (result) {
layout = layoutPrepareInlineResult(result, (_inlineRows.size() * MatrixRowShift) + row.items.size()); layout = layoutPrepareInlineResult(result, (_inlineRows.size() * MatrixRowShift) + row.items.size());
} }
if (!layout) return; if (!layout) return false;
layout->preload(); layout->preload();
if (inlineRowFinalize(row, sumWidth, layout->fullLine())) { if (inlineRowFinalize(row, sumWidth, layout->fullLine())) {
@ -1678,6 +1678,7 @@ void StickerPanInner::inlineRowsAddItem(DocumentData *savedGif, InlineResult *re
} }
row.items.push_back(layout); row.items.push_back(layout);
sumWidth += layout->maxWidth(); sumWidth += layout->maxWidth();
return true;
} }
bool StickerPanInner::inlineRowFinalize(InlineRow &row, int32 &sumWidth, bool force) { bool StickerPanInner::inlineRowFinalize(InlineRow &row, int32 &sumWidth, bool force) {
@ -1770,7 +1771,7 @@ LayoutInlineItem *StickerPanInner::layoutPrepareInlineResult(InlineResult *resul
layout = new LayoutInlineGif(result, 0, false); layout = new LayoutInlineGif(result, 0, false);
} else if (result->type == qstr("photo")) { } else if (result->type == qstr("photo")) {
layout = new LayoutInlinePhoto(result, 0); layout = new LayoutInlinePhoto(result, 0);
} else if (result->type == qstr("web_player_video")) { } else if (result->type == qstr("video")) {
layout = new LayoutInlineWebVideo(result); layout = new LayoutInlineWebVideo(result);
} else if (result->type == qstr("article")) { } else if (result->type == qstr("article")) {
layout = new LayoutInlineArticle(result, _inlineWithThumb); layout = new LayoutInlineArticle(result, _inlineWithThumb);
@ -1901,14 +1902,14 @@ void StickerPanInner::clearInlineRowsPanel() {
clearInlineRows(false); clearInlineRows(false);
} }
void StickerPanInner::refreshInlineRows(UserData *bot, const InlineResults &results, bool resultsDeleted) { int32 StickerPanInner::refreshInlineRows(UserData *bot, const InlineResults &results, bool resultsDeleted) {
_inlineBot = bot; _inlineBot = bot;
if (results.isEmpty() && (!_inlineBot || _inlineBot->username != cInlineGifBotUsername())) { if (results.isEmpty() && (!_inlineBot || _inlineBot->username != cInlineGifBotUsername())) {
if (resultsDeleted) { if (resultsDeleted) {
clearInlineRows(true); clearInlineRows(true);
} }
emit emptyInlineRows(); emit emptyInlineRows();
return; return 0;
} }
if (_showingInlineItems) { if (_showingInlineItems) {
@ -1921,7 +1922,7 @@ void StickerPanInner::refreshInlineRows(UserData *bot, const InlineResults &resu
_showingInlineItems = true; _showingInlineItems = true;
_showingSavedGifs = false; _showingSavedGifs = false;
int32 count = results.size(), from = validateExistingInlineRows(results); int32 count = results.size(), from = validateExistingInlineRows(results), added = 0;
if (count) { if (count) {
_inlineRows.reserve(count); _inlineRows.reserve(count);
@ -1929,7 +1930,9 @@ void StickerPanInner::refreshInlineRows(UserData *bot, const InlineResults &resu
row.items.reserve(SavedGifsMaxPerRow); row.items.reserve(SavedGifsMaxPerRow);
int32 sumWidth = 0; int32 sumWidth = 0;
for (int32 i = from; i < count; ++i) { for (int32 i = from; i < count; ++i) {
inlineRowsAddItem(0, results.at(i), row, sumWidth); if (inlineRowsAddItem(0, results.at(i), row, sumWidth)) {
++added;
}
} }
inlineRowFinalize(row, sumWidth, true); inlineRowFinalize(row, sumWidth, true);
} }
@ -1943,6 +1946,8 @@ void StickerPanInner::refreshInlineRows(UserData *bot, const InlineResults &resu
_lastMousePos = QCursor::pos(); _lastMousePos = QCursor::pos();
updateSelected(); updateSelected();
} }
return added;
} }
int32 StickerPanInner::validateExistingInlineRows(const InlineResults &results) { int32 StickerPanInner::validateExistingInlineRows(const InlineResults &results) {
@ -3722,7 +3727,10 @@ void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
} else if (adding) { } else if (adding) {
it.value()->nextOffset = QString(); it.value()->nextOffset = QString();
} }
showInlineRows(!adding);
if (!showInlineRows(!adding)) {
it.value()->nextOffset = QString();
}
onScroll(); onScroll();
} }
@ -3782,7 +3790,7 @@ void EmojiPan::onEmptyInlineRows() {
} }
} }
bool EmojiPan::refreshInlineRows() { bool EmojiPan::refreshInlineRows(int32 *added) {
bool clear = true; bool clear = true;
InlineCache::const_iterator i = _inlineCache.constFind(_inlineQuery); InlineCache::const_iterator i = _inlineCache.constFind(_inlineQuery);
if (i != _inlineCache.cend()) { if (i != _inlineCache.cend()) {
@ -3790,12 +3798,14 @@ bool EmojiPan::refreshInlineRows() {
_inlineNextOffset = i.value()->nextOffset; _inlineNextOffset = i.value()->nextOffset;
} }
if (clear) prepareShowHideCache(); if (clear) prepareShowHideCache();
s_inner.refreshInlineRows(_inlineBot, clear ? InlineResults() : i.value()->results, false); int32 result = s_inner.refreshInlineRows(_inlineBot, clear ? InlineResults() : i.value()->results, false);
if (added) *added = result;
return !clear; return !clear;
} }
void EmojiPan::showInlineRows(bool newResults) { int32 EmojiPan::showInlineRows(bool newResults) {
bool clear = !refreshInlineRows(); int32 added = 0;
bool clear = !refreshInlineRows(&added);
if (newResults) s_scroll.scrollToY(0); if (newResults) s_scroll.scrollToY(0);
e_switch.updateText(clear ? QString() : _inlineBot->username); e_switch.updateText(clear ? QString() : _inlineBot->username);
@ -3819,6 +3829,8 @@ void EmojiPan::showInlineRows(bool newResults) {
onSwitch(); onSwitch();
} }
} }
return added;
} }
void EmojiPan::recountContentMaxHeight() { void EmojiPan::recountContentMaxHeight() {

View File

@ -344,7 +344,7 @@ public:
void refreshStickers(); void refreshStickers();
void refreshRecentStickers(bool resize = true); void refreshRecentStickers(bool resize = true);
void refreshSavedGifs(); void refreshSavedGifs();
void refreshInlineRows(UserData *bot, const InlineResults &results, bool resultsDeleted); int32 refreshInlineRows(UserData *bot, const InlineResults &results, bool resultsDeleted);
void refreshRecent(); void refreshRecent();
void inlineBotChanged(); void inlineBotChanged();
void hideInlineRowsPanel(); void hideInlineRowsPanel();
@ -458,7 +458,7 @@ private:
InlineLayouts _inlineLayouts; InlineLayouts _inlineLayouts;
LayoutInlineItem *layoutPrepareInlineResult(InlineResult *result, int32 position); LayoutInlineItem *layoutPrepareInlineResult(InlineResult *result, int32 position);
void inlineRowsAddItem(DocumentData *savedGif, InlineResult *result, InlineRow &row, int32 &sumWidth); bool inlineRowsAddItem(DocumentData *savedGif, InlineResult *result, InlineRow &row, int32 &sumWidth);
bool inlineRowFinalize(InlineRow &row, int32 &sumWidth, bool force = false); bool inlineRowFinalize(InlineRow &row, int32 &sumWidth, bool force = false);
InlineRow &layoutInlineRow(InlineRow &row, int32 sumWidth = 0); InlineRow &layoutInlineRow(InlineRow &row, int32 sumWidth = 0);
@ -712,10 +712,10 @@ private:
QTimer _inlineRequestTimer; QTimer _inlineRequestTimer;
void inlineBotChanged(); void inlineBotChanged();
void showInlineRows(bool newResults); int32 showInlineRows(bool newResults);
bool hideOnNoInlineResults(); bool hideOnNoInlineResults();
void recountContentMaxHeight(); void recountContentMaxHeight();
bool refreshInlineRows(); bool refreshInlineRows(int32 *added = 0);
UserData *_inlineBot; UserData *_inlineBot;
QString _inlineQuery, _inlineNextQuery, _inlineNextOffset; QString _inlineQuery, _inlineNextQuery, _inlineNextOffset;
mtpRequestId _inlineRequestId; mtpRequestId _inlineRequestId;

View File

@ -1847,6 +1847,7 @@ void LayoutInlinePhoto::content_forget() {
LayoutInlineWebVideo::LayoutInlineWebVideo(InlineResult *result) : LayoutInlineItem(result, 0, 0) LayoutInlineWebVideo::LayoutInlineWebVideo(InlineResult *result) : LayoutInlineItem(result, 0, 0)
, _send(new SendInlineItemLink()) , _send(new SendInlineItemLink())
, _link(result->content_url.isEmpty() ? 0 : linkFromUrl(result->content_url))
, _title(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) , _title(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip)
, _description(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) { , _description(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) {
if (_result->duration) { if (_result->duration) {
@ -1904,8 +1905,13 @@ void LayoutInlineWebVideo::paint(Painter &p, const QRect &clip, uint32 selection
} }
void LayoutInlineWebVideo::getState(TextLinkPtr &link, HistoryCursorState &cursor, int32 x, int32 y) const { void LayoutInlineWebVideo::getState(TextLinkPtr &link, HistoryCursorState &cursor, int32 x, int32 y) const {
if (x >= 0 && x < _width && y >= 0 && y < _height) { if (x >= 0 && x < st::inlineThumbSize && y >= st::inlineRowMargin && y < st::inlineRowMargin + st::inlineThumbSize) {
link = _link;
return;
}
if (x >= st::inlineThumbSize + st::inlineThumbSkip && x < _width && y >= 0 && y < _height) {
link = _send; link = _send;
return;
} }
} }
@ -1934,6 +1940,7 @@ void LayoutInlineWebVideo::prepareThumb(int32 width, int32 height) const {
LayoutInlineArticle::LayoutInlineArticle(InlineResult *result, bool withThumb) : LayoutInlineItem(result, 0, 0) LayoutInlineArticle::LayoutInlineArticle(InlineResult *result, bool withThumb) : LayoutInlineItem(result, 0, 0)
, _send(new SendInlineItemLink()) , _send(new SendInlineItemLink())
, _url(result->url.isEmpty() ? 0 : linkFromUrl(result->url)) , _url(result->url.isEmpty() ? 0 : linkFromUrl(result->url))
, _link(result->content_url.isEmpty() ? 0 : linkFromUrl(result->content_url))
, _withThumb(withThumb) , _withThumb(withThumb)
, _title(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) , _title(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip)
, _description(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) { , _description(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) {
@ -2033,7 +2040,12 @@ void LayoutInlineArticle::paint(Painter &p, const QRect &clip, uint32 selection,
} }
void LayoutInlineArticle::getState(TextLinkPtr &link, HistoryCursorState &cursor, int32 x, int32 y) const { void LayoutInlineArticle::getState(TextLinkPtr &link, HistoryCursorState &cursor, int32 x, int32 y) const {
if (x >= 0 && x < _width && y >= 0 && y < _height) { int32 left = _withThumb ? (st::inlineThumbSize + st::inlineThumbSkip) : 0;
if (x >= 0 && x < left - st::inlineThumbSkip && y >= st::inlineRowMargin && y < st::inlineRowMargin + st::inlineThumbSize) {
link = _link;
return;
}
if (x >= left && x < _width && y >= 0 && y < _height) {
if (_url) { if (_url) {
int32 left = st::inlineThumbSize + st::inlineThumbSkip; int32 left = st::inlineThumbSize + st::inlineThumbSkip;
int32 titleHeight = qMin(_title.countHeight(_width - left), st::semiboldFont->height * 2); int32 titleHeight = qMin(_title.countHeight(_width - left), st::semiboldFont->height * 2);
@ -2045,6 +2057,7 @@ void LayoutInlineArticle::getState(TextLinkPtr &link, HistoryCursorState &cursor
} }
} }
link = _send; link = _send;
return;
} }
} }

View File

@ -666,7 +666,7 @@ public:
private: private:
TextLinkPtr _send; TextLinkPtr _send, _link;
mutable QPixmap _thumb; mutable QPixmap _thumb;
Text _title, _description; Text _title, _description;
@ -689,7 +689,7 @@ public:
private: private:
TextLinkPtr _send, _url; TextLinkPtr _send, _url, _link;
bool _withThumb; bool _withThumb;
mutable QPixmap _thumb; mutable QPixmap _thumb;

View File

@ -11,7 +11,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.9.15</string> <string>0.9.16</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>

View File

@ -34,8 +34,8 @@ IDI_ICON1 ICON "SourceFiles\\art\\icon256.ico"
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,9,15,8 FILEVERSION 0,9,16,0
PRODUCTVERSION 0,9,15,8 PRODUCTVERSION 0,9,16,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -51,10 +51,10 @@ BEGIN
BLOCK "040904b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "CompanyName", "Telegram Messenger LLP" VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileVersion", "0.9.15.8" VALUE "FileVersion", "0.9.16.0"
VALUE "LegalCopyright", "Copyright (C) 2013" VALUE "LegalCopyright", "Copyright (C) 2013"
VALUE "ProductName", "Telegram Desktop" VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.9.15.8" VALUE "ProductVersion", "0.9.16.0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -1701,7 +1701,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.9.15; CURRENT_PROJECT_VERSION = 0.9.16;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
@ -1720,7 +1720,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 0.9.15; CURRENT_PROJECT_VERSION = 0.9.16;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_OPTIMIZATION_LEVEL = fast; GCC_OPTIMIZATION_LEVEL = fast;
GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h; GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h;
@ -1747,10 +1747,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.9.15; CURRENT_PROJECT_VERSION = 0.9.16;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DYLIB_COMPATIBILITY_VERSION = 0.9; DYLIB_COMPATIBILITY_VERSION = 0.9;
DYLIB_CURRENT_VERSION = 0.9.15; DYLIB_CURRENT_VERSION = 0.9.16;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = ""; FRAMEWORK_SEARCH_PATHS = "";
GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
@ -1882,10 +1882,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.9.15; CURRENT_PROJECT_VERSION = 0.9.16;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 0.9; DYLIB_COMPATIBILITY_VERSION = 0.9;
DYLIB_CURRENT_VERSION = 0.9.15; DYLIB_CURRENT_VERSION = 0.9.16;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
FRAMEWORK_SEARCH_PATHS = ""; FRAMEWORK_SEARCH_PATHS = "";

View File

@ -1,6 +1,6 @@
AppVersion 9015 AppVersion 9016
AppVersionStrMajor 0.9 AppVersionStrMajor 0.9
AppVersionStrSmall 0.9.15 AppVersionStrSmall 0.9.16
AppVersionStr 0.9.15 AppVersionStr 0.9.16
DevChannel 0 DevChannel 0
BetaVersion 9015008 BetaVersion 0 9015008