2014-05-30 12:53:19 +04:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2014-05-30 12:53:19 +04:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-04-07 22:05:28 +04:00
|
|
|
#include "ui/twidget.h"
|
2019-04-02 13:13:30 +04:00
|
|
|
#include "ui/effects/animations.h"
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2015-12-08 15:33:37 +03:00
|
|
|
class DragArea : public TWidget {
|
2014-05-30 12:53:19 +04:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
DragArea(QWidget *parent);
|
|
|
|
|
|
|
|
void setText(const QString &text, const QString &subtext);
|
|
|
|
|
|
|
|
void otherEnter();
|
|
|
|
void otherLeave();
|
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
bool overlaps(const QRect &globalRect);
|
2015-10-01 17:05:05 +03:00
|
|
|
|
2016-10-26 19:43:13 +03:00
|
|
|
void hideFast();
|
|
|
|
|
2018-06-04 18:35:11 +03:00
|
|
|
void setDroppedCallback(Fn<void(const QMimeData *data)> callback) {
|
2017-02-21 16:45:56 +03:00
|
|
|
_droppedCallback = std::move(callback);
|
2016-11-28 18:45:07 +03:00
|
|
|
}
|
|
|
|
|
2016-10-01 15:34:23 +03:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
|
|
|
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
|
|
|
void dropEvent(QDropEvent *e) override;
|
|
|
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
|
|
|
|
2014-05-30 12:53:19 +04:00
|
|
|
public slots:
|
|
|
|
void hideStart();
|
|
|
|
void hideFinish();
|
|
|
|
|
|
|
|
void showStart();
|
|
|
|
|
|
|
|
private:
|
2016-12-07 16:32:25 +03:00
|
|
|
void setIn(bool in);
|
|
|
|
void opacityAnimationCallback();
|
2016-12-13 20:07:56 +03:00
|
|
|
QRect innerRect() const {
|
|
|
|
return QRect(
|
|
|
|
st::dragPadding.left(),
|
|
|
|
st::dragPadding.top(),
|
|
|
|
width() - st::dragPadding.left() - st::dragPadding.right(),
|
|
|
|
height() - st::dragPadding.top() - st::dragPadding.bottom()
|
|
|
|
);
|
|
|
|
}
|
2016-12-07 16:32:25 +03:00
|
|
|
|
|
|
|
bool _hiding = false;
|
|
|
|
bool _in = false;
|
2016-12-13 20:07:56 +03:00
|
|
|
QPixmap _cache;
|
2018-06-04 18:35:11 +03:00
|
|
|
Fn<void(const QMimeData *data)> _droppedCallback;
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2019-04-02 13:13:30 +04:00
|
|
|
Ui::Animations::Simple _a_opacity;
|
|
|
|
Ui::Animations::Simple _a_in;
|
2014-05-30 12:53:19 +04:00
|
|
|
|
|
|
|
QString _text, _subtext;
|
|
|
|
|
|
|
|
};
|