mirror of https://github.com/procxx/kepka.git
Some bugfixes. Closed beta 9040127.
Crash fix when trying to reply to a bot message which hides the keyboard. Counting button widths better (more padding, use exact width when avail). Hiding inline bot results fixed when switched to emoji before hiding.
This commit is contained in:
parent
460e2ec0ac
commit
418e06052c
|
@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||||
static const int32 AppVersion = 9040;
|
static const int32 AppVersion = 9040;
|
||||||
static const wchar_t *AppVersionStr = L"0.9.40";
|
static const wchar_t *AppVersionStr = L"0.9.40";
|
||||||
static const bool DevVersion = false;
|
static const bool DevVersion = false;
|
||||||
#define BETA_VERSION (9040126ULL) // just comment this line to build public version
|
#define BETA_VERSION (9040127ULL) // 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";
|
||||||
|
|
|
@ -3835,7 +3835,7 @@ int32 EmojiPan::showInlineRows(bool newResults) {
|
||||||
if (clear) {
|
if (clear) {
|
||||||
if (!hidden && hideOnNoInlineResults()) {
|
if (!hidden && hideOnNoInlineResults()) {
|
||||||
hideAnimated();
|
hideAnimated();
|
||||||
} else {
|
} else if (!_hiding) {
|
||||||
_cache = QPixmap(); // clear after refreshInlineRows()
|
_cache = QPixmap(); // clear after refreshInlineRows()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -87,7 +87,17 @@ namespace App {
|
||||||
case HistoryMessageReplyMarkup::Button::SwitchInline: {
|
case HistoryMessageReplyMarkup::Button::SwitchInline: {
|
||||||
if (MainWidget *m = App::main()) {
|
if (MainWidget *m = App::main()) {
|
||||||
if (UserData *bot = msg->history()->peer->asUser()) {
|
if (UserData *bot = msg->history()->peer->asUser()) {
|
||||||
m->inlineSwitchLayer('@' + bot->username + ' ' + QString::fromUtf8(button->data));
|
auto tryFastSwitch = [bot, &button]() -> bool {
|
||||||
|
if (bot->botInfo && bot->botInfo->inlineReturnPeerId) {
|
||||||
|
if (Notify::switchInlineBotButtonReceived(QString::fromUtf8(button->data))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
if (!tryFastSwitch()) {
|
||||||
|
m->inlineSwitchLayer('@' + bot->username + ' ' + QString::fromUtf8(button->data));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -280,10 +290,11 @@ namespace Notify {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchInlineBotButtonReceived(const QString &query) {
|
bool switchInlineBotButtonReceived(const QString &query) {
|
||||||
if (MainWidget *m = App::main()) {
|
if (MainWidget *m = App::main()) {
|
||||||
m->notify_switchInlineBotButtonReceived(query);
|
return m->notify_switchInlineBotButtonReceived(query);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void migrateUpdated(PeerData *peer) {
|
void migrateUpdated(PeerData *peer) {
|
||||||
|
|
|
@ -104,7 +104,7 @@ namespace Notify {
|
||||||
void inlineBotRequesting(bool requesting);
|
void inlineBotRequesting(bool requesting);
|
||||||
void replyMarkupUpdated(const HistoryItem *item);
|
void replyMarkupUpdated(const HistoryItem *item);
|
||||||
void inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop);
|
void inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop);
|
||||||
void switchInlineBotButtonReceived(const QString &query);
|
bool switchInlineBotButtonReceived(const QString &query);
|
||||||
|
|
||||||
void migrateUpdated(PeerData *peer);
|
void migrateUpdated(PeerData *peer);
|
||||||
|
|
||||||
|
|
|
@ -2574,16 +2574,20 @@ void ReplyKeyboard::resize(int width, int height) {
|
||||||
for (ButtonRow &row : _rows) {
|
for (ButtonRow &row : _rows) {
|
||||||
int s = row.size();
|
int s = row.size();
|
||||||
|
|
||||||
float64 widthForText = _width - ((s - 1) * _st->buttonSkip() + s * 2 * _st->buttonPadding()), widthOfText = 0.;
|
int widthForText = _width - ((s - 1) * _st->buttonSkip());
|
||||||
|
int widthOfText = 0;
|
||||||
for_const (const Button &button, row) {
|
for_const (const Button &button, row) {
|
||||||
widthOfText += qMax(button.text.maxWidth(), 1);
|
widthOfText += qMax(button.text.maxWidth(), 1);
|
||||||
|
widthForText -= _st->minButtonWidth(button.type);
|
||||||
}
|
}
|
||||||
|
bool exact = (widthForText == widthOfText);
|
||||||
|
|
||||||
float64 x = 0, coef = widthForText / widthOfText;
|
float64 x = 0;
|
||||||
for (Button &button : row) {
|
for (Button &button : row) {
|
||||||
float64 tw = widthForText / float64(s), w = 2 * _st->buttonPadding() + tw;
|
int buttonw = qMax(button.text.maxWidth(), 1);
|
||||||
|
float64 textw = exact ? buttonw : (widthForText / float64(s));
|
||||||
float64 minw = _st->minButtonWidth(button.type);
|
float64 minw = _st->minButtonWidth(button.type);
|
||||||
if (w < minw) w = minw;
|
float64 w = minw + qMax(textw, 0.);
|
||||||
|
|
||||||
int rectx = static_cast<int>(std::floor(x));
|
int rectx = static_cast<int>(std::floor(x));
|
||||||
int rectw = static_cast<int>(std::floor(x + w)) - rectx;
|
int rectw = static_cast<int>(std::floor(x + w)) - rectx;
|
||||||
|
@ -2591,7 +2595,7 @@ void ReplyKeyboard::resize(int width, int height) {
|
||||||
if (rtl()) button.rect.setX(_width - button.rect.x() - button.rect.width());
|
if (rtl()) button.rect.setX(_width - button.rect.x() - button.rect.width());
|
||||||
x += w + _st->buttonSkip();
|
x += w + _st->buttonSkip();
|
||||||
|
|
||||||
button.link->setFullDisplayed(tw >= button.text.maxWidth());
|
button.link->setFullDisplayed(textw >= buttonw);
|
||||||
}
|
}
|
||||||
y += buttonHeight;
|
y += buttonHeight;
|
||||||
}
|
}
|
||||||
|
@ -2625,9 +2629,9 @@ int ReplyKeyboard::naturalWidth() const {
|
||||||
auto markup = _item->Get<HistoryMessageReplyMarkup>();
|
auto markup = _item->Get<HistoryMessageReplyMarkup>();
|
||||||
for_const (const ButtonRow &row, _rows) {
|
for_const (const ButtonRow &row, _rows) {
|
||||||
int rowSize = row.size();
|
int rowSize = row.size();
|
||||||
int rowWidth = (rowSize - 1) * _st->buttonSkip() + rowSize * 2 * _st->buttonPadding();
|
int rowWidth = (rowSize - 1) * _st->buttonSkip();
|
||||||
for_const(const Button &button, row) {
|
for_const (const Button &button, row) {
|
||||||
rowWidth += qMax(button.text.maxWidth(), 1);
|
rowWidth += qMax(button.text.maxWidth(), 1) + _st->minButtonWidth(button.type);
|
||||||
}
|
}
|
||||||
if (rowWidth > result) {
|
if (rowWidth > result) {
|
||||||
result = rowWidth;
|
result = rowWidth;
|
||||||
|
@ -2753,7 +2757,7 @@ void ReplyKeyboard::Style::paintButton(Painter &p, const ReplyKeyboard::Button &
|
||||||
}
|
}
|
||||||
|
|
||||||
int tx = rect.x(), tw = rect.width();
|
int tx = rect.x(), tw = rect.width();
|
||||||
if (tw > st::botKbFont->elidew + _st->padding * 2) {
|
if (tw >= st::botKbFont->elidew + _st->padding * 2) {
|
||||||
tx += _st->padding;
|
tx += _st->padding;
|
||||||
tw -= _st->padding * 2;
|
tw -= _st->padding * 2;
|
||||||
} else if (tw > st::botKbFont->elidew) {
|
} else if (tw > st::botKbFont->elidew) {
|
||||||
|
@ -6510,7 +6514,7 @@ int HistoryMessage::KeyboardStyle::minButtonWidth(HistoryMessageReplyMarkup::But
|
||||||
case Button::Callback: iconWidth = st::msgInvSendingImg.pxWidth(); break;
|
case Button::Callback: iconWidth = st::msgInvSendingImg.pxWidth(); break;
|
||||||
}
|
}
|
||||||
if (iconWidth > 0) {
|
if (iconWidth > 0) {
|
||||||
result = std::min(result, iconWidth + 2 * int(st::msgBotKbIconPadding));
|
result = std::max(result, 2 * iconWidth + 4 * int(st::msgBotKbIconPadding));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2265,12 +2265,17 @@ bool BotKeyboard::updateMarkup(HistoryItem *to, bool force) {
|
||||||
_wasForMsgId = FullMsgId(to->channelId(), to->id);
|
_wasForMsgId = FullMsgId(to->channelId(), to->id);
|
||||||
clearSelection();
|
clearSelection();
|
||||||
|
|
||||||
auto markup = to->Get<HistoryMessageReplyMarkup>();
|
auto markupFlags = to->replyKeyboardFlags();
|
||||||
_forceReply = markup->flags & MTPDreplyKeyboardMarkup_ClientFlag::f_force_reply;
|
_forceReply = markupFlags & MTPDreplyKeyboardMarkup_ClientFlag::f_force_reply;
|
||||||
_maximizeSize = !(markup->flags & MTPDreplyKeyboardMarkup::Flag::f_resize);
|
_maximizeSize = !(markupFlags & MTPDreplyKeyboardMarkup::Flag::f_resize);
|
||||||
_singleUse = _forceReply || (markup->flags & MTPDreplyKeyboardMarkup::Flag::f_single_use);
|
_singleUse = _forceReply || (markupFlags & MTPDreplyKeyboardMarkup::Flag::f_single_use);
|
||||||
|
|
||||||
_impl.reset(markup->rows.isEmpty() ? nullptr : new ReplyKeyboard(to, std_::make_unique<Style>(this, *_st)));
|
_impl = nullptr;
|
||||||
|
if (auto markup = to->Get<HistoryMessageReplyMarkup>()) {
|
||||||
|
if (!markup->rows.isEmpty()) {
|
||||||
|
_impl.reset(new ReplyKeyboard(to, std_::make_unique<Style>(this, *_st)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateStyle();
|
updateStyle();
|
||||||
_height = st::botKbScroll.deltat + st::botKbScroll.deltab + (_impl ? _impl->naturalHeight() : 0);
|
_height = st::botKbScroll.deltat + st::botKbScroll.deltab + (_impl ? _impl->naturalHeight() : 0);
|
||||||
|
@ -3229,23 +3234,24 @@ void HistoryWidget::notify_inlineKeyboardMoved(const HistoryItem *item, int oldK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query) {
|
bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query) {
|
||||||
if (!_peer) {
|
if (UserData *bot = _peer ? _peer->asUser() : nullptr) {
|
||||||
return;
|
PeerId toPeerId = bot->botInfo ? bot->botInfo->inlineReturnPeerId : 0;
|
||||||
}
|
if (!toPeerId) {
|
||||||
if (UserData *bot = _peer->asUser()) {
|
return false;
|
||||||
if (!bot->botInfo || !bot->botInfo->inlineReturnPeerId) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
History *h = App::history(bot->botInfo->inlineReturnPeerId);
|
bot->botInfo->inlineReturnPeerId = 0;
|
||||||
|
History *h = App::history(toPeerId);
|
||||||
auto text = '@' + bot->username + ' ' + query;
|
auto text = '@' + bot->username + ' ' + query;
|
||||||
h->setMsgDraft(std_::make_unique<HistoryDraft>(text, 0, MessageCursor(text.size(), text.size(), QFIXED_MAX), false));
|
h->setMsgDraft(std_::make_unique<HistoryDraft>(text, 0, MessageCursor(text.size(), text.size(), QFIXED_MAX), false));
|
||||||
if (h == _history) {
|
if (h == _history) {
|
||||||
applyDraft();
|
applyDraft();
|
||||||
} else {
|
} else {
|
||||||
Ui::showPeerHistory(bot->botInfo->inlineReturnPeerId, ShowAtUnreadMsgId);
|
Ui::showPeerHistory(toPeerId, ShowAtUnreadMsgId);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::notify_userIsBotChanged(UserData *user) {
|
void HistoryWidget::notify_userIsBotChanged(UserData *user) {
|
||||||
|
|
|
@ -685,7 +685,7 @@ public:
|
||||||
void notify_inlineBotRequesting(bool requesting);
|
void notify_inlineBotRequesting(bool requesting);
|
||||||
void notify_replyMarkupUpdated(const HistoryItem *item);
|
void notify_replyMarkupUpdated(const HistoryItem *item);
|
||||||
void notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop);
|
void notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop);
|
||||||
void notify_switchInlineBotButtonReceived(const QString &query);
|
bool notify_switchInlineBotButtonReceived(const QString &query);
|
||||||
void notify_userIsBotChanged(UserData *user);
|
void notify_userIsBotChanged(UserData *user);
|
||||||
void notify_migrateUpdated(PeerData *peer);
|
void notify_migrateUpdated(PeerData *peer);
|
||||||
void notify_clipStopperHidden(ClipStopperType type);
|
void notify_clipStopperHidden(ClipStopperType type);
|
||||||
|
|
|
@ -780,8 +780,8 @@ void MainWidget::notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyb
|
||||||
history.notify_inlineKeyboardMoved(item, oldKeyboardTop, newKeyboardTop);
|
history.notify_inlineKeyboardMoved(item, oldKeyboardTop, newKeyboardTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::notify_switchInlineBotButtonReceived(const QString &query) {
|
bool MainWidget::notify_switchInlineBotButtonReceived(const QString &query) {
|
||||||
history.notify_switchInlineBotButtonReceived(query);
|
return history.notify_switchInlineBotButtonReceived(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::notify_userIsBotChanged(UserData *bot) {
|
void MainWidget::notify_userIsBotChanged(UserData *bot) {
|
||||||
|
|
|
@ -459,7 +459,7 @@ public:
|
||||||
void notify_inlineBotRequesting(bool requesting);
|
void notify_inlineBotRequesting(bool requesting);
|
||||||
void notify_replyMarkupUpdated(const HistoryItem *item);
|
void notify_replyMarkupUpdated(const HistoryItem *item);
|
||||||
void notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop);
|
void notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop);
|
||||||
void notify_switchInlineBotButtonReceived(const QString &query);
|
bool notify_switchInlineBotButtonReceived(const QString &query);
|
||||||
void notify_userIsBotChanged(UserData *bot);
|
void notify_userIsBotChanged(UserData *bot);
|
||||||
void notify_userIsContactChanged(UserData *user, bool fromThisApp);
|
void notify_userIsContactChanged(UserData *user, bool fromThisApp);
|
||||||
void notify_migrateUpdated(PeerData *peer);
|
void notify_migrateUpdated(PeerData *peer);
|
||||||
|
|
|
@ -34,8 +34,8 @@ IDI_ICON1 ICON "Resources\\art\\icon256.ico"
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 0,9,40,126
|
FILEVERSION 0,9,40,127
|
||||||
PRODUCTVERSION 0,9,40,126
|
PRODUCTVERSION 0,9,40,127
|
||||||
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.40.126"
|
VALUE "FileVersion", "0.9.40.127"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2014-2016"
|
VALUE "LegalCopyright", "Copyright (C) 2014-2016"
|
||||||
VALUE "ProductName", "Telegram Desktop"
|
VALUE "ProductName", "Telegram Desktop"
|
||||||
VALUE "ProductVersion", "0.9.40.126"
|
VALUE "ProductVersion", "0.9.40.127"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -3,4 +3,4 @@ AppVersionStrMajor 0.9
|
||||||
AppVersionStrSmall 0.9.40
|
AppVersionStrSmall 0.9.40
|
||||||
AppVersionStr 0.9.40
|
AppVersionStr 0.9.40
|
||||||
DevChannel 0
|
DevChannel 0
|
||||||
BetaVersion 9040126
|
BetaVersion 9040127
|
||||||
|
|
Loading…
Reference in New Issue