2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-04-07 18:05:28 +00:00
|
|
|
#include "ui/twidget.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
class DragArea : public TWidget {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
DragArea(QWidget *parent);
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
2017-02-26 11:32:13 +00:00
|
|
|
void setDroppedCallback(base::lambda<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;
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
|
|
|
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
|
|
|
void dropEvent(QDropEvent *e) override;
|
|
|
|
void dragMoveEvent(QDragMoveEvent *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;
|
2016-11-28 15:45:07 +00:00
|
|
|
base::lambda<void(const QMimeData *data)> _droppedCallback;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-07 13:32:25 +00:00
|
|
|
Animation _a_opacity;
|
|
|
|
Animation _a_in;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QString _text, _subtext;
|
|
|
|
|
|
|
|
};
|