Replace T_WIDGET macro with a template base class.

This commit is contained in:
John Preston 2017-02-11 14:24:37 +03:00
parent 61b55706ae
commit 25583fa813
63 changed files with 256 additions and 258 deletions

View File

@ -546,7 +546,7 @@ void SetupChannelBox::mousePressEvent(QMouseEvent *e) {
} }
} }
void SetupChannelBox::leaveEvent(QEvent *e) { void SetupChannelBox::leaveEventHook(QEvent *e) {
updateSelected(QCursor::pos()); updateSelected(QCursor::pos());
} }

View File

@ -146,7 +146,7 @@ protected:
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private slots: private slots:
void onSave(); void onSave();

View File

@ -168,7 +168,7 @@ void ConfirmBox::mouseReleaseEvent(QMouseEvent *e) {
return BoxContent::mouseReleaseEvent(e); return BoxContent::mouseReleaseEvent(e);
} }
void ConfirmBox::leaveEvent(QEvent *e) { void ConfirmBox::leaveEventHook(QEvent *e) {
ClickHandler::clearActive(this); ClickHandler::clearActive(this);
} }
@ -245,7 +245,7 @@ void MaxInviteBox::mousePressEvent(QMouseEvent *e) {
} }
} }
void MaxInviteBox::leaveEvent(QEvent *e) { void MaxInviteBox::leaveEventHook(QEvent *e) {
updateSelected(QCursor::pos()); updateSelected(QCursor::pos());
} }

View File

@ -57,7 +57,7 @@ protected:
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private: private:
struct InformBoxTag { struct InformBoxTag {
@ -109,7 +109,7 @@ protected:
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private: private:
void updateSelected(const QPoint &cursorGlobalPosition); void updateSelected(const QPoint &cursorGlobalPosition);

View File

@ -1169,7 +1169,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) {
} }
} }
void ContactsBox::Inner::enterEvent(QEvent *e) { void ContactsBox::Inner::enterEventHook(QEvent *e) {
setMouseTracking(true); setMouseTracking(true);
} }
@ -1235,7 +1235,7 @@ void ContactsBox::Inner::updateRowWithPeer(PeerData *peer) {
} }
} }
void ContactsBox::Inner::leaveEvent(QEvent *e) { void ContactsBox::Inner::leaveEventHook(QEvent *e) {
_mouseSelection = false; _mouseSelection = false;
setMouseTracking(false); setMouseTracking(false);
if (_selected || _filteredSelected >= 0 || _searchedSelected >= 0) { if (_selected || _filteredSelected >= 0 || _searchedSelected >= 0) {

View File

@ -208,8 +208,8 @@ private slots:
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;

View File

@ -181,11 +181,11 @@ void MembersBox::Inner::paintEvent(QPaintEvent *e) {
} }
} }
void MembersBox::Inner::enterEvent(QEvent *e) { void MembersBox::Inner::enterEventHook(QEvent *e) {
setMouseTracking(true); setMouseTracking(true);
} }
void MembersBox::Inner::leaveEvent(QEvent *e) { void MembersBox::Inner::leaveEventHook(QEvent *e) {
_mouseSelection = false; _mouseSelection = false;
setMouseTracking(false); setMouseTracking(false);
if (_selected >= 0) { if (_selected >= 0) {

View File

@ -118,8 +118,8 @@ public slots:
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;

View File

@ -332,7 +332,7 @@ void NotificationsBox::mouseMoveEvent(QMouseEvent *e) {
} }
} }
void NotificationsBox::leaveEvent(QEvent *e) { void NotificationsBox::leaveEventHook(QEvent *e) {
clearOverCorner(); clearOverCorner();
} }

View File

@ -39,7 +39,7 @@ protected:
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
private: private:

View File

@ -578,11 +578,11 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) {
} }
} }
void ShareBox::Inner::enterEvent(QEvent *e) { void ShareBox::Inner::enterEventHook(QEvent *e) {
setMouseTracking(true); setMouseTracking(true);
} }
void ShareBox::Inner::leaveEvent(QEvent *e) { void ShareBox::Inner::leaveEventHook(QEvent *e) {
setMouseTracking(false); setMouseTracking(false);
} }

View File

@ -140,8 +140,8 @@ signals:
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;

View File

@ -972,7 +972,7 @@ void StickersBox::Inner::setRowRemoved(int index, bool removed) {
} }
} }
void StickersBox::Inner::leaveEvent(QEvent *e) { void StickersBox::Inner::leaveEventHook(QEvent *e) {
_mouse = QPoint(-1, -1); _mouse = QPoint(-1, -1);
onUpdateSelected(); onUpdateSelected();
} }

View File

@ -183,7 +183,7 @@ protected:
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
signals: signals:
void draggingScrollDelta(int delta); void draggingScrollDelta(int delta);

View File

@ -277,7 +277,7 @@ void StickerSetBox::Inner::mouseMoveEvent(QMouseEvent *e) {
} }
} }
void StickerSetBox::Inner::leaveEvent(QEvent *e) { void StickerSetBox::Inner::leaveEventHook(QEvent *e) {
setSelected(-1); setSelected(-1);
} }

View File

@ -86,7 +86,7 @@ protected:
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private slots: private slots:
void onPreview(); void onPreview();

View File

@ -1088,7 +1088,7 @@ void DialogsInner::updateDialogRow(PeerData *peer, MsgId msgId, QRect updateRect
} }
} }
void DialogsInner::enterEvent(QEvent *e) { void DialogsInner::enterEventHook(QEvent *e) {
setMouseTracking(true); setMouseTracking(true);
updateSelected(); updateSelected();
} }
@ -1131,7 +1131,7 @@ void DialogsInner::updateSelectedRow(PeerData *peer) {
} }
} }
void DialogsInner::leaveEvent(QEvent *e) { void DialogsInner::leaveEventHook(QEvent *e) {
setMouseTracking(false); setMouseTracking(false);
clearSelection(); clearSelection();
} }

View File

@ -146,8 +146,8 @@ protected:
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void contextMenuEvent(QContextMenuEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override;
private: private:

View File

@ -836,13 +836,13 @@ void FieldAutocompleteInner::mouseReleaseEvent(QMouseEvent *e) {
chooseSelected(FieldAutocomplete::ChooseMethod::ByClick); chooseSelected(FieldAutocomplete::ChooseMethod::ByClick);
} }
void FieldAutocompleteInner::enterEvent(QEvent *e) { void FieldAutocompleteInner::enterEventHook(QEvent *e) {
setMouseTracking(true); setMouseTracking(true);
_mousePos = QCursor::pos(); _mousePos = QCursor::pos();
onUpdateSelected(true); onUpdateSelected(true);
} }
void FieldAutocompleteInner::leaveEvent(QEvent *e) { void FieldAutocompleteInner::leaveEventHook(QEvent *e) {
setMouseTracking(false); setMouseTracking(false);
if (_sel >= 0) { if (_sel >= 0) {
setSel(-1); setSel(-1);

View File

@ -165,8 +165,8 @@ private:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;

View File

@ -1834,12 +1834,12 @@ void HistoryInner::updateSize() {
} }
} }
void HistoryInner::enterEvent(QEvent *e) { void HistoryInner::enterEventHook(QEvent *e) {
dragActionUpdate(QCursor::pos()); dragActionUpdate(QCursor::pos());
// return QWidget::enterEvent(e); return TWidget::enterEventHook(e);
} }
void HistoryInner::leaveEvent(QEvent *e) { void HistoryInner::leaveEventHook(QEvent *e) {
if (auto item = App::hoveredItem()) { if (auto item = App::hoveredItem()) {
repaintItem(item); repaintItem(item);
App::hoveredItem(nullptr); App::hoveredItem(nullptr);
@ -1850,7 +1850,7 @@ void HistoryInner::leaveEvent(QEvent *e) {
_cursor = style::cur_default; _cursor = style::cur_default;
setCursor(_cursor); setCursor(_cursor);
} }
return QWidget::leaveEvent(e); return TWidget::leaveEventHook(e);
} }
HistoryInner::~HistoryInner() { HistoryInner::~HistoryInner() {
@ -2577,12 +2577,12 @@ void BotKeyboard::mouseReleaseEvent(QMouseEvent *e) {
} }
} }
void BotKeyboard::enterEvent(QEvent *e) { void BotKeyboard::enterEventHook(QEvent *e) {
_lastMousePos = QCursor::pos(); _lastMousePos = QCursor::pos();
updateSelected(); updateSelected();
} }
void BotKeyboard::leaveEvent(QEvent *e) { void BotKeyboard::leaveEventHook(QEvent *e) {
clearSelection(); clearSelection();
} }
@ -2988,7 +2988,7 @@ public:
protected: protected:
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private: private:
bool _checked = false; bool _checked = false;
@ -3015,8 +3015,8 @@ void SilentToggle::setChecked(bool checked) {
} }
} }
void SilentToggle::leaveEvent(QEvent *e) { void SilentToggle::leaveEventHook(QEvent *e) {
IconButton::leaveEvent(e); IconButton::leaveEventHook(e);
Ui::Tooltip::Hide(); Ui::Tooltip::Hide();
} }
@ -5627,7 +5627,7 @@ void HistoryWidget::dragLeaveEvent(QDragLeaveEvent *e) {
} }
} }
void HistoryWidget::leaveEvent(QEvent *e) { void HistoryWidget::leaveEventHook(QEvent *e) {
if (_attachDrag != DragStateNone || !_attachDragPhoto->isHidden() || !_attachDragDocument->isHidden()) { if (_attachDrag != DragStateNone || !_attachDragPhoto->isHidden() || !_attachDragDocument->isHidden()) {
_attachDrag = DragStateNone; _attachDrag = DragStateNone;
updateDragAreas(); updateDragAreas();

View File

@ -129,8 +129,8 @@ protected:
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void mouseDoubleClickEvent(QMouseEvent *e) override; void mouseDoubleClickEvent(QMouseEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *e) override; void keyPressEvent(QKeyEvent *e) override;
@ -413,8 +413,8 @@ protected:
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private: private:
void updateSelected(); void updateSelected();
@ -734,7 +734,7 @@ protected:
void keyPressEvent(QKeyEvent *e) override; void keyPressEvent(QKeyEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void contextMenuEvent(QContextMenuEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override;

View File

@ -194,7 +194,7 @@ void CoverWidget::mouseMoveEvent(QMouseEvent *e) {
setCloseVisible(closeVisible); setCloseVisible(closeVisible);
} }
void CoverWidget::leaveEvent(QEvent *e) { void CoverWidget::leaveEventHook(QEvent *e) {
setCloseVisible(false); setCloseVisible(false);
} }

View File

@ -50,7 +50,7 @@ protected:
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private: private:
void setCloseVisible(bool visible); void setCloseVisible(bool visible);

View File

@ -177,7 +177,7 @@ void Panel::paintEvent(QPaintEvent *e) {
App::roundRect(p, shadowedRect, st::menuBg, MenuCorners, nullptr, parts); App::roundRect(p, shadowedRect, st::menuBg, MenuCorners, nullptr, parts);
} }
void Panel::enterEvent(QEvent *e) { void Panel::enterEventHook(QEvent *e) {
if (_ignoringEnterEvents) return; if (_ignoringEnterEvents) return;
_hideTimer.stop(); _hideTimer.stop();
@ -186,17 +186,17 @@ void Panel::enterEvent(QEvent *e) {
} else { } else {
_showTimer.start(0); _showTimer.start(0);
} }
return TWidget::enterEvent(e); return TWidget::enterEventHook(e);
} }
void Panel::leaveEvent(QEvent *e) { void Panel::leaveEventHook(QEvent *e) {
_showTimer.stop(); _showTimer.stop();
if (_a_appearance.animating(getms())) { if (_a_appearance.animating(getms())) {
onHideStart(); onHideStart();
} else { } else {
_hideTimer.start(300); _hideTimer.start(300);
} }
return TWidget::leaveEvent(e); return TWidget::leaveEventHook(e);
} }
void Panel::showFromOther() { void Panel::showFromOther() {

View File

@ -59,8 +59,8 @@ public:
protected: protected:
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private slots: private slots:
void onShowStart(); void onShowStart();

View File

@ -150,24 +150,24 @@ void VolumeWidget::paintEvent(QPaintEvent *e) {
App::roundRect(p, QRect(shadowedRect.x(), -st::buttonRadius, shadowedRect.width(), shadowedRect.y() + shadowedRect.height() + st::buttonRadius), st::menuBg, MenuCorners, nullptr, parts); App::roundRect(p, QRect(shadowedRect.x(), -st::buttonRadius, shadowedRect.width(), shadowedRect.y() + shadowedRect.height() + st::buttonRadius), st::menuBg, MenuCorners, nullptr, parts);
} }
void VolumeWidget::enterEvent(QEvent *e) { void VolumeWidget::enterEventHook(QEvent *e) {
_hideTimer.stop(); _hideTimer.stop();
if (_a_appearance.animating(getms())) { if (_a_appearance.animating(getms())) {
onShowStart(); onShowStart();
} else { } else {
_showTimer.start(0); _showTimer.start(0);
} }
return TWidget::enterEvent(e); return TWidget::enterEventHook(e);
} }
void VolumeWidget::leaveEvent(QEvent *e) { void VolumeWidget::leaveEventHook(QEvent *e) {
_showTimer.stop(); _showTimer.stop();
if (_a_appearance.animating(getms())) { if (_a_appearance.animating(getms())) {
onHideStart(); onHideStart();
} else { } else {
_hideTimer.start(300); _hideTimer.start(300);
} }
return TWidget::leaveEvent(e); return TWidget::leaveEventHook(e);
} }
void VolumeWidget::otherEnter() { void VolumeWidget::otherEnter() {

View File

@ -58,8 +58,8 @@ public:
protected: protected:
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
bool eventFilter(QObject *obj, QEvent *e) override; bool eventFilter(QObject *obj, QEvent *e) override;

View File

@ -233,7 +233,7 @@ void Widget::paintEvent(QPaintEvent *e) {
} }
} }
void Widget::leaveEvent(QEvent *e) { void Widget::leaveEventHook(QEvent *e) {
updateOverLabelsState(false); updateOverLabelsState(false);
} }

View File

@ -60,7 +60,7 @@ protected:
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
private: private:

View File

@ -93,11 +93,11 @@ void VolumeController::mouseReleaseEvent(QMouseEvent *e) {
_downCoord = -1; _downCoord = -1;
} }
void VolumeController::enterEvent(QEvent *e) { void VolumeController::enterEventHook(QEvent *e) {
setOver(true); setOver(true);
} }
void VolumeController::leaveEvent(QEvent *e) { void VolumeController::leaveEventHook(QEvent *e) {
setOver(false); setOver(false);
} }

View File

@ -39,8 +39,8 @@ protected:
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private: private:
void setOver(bool over); void setOver(bool over);

View File

@ -1137,11 +1137,11 @@ void OverviewInner::keyPressEvent(QKeyEvent *e) {
} }
} }
void OverviewInner::enterEvent(QEvent *e) { void OverviewInner::enterEventHook(QEvent *e) {
return QWidget::enterEvent(e); return TWidget::enterEventHook(e);
} }
void OverviewInner::leaveEvent(QEvent *e) { void OverviewInner::leaveEventHook(QEvent *e) {
if (auto selectedMsgId = base::take(_selectedMsgId)) { if (auto selectedMsgId = base::take(_selectedMsgId)) {
repaintItem(selectedMsgId, -1); repaintItem(selectedMsgId, -1);
} }
@ -1150,7 +1150,7 @@ void OverviewInner::leaveEvent(QEvent *e) {
_cursor = style::cur_default; _cursor = style::cur_default;
setCursor(_cursor); setCursor(_cursor);
} }
return QWidget::leaveEvent(e); return TWidget::leaveEventHook(e);
} }
void OverviewInner::resizeEvent(QResizeEvent *e) { void OverviewInner::resizeEvent(QResizeEvent *e) {

View File

@ -101,8 +101,8 @@ protected:
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void keyPressEvent(QKeyEvent *e) override; void keyPressEvent(QKeyEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
public slots: public slots:

View File

@ -120,7 +120,7 @@ int InfoWidget::resizeGetHeight(int newWidth) {
return newHeight; return newHeight;
} }
void InfoWidget::leaveEvent(QEvent *e) { void InfoWidget::leaveEventHook(QEvent *e) {
BotCommandClickHandler::setPeerForCommand(nullptr); BotCommandClickHandler::setPeerForCommand(nullptr);
BotCommandClickHandler::setBotForCommand(nullptr); BotCommandClickHandler::setBotForCommand(nullptr);
} }

View File

@ -40,7 +40,7 @@ protected:
// Resizes content and counts natural widget height for the desired width. // Resizes content and counts natural widget height for the desired width.
int resizeGetHeight(int newWidth) override; int resizeGetHeight(int newWidth) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private: private:
// Observed notifications. // Observed notifications.

View File

@ -225,12 +225,12 @@ void PeerListWidget::contextMenuEvent(QContextMenuEvent *e) {
} }
} }
void PeerListWidget::enterEvent(QEvent *e) { void PeerListWidget::enterEventHook(QEvent *e) {
_mousePosition = QCursor::pos(); _mousePosition = QCursor::pos();
updateSelection(); updateSelection();
} }
void PeerListWidget::leaveEvent(QEvent *e) { void PeerListWidget::leaveEventHook(QEvent *e) {
_mousePosition = QPoint(-1, -1); _mousePosition = QPoint(-1, -1);
updateSelection(); updateSelection();
} }

View File

@ -107,13 +107,13 @@ protected:
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void contextMenuEvent(QContextMenuEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void enterFromChildEvent(QEvent *e, QWidget *child) override { void enterFromChildEvent(QEvent *e, QWidget *child) override {
enterEvent(e); enterEventHook(e);
} }
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void leaveToChildEvent(QEvent *e, QWidget *child) override { void leaveToChildEvent(QEvent *e, QWidget *child) override {
leaveEvent(e); leaveEventHook(e);
} }
virtual Ui::PopupMenu *fillPeerMenu(PeerData *peer) { virtual Ui::PopupMenu *fillPeerMenu(PeerData *peer) {

View File

@ -105,14 +105,14 @@ void EmojiColorPicker::paintEvent(QPaintEvent *e) {
} }
} }
void EmojiColorPicker::enterEvent(QEvent *e) { void EmojiColorPicker::enterEventHook(QEvent *e) {
_hideTimer.stop(); _hideTimer.stop();
if (_hiding) showAnimated(); if (_hiding) showAnimated();
TWidget::enterEvent(e); TWidget::enterEventHook(e);
} }
void EmojiColorPicker::leaveEvent(QEvent *e) { void EmojiColorPicker::leaveEventHook(QEvent *e) {
TWidget::leaveEvent(e); TWidget::leaveEventHook(e);
} }
void EmojiColorPicker::mousePressEvent(QMouseEvent *e) { void EmojiColorPicker::mousePressEvent(QMouseEvent *e) {
@ -542,7 +542,7 @@ void EmojiPanInner::mouseMoveEvent(QMouseEvent *e) {
updateSelected(); updateSelected();
} }
void EmojiPanInner::leaveEvent(QEvent *e) { void EmojiPanInner::leaveEventHook(QEvent *e) {
clearSelection(); clearSelection();
} }
@ -1253,7 +1253,7 @@ void StickerPanInner::mouseMoveEvent(QMouseEvent *e) {
updateSelected(); updateSelected();
} }
void StickerPanInner::leaveEvent(QEvent *e) { void StickerPanInner::leaveEventHook(QEvent *e) {
clearSelection(); clearSelection();
} }
@ -2991,7 +2991,7 @@ void EmojiPan::moveByBottom() {
updateContentHeight(); updateContentHeight();
} }
void EmojiPan::enterEvent(QEvent *e) { void EmojiPan::enterEventHook(QEvent *e) {
_hideTimer.stop(); _hideTimer.stop();
if (_hiding) showAnimated(_origin); if (_hiding) showAnimated(_origin);
} }
@ -3000,7 +3000,7 @@ bool EmojiPan::preventAutoHide() const {
return _removingSetId || _displayingSetId; return _removingSetId || _displayingSetId;
} }
void EmojiPan::leaveEvent(QEvent *e) { void EmojiPan::leaveEventHook(QEvent *e) {
if (preventAutoHide() || s_inner->inlineResultsShown()) return; if (preventAutoHide() || s_inner->inlineResultsShown()) return;
auto ms = getms(); auto ms = getms();
if (_a_show.animating(ms) || _a_opacity.animating(ms)) { if (_a_show.animating(ms) || _a_opacity.animating(ms)) {
@ -3008,7 +3008,7 @@ void EmojiPan::leaveEvent(QEvent *e) {
} else { } else {
_hideTimer.start(300); _hideTimer.start(300);
} }
return TWidget::leaveEvent(e); return TWidget::leaveEventHook(e);
} }
void EmojiPan::otherEnter() { void EmojiPan::otherEnter() {

View File

@ -82,8 +82,8 @@ signals:
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
@ -141,7 +141,7 @@ protected:
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void leaveToChildEvent(QEvent *e, QWidget *child) override; void leaveToChildEvent(QEvent *e, QWidget *child) override;
void enterFromChildEvent(QEvent *e, QWidget *child) override; void enterFromChildEvent(QEvent *e, QWidget *child) override;
@ -258,7 +258,7 @@ protected:
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void leaveToChildEvent(QEvent *e, QWidget *child) override; void leaveToChildEvent(QEvent *e, QWidget *child) override;
void enterFromChildEvent(QEvent *e, QWidget *child) override; void enterFromChildEvent(QEvent *e, QWidget *child) override;
@ -505,8 +505,8 @@ public:
~EmojiPan(); ~EmojiPan();
protected: protected:
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void otherEnter(); void otherEnter();
void otherLeave(); void otherLeave();

View File

@ -23,16 +23,16 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
namespace Ui { namespace Ui {
void AbstractButton::leaveEvent(QEvent *e) { void AbstractButton::leaveEventHook(QEvent *e) {
if (_state & StateFlag::Down) return; if (_state & StateFlag::Down) return;
setOver(false, StateChangeSource::ByHover); setOver(false, StateChangeSource::ByHover);
return TWidget::leaveEvent(e); return TWidget::leaveEventHook(e);
} }
void AbstractButton::enterEvent(QEvent *e) { void AbstractButton::enterEventHook(QEvent *e) {
checkIfOver(mapFromGlobal(QCursor::pos())); checkIfOver(mapFromGlobal(QCursor::pos()));
return TWidget::enterEvent(e); return TWidget::enterEventHook(e);
} }
void AbstractButton::setAcceptBoth(bool acceptBoth) { void AbstractButton::setAcceptBoth(bool acceptBoth) {

View File

@ -64,8 +64,8 @@ public:
} }
protected: protected:
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;

View File

@ -165,11 +165,11 @@ void CountryInput::mousePressEvent(QMouseEvent *e) {
} }
} }
void CountryInput::enterEvent(QEvent *e) { void CountryInput::enterEventHook(QEvent *e) {
setMouseTracking(true); setMouseTracking(true);
} }
void CountryInput::leaveEvent(QEvent *e) { void CountryInput::leaveEventHook(QEvent *e) {
setMouseTracking(false); setMouseTracking(false);
_active = false; _active = false;
setCursor(style::cur_default); setCursor(style::cur_default);
@ -366,11 +366,11 @@ void CountrySelectBox::Inner::paintEvent(QPaintEvent *e) {
} }
} }
void CountrySelectBox::Inner::enterEvent(QEvent *e) { void CountrySelectBox::Inner::enterEventHook(QEvent *e) {
setMouseTracking(true); setMouseTracking(true);
} }
void CountrySelectBox::Inner::leaveEvent(QEvent *e) { void CountrySelectBox::Inner::leaveEventHook(QEvent *e) {
_mouseSelection = false; _mouseSelection = false;
setMouseTracking(false); setMouseTracking(false);
if (_selected >= 0) { if (_selected >= 0) {

View File

@ -46,8 +46,8 @@ protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private: private:
void setText(const QString &newText); void setText(const QString &newText);
@ -112,8 +112,8 @@ signals:
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;

View File

@ -125,82 +125,108 @@ private:
}; };
#define T_WIDGET \ class TWidget;
public: \
TWidget *tparent() { \ template <typename Base>
return qobject_cast<TWidget*>(parentWidget()); \ class TWidgetHelper : public Base {
} \ public:
const TWidget *tparent() const { \ using Base::Base;
return qobject_cast<const TWidget*>(parentWidget()); \
} \ virtual QMargins getMargins() const {
virtual void leaveToChildEvent(QEvent *e, QWidget *child) { /* e -- from enterEvent() of child TWidget */ \ return QMargins();
} \
virtual void enterFromChildEvent(QEvent *e, QWidget *child) { /* e -- from leaveEvent() of child TWidget */ \
} \
void moveToLeft(int x, int y, int outerw = 0) { \
auto margins = getMargins(); \
x -= margins.left(); \
y -= margins.top(); \
move(rtl() ? ((outerw > 0 ? outerw : parentWidget()->width()) - x - width()) : x, y); \
} \
void moveToRight(int x, int y, int outerw = 0) { \
auto margins = getMargins(); \
x -= margins.right(); \
y -= margins.top(); \
move(rtl() ? x : ((outerw > 0 ? outerw : parentWidget()->width()) - x - width()), y); \
} \
void setGeometryToLeft(int x, int y, int w, int h, int outerw = 0) { \
auto margins = getMargins(); \
x -= margins.left(); \
y -= margins.top(); \
w -= margins.left() - margins.right(); \
h -= margins.top() - margins.bottom(); \
setGeometry(rtl() ? ((outerw > 0 ? outerw : parentWidget()->width()) - x - w) : x, y, w, h); \
} \
void setGeometryToRight(int x, int y, int w, int h, int outerw = 0) { \
auto margins = getMargins(); \
x -= margins.right(); \
y -= margins.top(); \
w -= margins.left() - margins.right(); \
h -= margins.top() - margins.bottom(); \
setGeometry(rtl() ? x : ((outerw > 0 ? outerw : parentWidget()->width()) - x - w), y, w, h); \
} \
QPoint myrtlpoint(int x, int y) const { \
return rtlpoint(x, y, width()); \
} \
QPoint myrtlpoint(const QPoint p) const { \
return rtlpoint(p, width()); \
} \
QRect myrtlrect(int x, int y, int w, int h) const { \
return rtlrect(x, y, w, h, width()); \
} \
QRect myrtlrect(const QRect &r) const { \
return rtlrect(r, width()); \
} \
void rtlupdate(const QRect &r) { \
update(myrtlrect(r)); \
} \
void rtlupdate(int x, int y, int w, int h) { \
update(myrtlrect(x, y, w, h)); \
} \
protected: \
void enterEvent(QEvent *e) override { \
TWidget *p(tparent()); \
if (p) p->leaveToChildEvent(e, this); \
return enterEventHook(e); \
} \
void leaveEvent(QEvent *e) override { \
TWidget *p(tparent()); \
if (p) p->enterFromChildEvent(e, this); \
return leaveEventHook(e); \
} }
class TWidget : public QWidget { void moveToLeft(int x, int y, int outerw = 0) {
auto margins = getMargins();
x -= margins.left();
y -= margins.top();
move(rtl() ? ((outerw > 0 ? outerw : parentWidget()->width()) - x - width()) : x, y);
}
void moveToRight(int x, int y, int outerw = 0) {
auto margins = getMargins();
x -= margins.right();
y -= margins.top();
move(rtl() ? x : ((outerw > 0 ? outerw : parentWidget()->width()) - x - width()), y);
}
void setGeometryToLeft(int x, int y, int w, int h, int outerw = 0) {
auto margins = getMargins();
x -= margins.left();
y -= margins.top();
w -= margins.left() - margins.right();
h -= margins.top() - margins.bottom();
setGeometry(rtl() ? ((outerw > 0 ? outerw : parentWidget()->width()) - x - w) : x, y, w, h);
}
void setGeometryToRight(int x, int y, int w, int h, int outerw = 0) {
auto margins = getMargins();
x -= margins.right();
y -= margins.top();
w -= margins.left() - margins.right();
h -= margins.top() - margins.bottom();
setGeometry(rtl() ? x : ((outerw > 0 ? outerw : parentWidget()->width()) - x - w), y, w, h);
}
QPoint myrtlpoint(int x, int y) const {
return rtlpoint(x, y, width());
}
QPoint myrtlpoint(const QPoint p) const {
return rtlpoint(p, width());
}
QRect myrtlrect(int x, int y, int w, int h) const {
return rtlrect(x, y, w, h, width());
}
QRect myrtlrect(const QRect &r) const {
return rtlrect(r, width());
}
void rtlupdate(const QRect &r) {
update(myrtlrect(r));
}
void rtlupdate(int x, int y, int w, int h) {
update(myrtlrect(x, y, w, h));
}
protected:
void enterEvent(QEvent *e) final override {
if (auto parent = tparent()) {
parent->leaveToChildEvent(e, this);
}
return enterEventHook(e);
}
virtual void enterEventHook(QEvent *e) {
return Base::enterEvent(e);
}
void leaveEvent(QEvent *e) final override {
if (auto parent = tparent()) {
parent->enterFromChildEvent(e, this);
}
return leaveEventHook(e);
}
virtual void leaveEventHook(QEvent *e) {
return Base::leaveEvent(e);
}
// e - from enterEvent() of child TWidget
virtual void leaveToChildEvent(QEvent *e, QWidget *child) {
}
// e - from leaveEvent() of child TWidget
virtual void enterFromChildEvent(QEvent *e, QWidget *child) {
}
private:
TWidget *tparent() {
return qobject_cast<TWidget*>(parentWidget());
}
const TWidget *tparent() const {
return qobject_cast<const TWidget*>(parentWidget());
}
};
class TWidget : public TWidgetHelper<QWidget> {
Q_OBJECT Q_OBJECT
T_WIDGET
public: public:
TWidget(QWidget *parent = nullptr) : QWidget(parent) { TWidget(QWidget *parent = nullptr) : TWidgetHelper<QWidget>(parent) {
} }
virtual void grabStart() { virtual void grabStart() {
} }
@ -224,10 +250,6 @@ public:
} }
} }
virtual QMargins getMargins() const {
return QMargins();
}
// Get the size of the widget as it should be. // Get the size of the widget as it should be.
// Negative return value means no default width. // Negative return value means no default width.
virtual int naturalWidth() const { virtual int naturalWidth() const {
@ -276,18 +298,14 @@ signals:
void heightUpdated(); void heightUpdated();
protected: protected:
void enterEventHook(QEvent *e) {
return QWidget::enterEvent(e);
}
void leaveEventHook(QEvent *e) {
return QWidget::leaveEvent(e);
}
// Resizes content and counts natural widget height for the desired width. // Resizes content and counts natural widget height for the desired width.
virtual int resizeGetHeight(int newWidth) { virtual int resizeGetHeight(int newWidth) {
return height(); return height();
} }
template <typename Base>
friend class TWidgetHelper;
}; };
template <typename Widget> template <typename Widget>

View File

@ -156,11 +156,11 @@ void ContinuousSlider::updateDownValueFromPos(const QPoint &pos) {
} }
} }
void ContinuousSlider::enterEvent(QEvent *e) { void ContinuousSlider::enterEventHook(QEvent *e) {
setOver(true); setOver(true);
} }
void ContinuousSlider::leaveEvent(QEvent *e) { void ContinuousSlider::leaveEventHook(QEvent *e) {
setOver(false); setOver(false);
} }

View File

@ -63,8 +63,8 @@ protected:
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void wheelEvent(QWheelEvent *e) override; void wheelEvent(QWheelEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
float64 fadeOpacity() const { float64 fadeOpacity() const {
return _fadeOpacity; return _fadeOpacity;

View File

@ -127,19 +127,19 @@ void InnerDropdown::paintEvent(QPaintEvent *e) {
} }
} }
void InnerDropdown::enterEvent(QEvent *e) { void InnerDropdown::enterEventHook(QEvent *e) {
showAnimated(_origin); showAnimated(_origin);
return TWidget::enterEvent(e); return TWidget::enterEventHook(e);
} }
void InnerDropdown::leaveEvent(QEvent *e) { void InnerDropdown::leaveEventHook(QEvent *e) {
auto ms = getms(); auto ms = getms();
if (_a_show.animating(ms) || _a_opacity.animating(ms)) { if (_a_show.animating(ms) || _a_opacity.animating(ms)) {
hideAnimated(); hideAnimated();
} else { } else {
_hideTimer.start(300); _hideTimer.start(300);
} }
return TWidget::leaveEvent(e); return TWidget::leaveEventHook(e);
} }
void InnerDropdown::otherEnter() { void InnerDropdown::otherEnter() {

View File

@ -73,8 +73,8 @@ public:
protected: protected:
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
bool eventFilter(QObject *obj, QEvent *e) override; bool eventFilter(QObject *obj, QEvent *e) override;
int resizeGetHeight(int newWidth) override; int resizeGetHeight(int newWidth) override;

View File

@ -133,7 +133,7 @@ QString FlatTextarea::tagsMimeType() {
return qsl("application/x-td-field-tags"); return qsl("application/x-td-field-tags");
} }
FlatTextarea::FlatTextarea(QWidget *parent, const style::FlatTextarea &st, const QString &pholder, const QString &v, const TagList &tags) : QTextEdit(parent) FlatTextarea::FlatTextarea(QWidget *parent, const style::FlatTextarea &st, const QString &pholder, const QString &v, const TagList &tags) : TWidgetHelper<QTextEdit>(parent)
, _placeholderVisible(!v.length()) , _placeholderVisible(!v.length())
, _lastTextWithTags { v, tags } , _lastTextWithTags { v, tags }
, _st(st) { , _st(st) {
@ -1464,7 +1464,7 @@ void FlatTextarea::contextMenuEvent(QContextMenuEvent *e) {
} }
} }
FlatInput::FlatInput(QWidget *parent, const style::FlatInput &st, const QString &pholder, const QString &v) : QLineEdit(v, parent) FlatInput::FlatInput(QWidget *parent, const style::FlatInput &st, const QString &pholder, const QString &v) : TWidgetHelper<QLineEdit>(v, parent)
, _oldtext(v) , _oldtext(v)
, _fullph(pholder) , _fullph(pholder)
, _placeholderVisible(!v.length()) , _placeholderVisible(!v.length())
@ -3228,7 +3228,7 @@ void InputField::setErrorShown(bool error) {
} }
} }
MaskedInputField::MaskedInputField(QWidget *parent, const style::InputField &st, const QString &placeholder, const QString &val) : QLineEdit(val, parent) MaskedInputField::MaskedInputField(QWidget *parent, const style::InputField &st, const QString &placeholder, const QString &val) : TWidgetHelper<QLineEdit>(val, parent)
, _st(st) , _st(st)
, _oldtext(val) , _oldtext(val)
, _placeholderFull(placeholder) { , _placeholderFull(placeholder) {

View File

@ -28,9 +28,8 @@ namespace Ui {
static UserData * const LookingUpInlineBot = SharedMemoryLocation<UserData, 0>(); static UserData * const LookingUpInlineBot = SharedMemoryLocation<UserData, 0>();
class FlatTextarea : public QTextEdit, private base::Subscriber { class FlatTextarea : public TWidgetHelper<QTextEdit>, private base::Subscriber {
Q_OBJECT Q_OBJECT
T_WIDGET
public: public:
using TagList = TextWithTags::Tags; using TagList = TextWithTags::Tags;
@ -112,10 +111,6 @@ public:
}; };
void setTagMimeProcessor(std_::unique_ptr<TagMimeProcessor> &&processor); void setTagMimeProcessor(std_::unique_ptr<TagMimeProcessor> &&processor);
QMargins getMargins() const {
return QMargins();
}
public slots: public slots:
void onTouchTimer(); void onTouchTimer();
@ -243,9 +238,8 @@ inline bool operator!=(const FlatTextarea::LinkRange &a, const FlatTextarea::Lin
return !(a == b); return !(a == b);
} }
class FlatInput : public QLineEdit, private base::Subscriber { class FlatInput : public TWidgetHelper<QLineEdit>, private base::Subscriber {
Q_OBJECT Q_OBJECT
T_WIDGET
public: public:
FlatInput(QWidget *parent, const style::FlatInput &st, const QString &ph = QString(), const QString &val = QString()); FlatInput(QWidget *parent, const style::FlatInput &st, const QString &ph = QString(), const QString &val = QString());
@ -264,10 +258,6 @@ public:
return _oldtext; return _oldtext;
} }
QMargins getMargins() const {
return QMargins();
}
public slots: public slots:
void onTextChange(const QString &text); void onTextChange(const QString &text);
void onTextEdited(); void onTextEdited();
@ -694,9 +684,8 @@ private:
bool _correcting = false; bool _correcting = false;
}; };
class MaskedInputField : public QLineEdit, private base::Subscriber { class MaskedInputField : public TWidgetHelper<QLineEdit>, private base::Subscriber {
Q_OBJECT Q_OBJECT
T_WIDGET
public: public:
MaskedInputField(QWidget *parent, const style::InputField &st, const QString &placeholder = QString(), const QString &val = QString()); MaskedInputField(QWidget *parent, const style::InputField &st, const QString &placeholder = QString(), const QString &val = QString());
@ -729,10 +718,6 @@ public:
startPlaceholderAnimation(); startPlaceholderAnimation();
} }
QMargins getMargins() const {
return QMargins();
}
public slots: public slots:
void onTextChange(const QString &text); void onTextChange(const QString &text);
void onCursorPositionChanged(int oldPosition, int position); void onCursorPositionChanged(int oldPosition, int position);

View File

@ -359,12 +359,12 @@ void FlatLabel::mouseDoubleClickEvent(QMouseEvent *e) {
} }
} }
void FlatLabel::enterEvent(QEvent *e) { void FlatLabel::enterEventHook(QEvent *e) {
_lastMousePos = QCursor::pos(); _lastMousePos = QCursor::pos();
dragActionUpdate(); dragActionUpdate();
} }
void FlatLabel::leaveEvent(QEvent *e) { void FlatLabel::leaveEventHook(QEvent *e) {
ClickHandler::clearActive(this); ClickHandler::clearActive(this);
} }

View File

@ -120,8 +120,8 @@ protected:
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void mouseDoubleClickEvent(QMouseEvent *e) override; void mouseDoubleClickEvent(QMouseEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void focusOutEvent(QFocusEvent *e) override; void focusOutEvent(QFocusEvent *e) override;
void focusInEvent(QFocusEvent *e) override; void focusInEvent(QFocusEvent *e) override;
void keyPressEvent(QKeyEvent *e) override; void keyPressEvent(QKeyEvent *e) override;

View File

@ -298,17 +298,17 @@ void Menu::clearMouseSelection() {
} }
} }
void Menu::enterEvent(QEvent *e) { void Menu::enterEventHook(QEvent *e) {
QPoint mouse = QCursor::pos(); QPoint mouse = QCursor::pos();
if (!rect().marginsRemoved(QMargins(0, _st.skip, 0, _st.skip)).contains(mapFromGlobal(mouse))) { if (!rect().marginsRemoved(QMargins(0, _st.skip, 0, _st.skip)).contains(mapFromGlobal(mouse))) {
clearMouseSelection(); clearMouseSelection();
} }
return TWidget::enterEvent(e); return TWidget::enterEventHook(e);
} }
void Menu::leaveEvent(QEvent *e) { void Menu::leaveEventHook(QEvent *e) {
clearMouseSelection(); clearMouseSelection();
return TWidget::leaveEvent(e); return TWidget::leaveEventHook(e);
} }
void Menu::setSelected(int selected) { void Menu::setSelected(int selected) {

View File

@ -89,8 +89,8 @@ protected:
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private slots: private slots:
void actionChanged(); void actionChanged();

View File

@ -606,7 +606,7 @@ QMargins MultiSelect::Inner::itemPaintMargins() const {
}; };
} }
void MultiSelect::Inner::leaveEvent(QEvent *e) { void MultiSelect::Inner::leaveEventHook(QEvent *e) {
clearSelection(); clearSelection();
} }

View File

@ -100,7 +100,7 @@ protected:
int resizeGetHeight(int newWidth) override; int resizeGetHeight(int newWidth) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void keyPressEvent(QKeyEvent *e) override; void keyPressEvent(QKeyEvent *e) override;

View File

@ -40,7 +40,7 @@ void ScrollShadow::changeVisibility(bool shown) {
setVisible(shown); setVisible(shown);
} }
ScrollBar::ScrollBar(ScrollArea *parent, bool vert, const style::ScrollArea *st) : QWidget(parent) ScrollBar::ScrollBar(ScrollArea *parent, bool vert, const style::ScrollArea *st) : TWidget(parent)
, _st(st) , _st(st)
, _vertical(vert) , _vertical(vert)
, _hiding(_st->hiding != 0) , _hiding(_st->hiding != 0)
@ -214,13 +214,13 @@ void ScrollBar::hideTimeout(TimeMs dt) {
} }
} }
void ScrollBar::enterEvent(QEvent *e) { void ScrollBar::enterEventHook(QEvent *e) {
_hideTimer.stop(); _hideTimer.stop();
setMouseTracking(true); setMouseTracking(true);
setOver(true); setOver(true);
} }
void ScrollBar::leaveEvent(QEvent *e) { void ScrollBar::leaveEventHook(QEvent *e) {
if (!_moving) { if (!_moving) {
setMouseTracking(false); setMouseTracking(false);
} }
@ -320,7 +320,7 @@ void SplittedWidgetOther::paintEvent(QPaintEvent *e) {
} }
} }
ScrollArea::ScrollArea(QWidget *parent, const style::ScrollArea &st, bool handleTouch) : QScrollArea(parent) ScrollArea::ScrollArea(QWidget *parent, const style::ScrollArea &st, bool handleTouch) : TWidgetHelper<QScrollArea>(parent)
, _st(st) , _st(st)
, _horizontalBar(this, false, &_st) , _horizontalBar(this, false, &_st)
, _verticalBar(this, true, &_st) , _verticalBar(this, true, &_st)

View File

@ -51,7 +51,7 @@ private:
}; };
class ScrollBar : public QWidget { class ScrollBar : public TWidget {
Q_OBJECT Q_OBJECT
public: public:
@ -73,8 +73,8 @@ signals:
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
@ -170,9 +170,8 @@ private:
}; };
class SplittedWidgetOther; class SplittedWidgetOther;
class ScrollArea : public QScrollArea { class ScrollArea : public TWidgetHelper<QScrollArea> {
Q_OBJECT Q_OBJECT
T_WIDGET
public: public:
ScrollArea(QWidget *parent, const style::ScrollArea &st = st::defaultScrollArea, bool handleTouch = true); ScrollArea(QWidget *parent, const style::ScrollArea &st = st::defaultScrollArea, bool handleTouch = true);
@ -205,10 +204,6 @@ public:
bool viewportEvent(QEvent *e) override; bool viewportEvent(QEvent *e) override;
void keyPressEvent(QKeyEvent *e) override; void keyPressEvent(QKeyEvent *e) override;
QMargins getMargins() const {
return QMargins();
}
protected: protected:
bool eventFilter(QObject *obj, QEvent *e) override; bool eventFilter(QObject *obj, QEvent *e) override;

View File

@ -792,7 +792,7 @@ bool Notification::unlinkHistory(History *history) {
return unlink; return unlink;
} }
void Notification::enterEvent(QEvent *e) { void Notification::enterEventHook(QEvent *e) {
if (!_history) return; if (!_history) return;
if (auto manager = ManagerInstance.data()) { if (auto manager = ManagerInstance.data()) {
manager->stopAllHiding(); manager->stopAllHiding();
@ -802,7 +802,7 @@ void Notification::enterEvent(QEvent *e) {
} }
} }
void Notification::leaveEvent(QEvent *e) { void Notification::leaveEventHook(QEvent *e) {
if (!_history) return; if (!_history) return;
if (auto manager = ManagerInstance.data()) { if (auto manager = ManagerInstance.data()) {
manager->startAllHiding(); manager->startAllHiding();
@ -892,12 +892,12 @@ HideAllButton::~HideAllButton() {
} }
} }
void HideAllButton::enterEvent(QEvent *e) { void HideAllButton::enterEventHook(QEvent *e) {
_mouseOver = true; _mouseOver = true;
update(); update();
} }
void HideAllButton::leaveEvent(QEvent *e) { void HideAllButton::leaveEventHook(QEvent *e) {
_mouseOver = false; _mouseOver = false;
update(); update();
} }

View File

@ -203,8 +203,8 @@ public:
~Notification(); ~Notification();
protected: protected:
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
bool eventFilter(QObject *o, QEvent *e) override; bool eventFilter(QObject *o, QEvent *e) override;
@ -269,8 +269,8 @@ public:
~HideAllButton(); ~HideAllButton();
protected: protected:
void enterEvent(QEvent *e) override; void enterEventHook(QEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;

View File

@ -621,7 +621,7 @@ void EditorBlock::updateSelected(QPoint localPosition) {
setSelected(underMouseIndex); setSelected(underMouseIndex);
} }
void EditorBlock::leaveEvent(QEvent *e) { void EditorBlock::leaveEventHook(QEvent *e) {
_mouseSelection = false; _mouseSelection = false;
setSelected(-1); setSelected(-1);
} }

View File

@ -92,7 +92,7 @@ protected:
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
void leaveEvent(QEvent *e) override; void leaveEventHook(QEvent *e) override;
private: private:
class Row; class Row;