2017-04-08 13:27:53 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-04-08 13:27:53 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ui/widgets/tooltip.h"
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
namespace style {
|
|
|
|
struct BotKeyboardButton;
|
|
|
|
} // namespace style
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
class ReplyKeyboard;
|
|
|
|
|
|
|
|
class BotKeyboard
|
|
|
|
: public TWidget
|
|
|
|
, public Ui::AbstractTooltipShower
|
|
|
|
, public ClickHandlerHost {
|
2017-04-08 13:27:53 +00:00
|
|
|
public:
|
|
|
|
BotKeyboard(QWidget *parent);
|
|
|
|
|
|
|
|
bool moderateKeyActivate(int index);
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
void step_selected(crl::time ms, bool timer);
|
2017-04-08 13:27:53 +00:00
|
|
|
void resizeToWidth(int newWidth, int maxOuterHeight) {
|
|
|
|
_maxOuterHeight = maxOuterHeight;
|
|
|
|
return TWidget::resizeToWidth(newWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool maximizeSize() const;
|
|
|
|
bool singleUse() const;
|
|
|
|
|
|
|
|
FullMsgId forMsgId() const {
|
|
|
|
return _wasForMsgId;
|
|
|
|
}
|
|
|
|
|
|
|
|
// AbstractTooltipShower interface
|
|
|
|
QString tooltipText() const override;
|
|
|
|
QPoint tooltipPos() const override;
|
2019-09-16 11:14:06 +00:00
|
|
|
bool tooltipWindowActive() const override;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
|
|
|
// ClickHandlerHost interface
|
|
|
|
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
|
|
|
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
~BotKeyboard();
|
|
|
|
|
2017-04-08 13:27:53 +00:00
|
|
|
protected:
|
|
|
|
int resizeGetHeight(int newWidth) override;
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
|
|
void enterEventHook(QEvent *e) override;
|
|
|
|
void leaveEventHook(QEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void updateSelected();
|
|
|
|
|
|
|
|
void updateStyle(int newWidth);
|
|
|
|
void clearSelection();
|
|
|
|
|
|
|
|
FullMsgId _wasForMsgId;
|
|
|
|
int _height = 0;
|
|
|
|
int _maxOuterHeight = 0;
|
|
|
|
bool _maximizeSize = false;
|
|
|
|
bool _singleUse = false;
|
|
|
|
bool _forceReply = false;
|
|
|
|
|
|
|
|
QPoint _lastMousePos;
|
|
|
|
std::unique_ptr<ReplyKeyboard> _impl;
|
|
|
|
|
|
|
|
const style::BotKeyboardButton *_st = nullptr;
|
|
|
|
|
|
|
|
};
|