2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 08:55:59 +00:00

Merge branch 'same_peer_flag' into dev + fix style codegen rule desc.

Conflicts:
	Telegram/Telegram.vcxproj
	Telegram/Telegram.vcxproj.filters
This commit is contained in:
John Preston
2016-08-16 20:12:55 +03:00
23 changed files with 1073 additions and 189 deletions

View File

@@ -689,10 +689,10 @@ void checkForSwitchInlineButton(HistoryItem *item) {
} // namespace
HistoryItem *Histories::addNewMessage(const MTPMessage &msg, NewMessageType type) {
PeerId peer = peerFromMessage(msg);
auto peer = peerFromMessage(msg);
if (!peer) return nullptr;
HistoryItem *result = App::history(peer)->addNewMessage(msg, type);
auto result = App::history(peer)->addNewMessage(msg, type);
if (result && type == NewMessageUnread) {
checkForSwitchInlineButton(result);
}
@@ -2561,9 +2561,14 @@ void HistoryMessageReplyMarkup::createFromButtonRows(const QVector<MTPKeyboardBu
buttonRow.push_back({ Button::Url, qs(buttonData.vtext), qba(buttonData.vurl), 0 });
} break;
case mtpc_keyboardButtonSwitchInline: {
const auto &buttonData(button.c_keyboardButtonSwitchInline());
buttonRow.push_back({ Button::SwitchInline, qs(buttonData.vtext), qba(buttonData.vquery), 0 });
flags |= MTPDreplyKeyboardMarkup_ClientFlag::f_has_switch_inline_button;
auto &buttonData = button.c_keyboardButtonSwitchInline();
auto buttonType = buttonData.is_same_peer() ? Button::SwitchInlineSame : Button::SwitchInline;
buttonRow.push_back({ buttonType, qs(buttonData.vtext), qba(buttonData.vquery), 0 });
if (buttonType == Button::SwitchInline) {
// Optimization flag.
// Fast check on all new messages if there is a switch button to auto-click it.
flags |= MTPDreplyKeyboardMarkup_ClientFlag::f_has_switch_inline_button;
}
} break;
}
}
@@ -6602,6 +6607,7 @@ void HistoryMessage::KeyboardStyle::paintButtonIcon(Painter &p, const QRect &rec
case Button::Url: sprite = st::msgBotKbUrlIcon; break;
// case Button::RequestPhone: sprite = st::msgBotKbRequestPhoneIcon; break;
// case Button::RequestLocation: sprite = st::msgBotKbRequestLocationIcon; break;
case Button::SwitchInlineSame:
case Button::SwitchInline: sprite = st::msgBotKbSwitchPmIcon; break;
}
if (!sprite.isEmpty()) {
@@ -6621,6 +6627,7 @@ int HistoryMessage::KeyboardStyle::minButtonWidth(HistoryMessageReplyMarkup::But
case Button::Url: iconWidth = st::msgBotKbUrlIcon.pxWidth(); break;
//case Button::RequestPhone: iconWidth = st::msgBotKbRequestPhoneIcon.pxWidth(); break;
//case Button::RequestLocation: iconWidth = st::msgBotKbRequestLocationIcon.pxWidth(); break;
case Button::SwitchInlineSame:
case Button::SwitchInline: iconWidth = st::msgBotKbSwitchPmIcon.pxWidth(); break;
case Button::Callback: iconWidth = st::msgInvSendingImg.pxWidth(); break;
}