2014-05-30 08:53:19 +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.
|
2014-05-30 08:53:19 +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
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2019-09-13 12:22:54 +00:00
|
|
|
#include "ui/rp_widget.h"
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2020-06-09 23:29:24 +00:00
|
|
|
class DragArea : public Ui::RpWidget {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
DragArea(QWidget *parent);
|
|
|
|
|
2020-06-09 23:29:24 +00:00
|
|
|
struct Areas {
|
|
|
|
DragArea *document;
|
|
|
|
DragArea *photo;
|
|
|
|
};
|
|
|
|
static Areas SetupDragAreaToContainer(
|
|
|
|
not_null<Ui::RpWidget*> container,
|
|
|
|
Fn<bool()> &&dragEnterFilter = nullptr,
|
|
|
|
Fn<void(bool)> &&setAcceptDropsField = nullptr,
|
|
|
|
Fn<void()> &&updateControlsGeometry = nullptr);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void setText(const QString &text, const QString &subtext);
|
|
|
|
|
|
|
|
void otherEnter();
|
|
|
|
void otherLeave();
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
bool overlaps(const QRect &globalRect);
|
2015-10-01 14:05:05 +00:00
|
|
|
|
2016-10-26 16:43:13 +00:00
|
|
|
void hideFast();
|
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
void setDroppedCallback(Fn<void(const QMimeData *data)> callback) {
|
2017-02-21 13:45:56 +00:00
|
|
|
_droppedCallback = std::move(callback);
|
2016-11-28 15:45:07 +00:00
|
|
|
}
|
|
|
|
|
2016-10-01 12:34:23 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
2020-06-09 23:29:24 +00:00
|
|
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
|
|
|
// These events should be filtered by parent!
|
2016-10-01 12:34:23 +00:00
|
|
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
|
|
|
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
|
|
|
void dropEvent(QDropEvent *e) override;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
public slots:
|
|
|
|
void hideStart();
|
|
|
|
void hideFinish();
|
|
|
|
|
|
|
|
void showStart();
|
|
|
|
|
|
|
|
private:
|
2016-12-07 13:32:25 +00:00
|
|
|
void setIn(bool in);
|
|
|
|
void opacityAnimationCallback();
|
2016-12-13 17:07:56 +00: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 13:32:25 +00:00
|
|
|
|
|
|
|
bool _hiding = false;
|
|
|
|
bool _in = false;
|
2016-12-13 17:07:56 +00:00
|
|
|
QPixmap _cache;
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void(const QMimeData *data)> _droppedCallback;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _a_opacity;
|
|
|
|
Ui::Animations::Simple _a_in;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QString _text, _subtext;
|
|
|
|
|
|
|
|
};
|