Skip to content

Commit

Permalink
Added type voice for inline bots, fixed keyboard buttons bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Apr 11, 2016
1 parent 2b58e4d commit 00367ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2587,7 +2587,8 @@ void ReplyKeyboard::resize(int width, int height) {
int buttonw = qMax(button.text.maxWidth(), 1);
float64 textw = exact ? buttonw : (widthForText / float64(s));
float64 minw = _st->minButtonWidth(button.type);
float64 w = minw + qMax(textw, 0.);
float64 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;
Expand Down
20 changes: 11 additions & 9 deletions Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,14 @@ void File::paint(Painter &p, const QRect &clip, uint32 selection, const PaintCon
_title.drawLeftElided(p, left, titleTop, _width - left, _width);

p.setPen(st::inlineDescriptionFg);
if (_statusText.isEmpty()) {
_description.drawLeftElided(p, left, descriptionTop, _width - left, _width);
} else {
bool drawStatusSize = true;
if (_statusSize == FileStatusSizeReady || _statusSize == FileStatusSizeLoaded || _statusSize == FileStatusSizeFailed) {
if (!_description.isEmpty()) {
_description.drawLeftElided(p, left, descriptionTop, _width - left, _width);
drawStatusSize = false;
}
}
if (drawStatusSize) {
p.setFont(st::normalFont);
p.drawTextLeft(left, descriptionTop, _width, _statusText);
}
Expand Down Expand Up @@ -898,14 +903,11 @@ bool File::updateStatusText() const {
void File::setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 realDuration) const {
_statusSize = newSize;
if (_statusSize == FileStatusSizeReady) {
// _statusText = (duration >= 0) ? formatDurationAndSizeText(duration, fullSize) : (duration < -1 ? formatGifAndSizeText(fullSize) : formatSizeText(fullSize));
_statusText = QString();
_statusText = (duration >= 0) ? formatDurationAndSizeText(duration, fullSize) : (duration < -1 ? formatGifAndSizeText(fullSize) : formatSizeText(fullSize));
} else if (_statusSize == FileStatusSizeLoaded) {
// _statusText = (duration >= 0) ? formatDurationText(duration) : (duration < -1 ? qsl("GIF") : formatSizeText(fullSize));
_statusText = QString();
_statusText = (duration >= 0) ? formatDurationText(duration) : (duration < -1 ? qsl("GIF") : formatSizeText(fullSize));
} else if (_statusSize == FileStatusSizeFailed) {
// _statusText = lang(lng_attach_failed);
_statusText = QString();
_statusText = lang(lng_attach_failed);
} else if (_statusSize >= 0) {
_statusText = formatDownloadText(_statusSize, fullSize);
} else {
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/inline_bots/inline_bot_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ std_::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult
result->insert(qsl("photo"), Result::Type::Photo);
result->insert(qsl("video"), Result::Type::Video);
result->insert(qsl("audio"), Result::Type::Audio);
result->insert(qsl("voice"), Result::Type::Audio);
result->insert(qsl("sticker"), Result::Type::Sticker);
result->insert(qsl("file"), Result::Type::File);
result->insert(qsl("gif"), Result::Type::Gif);
Expand Down

0 comments on commit 00367ec

Please sign in to comment.