mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
drag-n-drop files to dialogs list
This commit is contained in:
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user