DropSite example: support markdown
If the mime data includes text/markdown, display it decoded in the QLabel,
and also display the raw markdown in the table below. QLabel supports
markdown since 51cbd5288c.
Ideally we should add proper support for markdown to QMimeData, but
it's too late to do that for Qt 5.
Pick-to: 5.15
Change-Id: I2a9998e4b239658fe49f39786e7c4fdd0c08b21a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
bb10
parent
93ac7b9d17
commit
4edcea762d
|
|
@ -93,6 +93,9 @@ void DropArea::dropEvent(QDropEvent *event)
|
|||
//! [dropEvent() function part2]
|
||||
if (mimeData->hasImage()) {
|
||||
setPixmap(qvariant_cast<QPixmap>(mimeData->imageData()));
|
||||
} else if (mimeData->hasFormat(QLatin1String("text/markdown"))) {
|
||||
setText(QString::fromUtf8(mimeData->data(QLatin1String("text/markdown"))));
|
||||
setTextFormat(Qt::MarkdownText);
|
||||
} else if (mimeData->hasHtml()) {
|
||||
setText(mimeData->html());
|
||||
setTextFormat(Qt::RichText);
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData)
|
|||
QString text;
|
||||
if (format == QLatin1String("text/plain")) {
|
||||
text = mimeData->text().simplified();
|
||||
} else if (format == QLatin1String("text/markdown")) {
|
||||
text = QString::fromUtf8(mimeData->data(QLatin1String("text/markdown")));
|
||||
} else if (format == QLatin1String("text/html")) {
|
||||
text = mimeData->html().simplified();
|
||||
} else if (format == QLatin1String("text/uri-list")) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue