init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
78
Telegram/SourceFiles/history/history_drag_area.h
Normal file
78
Telegram/SourceFiles/history/history_drag_area.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "ui/rp_widget.h"
|
||||
#include "ui/effects/animations.h"
|
||||
|
||||
namespace Storage {
|
||||
enum class MimeDataState;
|
||||
} // namespace Storage
|
||||
|
||||
class DragArea : public Ui::RpWidget {
|
||||
public:
|
||||
DragArea(QWidget *parent);
|
||||
|
||||
struct Areas {
|
||||
DragArea *document;
|
||||
DragArea *photo;
|
||||
};
|
||||
|
||||
using CallbackComputeState
|
||||
= Fn<Storage::MimeDataState(const QMimeData *data)>;
|
||||
|
||||
static Areas SetupDragAreaToContainer(
|
||||
not_null<Ui::RpWidget*> container,
|
||||
Fn<bool(not_null<const QMimeData*>)> &&dragEnterFilter = nullptr,
|
||||
Fn<void(bool)> &&setAcceptDropsField = nullptr,
|
||||
Fn<void()> &&updateControlsGeometry = nullptr,
|
||||
CallbackComputeState &&computeState = nullptr,
|
||||
bool hideSubtext = false);
|
||||
|
||||
void setText(const QString &text, const QString &subtext);
|
||||
|
||||
void otherEnter();
|
||||
void otherLeave();
|
||||
|
||||
bool overlaps(const QRect &globalRect);
|
||||
|
||||
void hideFast();
|
||||
|
||||
void setDroppedCallback(Fn<void(const QMimeData *data)> callback) {
|
||||
_droppedCallback = std::move(callback);
|
||||
}
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
void dragMoveEvent(QDragMoveEvent *e) override;
|
||||
// These events should be filtered by parent!
|
||||
void dragEnterEvent(QDragEnterEvent *e) override;
|
||||
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
||||
void dropEvent(QDropEvent *e) override;
|
||||
|
||||
private:
|
||||
void hideStart();
|
||||
void hideFinish();
|
||||
|
||||
void showStart();
|
||||
|
||||
void setIn(bool in);
|
||||
void opacityAnimationCallback();
|
||||
|
||||
bool _hiding = false;
|
||||
bool _in = false;
|
||||
QPixmap _cache;
|
||||
Fn<void(const QMimeData *data)> _droppedCallback;
|
||||
|
||||
Ui::Animations::Simple _a_opacity;
|
||||
Ui::Animations::Simple _a_in;
|
||||
|
||||
QString _text, _subtext;
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user