mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
MdEditor: copy backgorund when copying in-place preview
This commit is contained in:
parent
bcb307aa4b
commit
c2bb490378
@ -1625,6 +1625,7 @@ bool VMdEditor::initInPlacePreviewMenu(QAction *p_before,
|
|||||||
}
|
}
|
||||||
|
|
||||||
QPixmap image;
|
QPixmap image;
|
||||||
|
QString background;
|
||||||
int pib = p_pos - p_block.position();
|
int pib = p_pos - p_block.position();
|
||||||
for (auto info : previews) {
|
for (auto info : previews) {
|
||||||
const VPreviewedImageInfo &pii = info->m_imageInfo;
|
const VPreviewedImageInfo &pii = info->m_imageInfo;
|
||||||
@ -1632,6 +1633,7 @@ bool VMdEditor::initInPlacePreviewMenu(QAction *p_before,
|
|||||||
const QPixmap *img = findImage(pii.m_imageName);
|
const QPixmap *img = findImage(pii.m_imageName);
|
||||||
if (img) {
|
if (img) {
|
||||||
image = *img;
|
image = *img;
|
||||||
|
background = pii.m_background;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1644,10 +1646,20 @@ bool VMdEditor::initInPlacePreviewMenu(QAction *p_before,
|
|||||||
|
|
||||||
QAction *copyImageAct = new QAction(tr("Copy In-Place Preview"), p_menu);
|
QAction *copyImageAct = new QAction(tr("Copy In-Place Preview"), p_menu);
|
||||||
connect(copyImageAct, &QAction::triggered,
|
connect(copyImageAct, &QAction::triggered,
|
||||||
this, [this, image]() {
|
this, [this, image, background]() {
|
||||||
|
QColor co(background);
|
||||||
|
if (!co.isValid()) {
|
||||||
|
co = palette().color(QPalette::Base);
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage img(image.size(), QImage::Format_ARGB32);
|
||||||
|
img.fill(co);
|
||||||
|
QPainter pter(&img);
|
||||||
|
pter.drawPixmap(img.rect(), image);
|
||||||
|
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
VClipboardUtils::setImageToClipboard(clipboard,
|
VClipboardUtils::setImageToClipboard(clipboard,
|
||||||
image,
|
img,
|
||||||
QClipboard::Clipboard);
|
QClipboard::Clipboard);
|
||||||
});
|
});
|
||||||
p_menu->insertAction(p_before, copyImageAct);
|
p_menu->insertAction(p_before, copyImageAct);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user