mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-10 00:29:31 +00:00
Merge branch 'master' of https://github.com/telegramdesktop/tdesktop
This commit is contained in:
commit
b84101b12e
@ -139,6 +139,8 @@ enum {
|
||||
|
||||
WrongPasscodeTimeout = 1500,
|
||||
SessionsShortPollTimeout = 60000,
|
||||
|
||||
ChoosePeerByDragTimeout = 1000, // 1 second mouse not moved to choose dialog when dragging a file
|
||||
};
|
||||
|
||||
inline bool isServiceUser(uint64 id) {
|
||||
|
@ -1410,6 +1410,9 @@ DialogsWidget::DialogsWidget(MainWidget *parent) : QWidget(parent)
|
||||
connect(&_newGroup, SIGNAL(clicked()), this, SLOT(onNewGroup()));
|
||||
connect(&_cancelSearch, SIGNAL(clicked()), this, SLOT(onCancelSearch()));
|
||||
|
||||
_chooseByDragTimer.setSingleShot(true);
|
||||
connect(&_chooseByDragTimer, SIGNAL(timeout()), this, SLOT(onChooseByDrag()));
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
_searchTimer.setSingleShot(true);
|
||||
@ -1628,6 +1631,10 @@ void DialogsWidget::onNeedSearchMessages() {
|
||||
}
|
||||
}
|
||||
|
||||
void DialogsWidget::onChooseByDrag() {
|
||||
list.choosePeer();
|
||||
}
|
||||
|
||||
void DialogsWidget::searchMessages(const QString &query) {
|
||||
if (_filter.text() != query) {
|
||||
_filter.setText(query);
|
||||
@ -1774,15 +1781,20 @@ void DialogsWidget::dragEnterEvent(QDragEnterEvent *e) {
|
||||
e->setDropAction(Qt::CopyAction);
|
||||
e->accept();
|
||||
updateDragInScroll(scroll.geometry().contains(e->pos()));
|
||||
} else if (false && App::main() && App::main()->getDragState(e->mimeData()) != DragStateNone) {
|
||||
} else if (App::main() && App::main()->getDragState(e->mimeData()) != DragStateNone) {
|
||||
e->setDropAction(Qt::CopyAction);
|
||||
e->accept();
|
||||
}
|
||||
_chooseByDragTimer.stop();
|
||||
}
|
||||
|
||||
void DialogsWidget::dragMoveEvent(QDragMoveEvent *e) {
|
||||
if (scroll.geometry().contains(e->pos())) {
|
||||
if (_dragForward) updateDragInScroll(true);
|
||||
if (_dragForward) {
|
||||
updateDragInScroll(true);
|
||||
} else {
|
||||
_chooseByDragTimer.start(ChoosePeerByDragTimeout);
|
||||
}
|
||||
PeerData *p = list.updateFromParentDrag(mapToGlobal(e->pos()));
|
||||
if (p) {
|
||||
e->setDropAction(Qt::CopyAction);
|
||||
@ -1798,7 +1810,11 @@ void DialogsWidget::dragMoveEvent(QDragMoveEvent *e) {
|
||||
}
|
||||
|
||||
void DialogsWidget::dragLeaveEvent(QDragLeaveEvent *e) {
|
||||
if (_dragForward) updateDragInScroll(false);
|
||||
if (_dragForward) {
|
||||
updateDragInScroll(false);
|
||||
} else {
|
||||
_chooseByDragTimer.stop();
|
||||
}
|
||||
list.leaveEvent(0);
|
||||
e->accept();
|
||||
}
|
||||
@ -1815,6 +1831,7 @@ void DialogsWidget::updateDragInScroll(bool inScroll) {
|
||||
}
|
||||
|
||||
void DialogsWidget::dropEvent(QDropEvent *e) {
|
||||
_chooseByDragTimer.stop();
|
||||
if (scroll.geometry().contains(e->pos())) {
|
||||
PeerData *p = list.updateFromParentDrag(mapToGlobal(e->pos()));
|
||||
if (p) {
|
||||
@ -1822,7 +1839,7 @@ void DialogsWidget::dropEvent(QDropEvent *e) {
|
||||
if (e->mimeData()->hasFormat(qsl("application/x-td-forward-selected"))) {
|
||||
App::main()->onForward(p->id, true);
|
||||
} else {
|
||||
App::main()->showPeer(p->id, 0, false, true);
|
||||
App::main()->onFilesDrop(p->id, e->mimeData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -236,11 +236,14 @@ public slots:
|
||||
bool onSearchMessages(bool searchCache = false);
|
||||
void onNeedSearchMessages();
|
||||
|
||||
void onChooseByDrag();
|
||||
|
||||
private:
|
||||
|
||||
bool _drawShadow;
|
||||
|
||||
bool _dragInScroll, _dragForward;
|
||||
QTimer _chooseByDragTimer;
|
||||
|
||||
void unreadCountsReceived(const QVector<MTPDialog> &dialogs);
|
||||
bool dialogsFailed(const RPCError &error);
|
||||
|
@ -384,7 +384,7 @@ void DragArea::dragLeaveEvent(QDragLeaveEvent *e) {
|
||||
void DragArea::dropEvent(QDropEvent *e) {
|
||||
static_cast<HistoryWidget*>(parentWidget())->dropEvent(e);
|
||||
if (e->isAccepted()) {
|
||||
emit dropped(e);
|
||||
emit dropped(e->mimeData());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ public:
|
||||
|
||||
signals:
|
||||
|
||||
void dropped(QDropEvent *e);
|
||||
void dropped(const QMimeData *data);
|
||||
|
||||
public slots:
|
||||
|
||||
|
@ -2243,8 +2243,8 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
|
||||
_attachDragDocument.hide();
|
||||
_attachDragPhoto.hide();
|
||||
|
||||
connect(&_attachDragDocument, SIGNAL(dropped(QDropEvent*)), this, SLOT(onDocumentDrop(QDropEvent*)));
|
||||
connect(&_attachDragPhoto, SIGNAL(dropped(QDropEvent*)), this, SLOT(onPhotoDrop(QDropEvent*)));
|
||||
connect(&_attachDragDocument, SIGNAL(dropped(const QMimeData*)), this, SLOT(onDocumentDrop(const QMimeData*)));
|
||||
connect(&_attachDragPhoto, SIGNAL(dropped(const QMimeData*)), this, SLOT(onPhotoDrop(const QMimeData*)));
|
||||
}
|
||||
|
||||
void HistoryWidget::start() {
|
||||
@ -3931,15 +3931,45 @@ void HistoryWidget::dropEvent(QDropEvent *e) {
|
||||
e->acceptProposedAction();
|
||||
}
|
||||
|
||||
void HistoryWidget::onDocumentDrop(QDropEvent *e) {
|
||||
void HistoryWidget::onPhotoDrop(const QMimeData *data) {
|
||||
if (!hist) return;
|
||||
|
||||
QStringList files = getMediasFromMime(e->mimeData());
|
||||
if (data->hasImage()) {
|
||||
QImage image = qvariant_cast<QImage>(data->imageData());
|
||||
if (image.isNull()) return;
|
||||
|
||||
uploadImage(image, false, data->text());
|
||||
} else {
|
||||
QStringList files = getMediasFromMime(data);
|
||||
if (files.isEmpty()) return;
|
||||
|
||||
uploadMedias(files, ToPreparePhoto);
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryWidget::onDocumentDrop(const QMimeData *data) {
|
||||
if (!hist) return;
|
||||
|
||||
QStringList files = getMediasFromMime(data);
|
||||
if (files.isEmpty()) return;
|
||||
|
||||
uploadMedias(files, ToPrepareDocument);
|
||||
}
|
||||
|
||||
void HistoryWidget::onFilesDrop(const QMimeData *data) {
|
||||
if (data->hasImage()) {
|
||||
QImage image = qvariant_cast<QImage>(data->imageData());
|
||||
if (image.isNull()) return;
|
||||
|
||||
uploadImage(image, false, data->text());
|
||||
} else {
|
||||
QStringList files = getMediasFromMime(data);
|
||||
if (files.isEmpty()) return;
|
||||
|
||||
uploadMedias(files, ToPrepareAuto);
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryWidget::onKbToggle(bool manual) {
|
||||
if (_kbShown || _kbReplyTo) {
|
||||
_kbHide.hide();
|
||||
@ -4009,22 +4039,6 @@ void HistoryWidget::onCmdStart() {
|
||||
_field.moveCursor(QTextCursor::End);
|
||||
}
|
||||
|
||||
void HistoryWidget::onPhotoDrop(QDropEvent *e) {
|
||||
if (!hist) return;
|
||||
|
||||
if (e->mimeData()->hasImage()) {
|
||||
QImage image = qvariant_cast<QImage>(e->mimeData()->imageData());
|
||||
if (image.isNull()) return;
|
||||
|
||||
uploadImage(image);
|
||||
} else {
|
||||
QStringList files = getMediasFromMime(e->mimeData());
|
||||
if (files.isEmpty()) return;
|
||||
|
||||
uploadMedias(files, ToPreparePhoto);
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryWidget::contextMenuEvent(QContextMenuEvent *e) {
|
||||
if (!_list) return;
|
||||
|
||||
|
@ -509,8 +509,9 @@ public slots:
|
||||
|
||||
void onPhotoSelect();
|
||||
void onDocumentSelect();
|
||||
void onPhotoDrop(QDropEvent *e);
|
||||
void onDocumentDrop(QDropEvent *e);
|
||||
void onPhotoDrop(const QMimeData *data);
|
||||
void onDocumentDrop(const QMimeData *data);
|
||||
void onFilesDrop(const QMimeData *data);
|
||||
|
||||
void onKbToggle(bool manual = true);
|
||||
void onCmdStart();
|
||||
|
@ -571,6 +571,11 @@ void MainWidget::onSendPaths(const PeerId &peer) {
|
||||
history.onSendPaths(peer);
|
||||
}
|
||||
|
||||
void MainWidget::onFilesDrop(const PeerId &peer, const QMimeData *data) {
|
||||
showPeer(peer, 0, false, true);
|
||||
history.onFilesDrop(data);
|
||||
}
|
||||
|
||||
void MainWidget::noHider(HistoryHider *destroyed) {
|
||||
if (hider == destroyed) {
|
||||
hider = 0;
|
||||
@ -616,12 +621,13 @@ void MainWidget::hiderLayer(HistoryHider *h) {
|
||||
|
||||
hider = h;
|
||||
connect(hider, SIGNAL(forwarded()), &dialogs, SLOT(onCancelSearch()));
|
||||
dialogsToUp();
|
||||
if (cWideMode()) {
|
||||
hider->show();
|
||||
resizeEvent(0);
|
||||
dialogs.activate();
|
||||
} else {
|
||||
dialogsToUp();
|
||||
|
||||
hider->hide();
|
||||
dialogs.enableShadow(false);
|
||||
QPixmap animCache = myGrab(this, QRect(0, 0, _dialogsWidth, height()));
|
||||
|
@ -257,6 +257,7 @@ public:
|
||||
void onForward(const PeerId &peer, bool forwardSelected);
|
||||
void onShareContact(const PeerId &peer, UserData *contact);
|
||||
void onSendPaths(const PeerId &peer);
|
||||
void onFilesDrop(const PeerId &peer, const QMimeData *data);
|
||||
bool selectingPeer(bool withConfirm = false);
|
||||
void offerPeer(PeerId peer);
|
||||
void focusPeerSelect();
|
||||
|
Loading…
Reference in New Issue
Block a user