Not inline bot keyboard now supports editing as well.

Styles improved for not inline bot keyboard.
Full crash string adding to crash report.
Preparing to leave source code without #include "stdafx.h"
This commit is contained in:
John Preston 2016-04-01 19:32:26 +04:00
parent 0e0956451a
commit 1ef944ed7b
13 changed files with 64 additions and 32 deletions

View File

@ -2114,17 +2114,17 @@ verifiedCheckInv: sprite(299px, 221px, 14px, 14px);
verifiedCheckPos: point(4px, 2px);
botKbDuration: 200;
botKbBg: #f7f7f7;
botKbOverBg: #e8ecef;
botKbDownBg: #dfe3e6;
botKbColor: #8a8a8f;
botKbFont: font(16px);
botKbBg: #edf1f5;
botKbOverBg: #d8e2ec;
botKbDownBg: #d8e2ec;
botKbColor: #4b565f;
botKbFont: font(15px semibold);
botKbButton: botKeyboardButton {
margin: 10px;
padding: 10px;
height: 36px;
textTop: 8px;
downTextTop: 9px;
height: 38px;
textTop: 9px;
downTextTop: 10px;
}
botKbTinyButton: botKeyboardButton {
margin: 4px;

View File

@ -244,6 +244,12 @@ namespace Notify {
if (MainWidget *m = App::main()) m->notify_inlineBotRequesting(requesting);
}
void replyMarkupUpdated(const HistoryItem *item) {
if (MainWidget *m = App::main()) {
m->notify_replyMarkupUpdated(item);
}
}
void migrateUpdated(PeerData *peer) {
if (MainWidget *m = App::main()) m->notify_migrateUpdated(peer);
}

View File

@ -94,6 +94,7 @@ namespace Notify {
void botCommandsChanged(UserData *user);
void inlineBotRequesting(bool requesting);
void replyMarkupUpdated(const HistoryItem *item);
void migrateUpdated(PeerData *peer);

View File

@ -3574,7 +3574,7 @@ TextBlock::TextBlock(const style::font &font, const QString &str, QFixed minResi
bool logCrashString = (rand_value<uchar>() % 4 == 1);
if (logCrashString) {
SignalHandlers::setCrashAnnotationRef("CrashString", &part);
SignalHandlers::setCrashAnnotationRef("CrashString", &str);
}
BlockParser parser(&engine, this, minResizeWidth, _from, part);
if (logCrashString) {

View File

@ -3533,7 +3533,6 @@ HistoryPhoto::HistoryPhoto(PhotoData *photo, const QString &caption, const Histo
, _data(photo)
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
setLinks(MakeShared<PhotoOpenClickHandler>(_data), MakeShared<PhotoSaveClickHandler>(_data), MakeShared<PhotoCancelClickHandler>(_data));
if (!caption.isEmpty()) {
_caption.setText(st::msgFont, caption + parent->skipBlock(), itemTextNoMonoOptions(parent));
}
@ -7058,6 +7057,8 @@ void HistoryMessage::setReplyMarkup(const MTPReplyMarkup *markup) {
if (Has<HistoryMessageReplyMarkup>()) {
RemoveComponents(HistoryMessageReplyMarkup::Bit());
setPendingInitDimensions();
Notify::replyMarkupUpdated(this);
}
} else {
if (!Has<HistoryMessageReplyMarkup>()) {
@ -7065,6 +7066,8 @@ void HistoryMessage::setReplyMarkup(const MTPReplyMarkup *markup) {
}
Get<HistoryMessageReplyMarkup>()->create(*markup);
setPendingInitDimensions();
Notify::replyMarkupUpdated(this);
}
}

View File

@ -1510,7 +1510,7 @@ public:
}
virtual void applyEdition(const MTPDmessage &message) {
}
virtual void updateMedia(const MTPMessageMedia *media, bool edited = false) {
virtual void updateMedia(const MTPMessageMedia *media) {
}
virtual int32 addToOverview(AddToOverviewMethod method) {
return 0;
@ -2835,8 +2835,8 @@ public:
QString notificationText() const override;
void applyEdition(const MTPDmessage &message) override;
void updateMedia(const MTPMessageMedia *media, bool edited = false) override {
if (!edited && media && _media && _media->type() != MediaTypeWebPage) {
void updateMedia(const MTPMessageMedia *media) override {
if (media && _media && _media->type() != MediaTypeWebPage) {
_media->updateFrom(*media, this);
} else {
setMedia(media);

View File

@ -2136,8 +2136,8 @@ void ReportSpamPanel::setReported(bool reported, PeerData *onPeer) {
}
BotKeyboard::BotKeyboard() {
setGeometry(0, 0, _st->margin, _st->margin);
_height = _st->margin;
setGeometry(0, 0, _st->margin, st::botKbScroll.deltat);
_height = st::botKbScroll.deltat;
setMouseTracking(true);
}
@ -2149,8 +2149,8 @@ void BotKeyboard::paintEvent(QPaintEvent *e) {
if (_impl) {
int x = rtl() ? st::botKbScroll.width : _st->margin;
p.translate(x, _st->margin);
_impl->paint(p, clip.translated(-x, -_st->margin));
p.translate(x, st::botKbScroll.deltat);
_impl->paint(p, clip.translated(-x, -st::botKbScroll.deltat));
}
}
@ -2195,14 +2195,14 @@ void BotKeyboard::resizeEvent(QResizeEvent *e) {
updateStyle();
_height = _impl->naturalHeight() + 2 * _st->margin;
_height = _impl->naturalHeight() + st::botKbScroll.deltat + st::botKbScroll.deltab;
if (_maximizeSize) _height = qMax(_height, _maxOuterHeight);
if (height() != _height) {
resize(width(), _height);
return;
}
_impl->resize(width() - _st->margin - st::botKbScroll.width, _height - 2 * _st->margin);
_impl->resize(width() - _st->margin - st::botKbScroll.width, _height - (st::botKbScroll.deltat + st::botKbScroll.deltab));
}
void BotKeyboard::mousePressEvent(QMouseEvent *e) {
@ -2246,9 +2246,11 @@ void BotKeyboard::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pres
_impl->clickHandlerPressedChanged(p, pressed);
}
bool BotKeyboard::updateMarkup(HistoryItem *to) {
bool BotKeyboard::updateMarkup(HistoryItem *to, bool force) {
if (to && to->definesReplyKeyboard()) {
if (_wasForMsgId == FullMsgId(to->channelId(), to->id)) return false;
if (_wasForMsgId == FullMsgId(to->channelId(), to->id) && !force) {
return false;
}
_wasForMsgId = FullMsgId(to->channelId(), to->id);
clearSelection();
@ -2261,7 +2263,7 @@ bool BotKeyboard::updateMarkup(HistoryItem *to) {
_impl.reset(markup->rows.isEmpty() ? nullptr : new ReplyKeyboard(to, MakeUnique<Style>(this, *_st)));
updateStyle();
_height = 2 * _st->margin + (_impl ? _impl->naturalHeight() : 0);
_height = st::botKbScroll.deltat + st::botKbScroll.deltab + (_impl ? _impl->naturalHeight() : 0);
if (_maximizeSize) _height = qMax(_height, _maxOuterHeight);
if (height() != _height) {
resize(width(), _height);
@ -2290,7 +2292,7 @@ bool BotKeyboard::forceReply() const {
void BotKeyboard::resizeToWidth(int width, int maxOuterHeight) {
updateStyle(width);
_height = 2 * _st->margin + (_impl ? _impl->naturalHeight() : 0);
_height = st::botKbScroll.deltat + st::botKbScroll.deltab + (_impl ? _impl->naturalHeight() : 0);
_maxOuterHeight = maxOuterHeight;
if (_maximizeSize) _height = qMax(_height, _maxOuterHeight);
@ -3172,6 +3174,12 @@ void HistoryWidget::notify_inlineBotRequesting(bool requesting) {
_attachEmoji.setLoading(requesting);
}
void HistoryWidget::notify_replyMarkupUpdated(const HistoryItem *item) {
if (_keyboard.forMsgId() == item->fullId()) {
updateBotKeyboard(item->history(), true);
}
}
void HistoryWidget::notify_userIsBotChanged(UserData *user) {
if (_peer && _peer == user) {
_list->notifyIsBotChanged();
@ -6540,7 +6548,7 @@ void HistoryWidget::countHistoryShowFrom() {
_history->updateShowFrom();
}
void HistoryWidget::updateBotKeyboard(History *h) {
void HistoryWidget::updateBotKeyboard(History *h, bool force) {
if (h && h != _history && h != _migrated) {
return;
}
@ -6548,11 +6556,12 @@ void HistoryWidget::updateBotKeyboard(History *h) {
bool changed = false;
bool wasVisible = _kbShown || _kbReplyTo;
if ((_replyToId && !_replyEditMsg) || _editMsgId || !_history) {
changed = _keyboard.updateMarkup(0);
changed = _keyboard.updateMarkup(nullptr, force);
} else if (_replyToId && _replyEditMsg) {
changed = _keyboard.updateMarkup(_replyEditMsg);
changed = _keyboard.updateMarkup(_replyEditMsg, force);
} else {
changed = _keyboard.updateMarkup(_history->lastKeyboardId ? App::histItemById(_channel, _history->lastKeyboardId) : 0);
HistoryItem *keyboardItem = _history->lastKeyboardId ? App::histItemById(_channel, _history->lastKeyboardId) : nullptr;
changed = _keyboard.updateMarkup(keyboardItem, force);
}
updateCmdStartShown();
if (!changed) return;

View File

@ -314,7 +314,9 @@ public:
void enterEvent(QEvent *e);
void leaveEvent(QEvent *e);
bool updateMarkup(HistoryItem *last);
// With force=true the markup is updated even if it is
// already shown for the passed history item.
bool updateMarkup(HistoryItem *last, bool force = false);
bool hasMarkup() const;
bool forceReply() const;
@ -608,7 +610,10 @@ public:
bool insertBotCommand(const QString &cmd, bool specialGif);
bool eventFilter(QObject *obj, QEvent *e) override;
void updateBotKeyboard(History *h = 0);
// With force=true the markup is updated even if it is
// already shown for the passed history item.
void updateBotKeyboard(History *h = nullptr, bool force = false);
DragState getDragState(const QMimeData *d);
@ -656,6 +661,7 @@ public:
void notify_historyItemLayoutChanged(const HistoryItem *item);
void notify_botCommandsChanged(UserData *user);
void notify_inlineBotRequesting(bool requesting);
void notify_replyMarkupUpdated(const HistoryItem *item);
void notify_userIsBotChanged(UserData *user);
void notify_migrateUpdated(PeerData *peer);
void notify_clipStopperHidden(ClipStopperType type);

View File

@ -770,6 +770,10 @@ void MainWidget::notify_inlineBotRequesting(bool requesting) {
history.notify_inlineBotRequesting(requesting);
}
void MainWidget::notify_replyMarkupUpdated(const HistoryItem *item) {
history.notify_replyMarkupUpdated(item);
}
void MainWidget::notify_userIsBotChanged(UserData *bot) {
history.notify_userIsBotChanged(bot);
}

View File

@ -443,6 +443,7 @@ public:
void notify_botCommandsChanged(UserData *bot);
void notify_inlineBotRequesting(bool requesting);
void notify_replyMarkupUpdated(const HistoryItem *item);
void notify_userIsBotChanged(UserData *bot);
void notify_userIsContactChanged(UserData *user, bool fromThisApp);
void notify_migrateUpdated(PeerData *peer);

View File

@ -205,7 +205,7 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent)
, _showSessions(this, lang(lng_settings_show_sessions))
, _askQuestion(this, lang(lng_settings_ask_question))
, _telegramFAQ(this, lang(lng_settings_faq))
, _logOut(this, lang(lng_settings_logout), st::btnLogout)
, _logOut(this, lang(lng_settings_logout), st::btnRedLink)
, _supportGetRequest(0) {
if (self()) {
self()->loadUserpic();

View File

@ -294,8 +294,7 @@ private:
LinkButton _connectionType;
QString _connectionTypeText;
int32 _connectionTypeWidth;
LinkButton _showSessions, _askQuestion, _telegramFAQ;
FlatButton _logOut;
LinkButton _showSessions, _askQuestion, _telegramFAQ, _logOut;
mtpRequestId _supportGetRequest;

View File

@ -79,6 +79,7 @@
<Optimization>Disabled</Optimization>
<AdditionalOptions>/Zm152 %(AdditionalOptions)</AdditionalOptions>
<WarningLevel>Level3</WarningLevel>
<ForcedIncludeFiles>"stdafx.h"</ForcedIncludeFiles>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -109,6 +110,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<AdditionalOptions>/Zm110 %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>"stdafx.h"</ForcedIncludeFiles>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -140,6 +142,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<AdditionalOptions>/Zm110 %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>"stdafx.h"</ForcedIncludeFiles>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>