2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Implement drag-n-drop to forum topics.

This commit is contained in:
John Preston
2022-11-01 11:18:56 +04:00
parent 6d215d3729
commit d5ea0149e8
23 changed files with 232 additions and 133 deletions

View File

@@ -7,7 +7,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "core/mime_type.h"
#include "core/utils.h"
#include <QtCore/QMimeDatabase>
#include <QtCore/QMimeData>
namespace Core {
@@ -152,4 +155,19 @@ bool FileIsImage(const QString &name, const QString &mime) {
return false;
}
std::shared_ptr<QMimeData> ShareMimeMediaData(
not_null<const QMimeData*> original) {
auto result = std::make_shared<QMimeData>();
if (original->hasFormat(u"application/x-td-forward"_q)) {
result->setData(u"application/x-td-forward"_q, "1");
}
if (original->hasImage()) {
result->setImageData(original->imageData());
}
if (auto list = base::GetMimeUrls(original); !list.isEmpty()) {
result->setUrls(std::move(list));
}
return result;
}
} // namespace Core

View File

@@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtCore/QStringList>
#include <QtCore/QMimeType>
class QMimeData;
namespace Core {
class MimeType {
@@ -47,4 +49,7 @@ private:
[[nodiscard]] bool FileIsImage(const QString &name, const QString &mime);
[[nodiscard]] std::shared_ptr<QMimeData> ShareMimeMediaData(
not_null<const QMimeData*> original);
} // namespace Core