mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 06:19:52 +08:00
preview: scaled in-place preview of diagrams
This commit is contained in:
parent
423cc76ee5
commit
14070ab67a
@ -402,6 +402,8 @@ void VLivePreviewHelper::processForInplacePreview(int p_idx)
|
|||||||
|
|
||||||
void VLivePreviewHelper::updateInplacePreview()
|
void VLivePreviewHelper::updateInplacePreview()
|
||||||
{
|
{
|
||||||
|
Qt::TransformationMode tMode = Qt::SmoothTransformation;
|
||||||
|
qreal sf = VUtils::calculateScaleFactor();
|
||||||
QSet<int> blocks;
|
QSet<int> blocks;
|
||||||
QVector<QSharedPointer<VImageToPreview> > images;
|
QVector<QSharedPointer<VImageToPreview> > images;
|
||||||
for (int i = 0; i < m_codeBlocks.size(); ++i) {
|
for (int i = 0; i < m_codeBlocks.size(); ++i) {
|
||||||
@ -410,13 +412,27 @@ void VLivePreviewHelper::updateInplacePreview()
|
|||||||
// Generate the image.
|
// Generate the image.
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
if (cb.hasImageData()) {
|
if (cb.hasImageData()) {
|
||||||
cb.inplacePreview()->m_image.loadFromData(cb.imageData().toUtf8(),
|
QPixmap tmpImg;
|
||||||
cb.imageFormat().toLocal8Bit().data());
|
tmpImg.loadFromData(cb.imageData().toUtf8(),
|
||||||
|
cb.imageFormat().toLocal8Bit().data());
|
||||||
|
if (sf < 1.1) {
|
||||||
|
cb.inplacePreview()->m_image.swap(tmpImg);
|
||||||
|
} else {
|
||||||
|
cb.inplacePreview()->m_image = tmpImg.scaledToWidth(tmpImg.width() * sf, tMode);
|
||||||
|
}
|
||||||
|
|
||||||
images.append(cb.inplacePreview());
|
images.append(cb.inplacePreview());
|
||||||
valid = true;
|
valid = true;
|
||||||
} else if (cb.hasImageDataBa()) {
|
} else if (cb.hasImageDataBa()) {
|
||||||
cb.inplacePreview()->m_image.loadFromData(cb.imageDataBa(),
|
QPixmap tmpImg;
|
||||||
cb.imageFormat().toLocal8Bit().data());
|
tmpImg.loadFromData(cb.imageDataBa(),
|
||||||
|
cb.imageFormat().toLocal8Bit().data());
|
||||||
|
if (sf < 1.1) {
|
||||||
|
cb.inplacePreview()->m_image.swap(tmpImg);
|
||||||
|
} else {
|
||||||
|
cb.inplacePreview()->m_image = tmpImg.scaledToWidth(tmpImg.width() * sf, tMode);
|
||||||
|
}
|
||||||
|
|
||||||
images.append(cb.inplacePreview());
|
images.append(cb.inplacePreview());
|
||||||
valid = true;
|
valid = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user