Commit 7bfca147 authored by Agata Cacko's avatar Agata Cacko
Browse files

Fix High DPI for canvas previews in Undo History docker

Before this commit, canvas previews/thumbnails in the
Undo History docker were low resolution on High DPI screen.
This commit make them high resolution (respect devicePixelRatio).
Because there is no item delegate and no manual paint command,
it required adding a devicePixelRatio parameter to the Model.
parent c93afb7d
......@@ -255,9 +255,11 @@ void KisUndoModel::addImage(int idx)
if (m_stack->count() == idx && !m_imageMap.contains(currentCommand)) {
KisImageWSP historyImage = m_canvas->image();
KisPaintDeviceSP paintDevice = historyImage->projection();
QImage image = paintDevice->createThumbnail(32, 32, 1,
QSize size = QSize(32, 32)*m_devicePixelRatioF;
QImage image = paintDevice->createThumbnail(size.width(), size.height(), 1,
KoColorConversionTransformation::internalRenderingIntent(),
KoColorConversionTransformation::internalConversionFlags());
image.setDevicePixelRatio(m_devicePixelRatioF);
m_imageMap[currentCommand] = image;
}
......@@ -281,3 +283,8 @@ bool KisUndoModel::checkMergedCommand(int index)
Q_UNUSED(index)
return false;
}
void KisUndoModel::setDevicePixelRatio(qreal devicePixelRatio)
{
m_devicePixelRatioF = devicePixelRatio;
}
......@@ -93,6 +93,14 @@ public:
void setCanvas(KisCanvas2* canvas);
bool checkMergedCommand(int index);
// It's a bit weird to have "setDevicePixelRatio"
// in a model class, but it's needed for
// QImages inside, because there is no
// ItemDelegate for the items,
// so it's better to initialize QImages already
// devicePixelRatio-corrected.
void setDevicePixelRatio(qreal devicePixelRatio);
public Q_SLOTS:
void setStack(KUndo2QStack *stack);
void addImage(int idx);
......@@ -110,5 +118,6 @@ private:
QIcon m_clean_icon;
QPointer<KisCanvas2> m_canvas;
QMap<const KUndo2Command*, QImage> m_imageMap;
qreal m_devicePixelRatioF {1.0};
};
#endif
......@@ -118,6 +118,7 @@ void KisUndoViewPrivate::init(KisUndoView* view)
{
q = view;
model = new KisUndoModel(q);
model->setDevicePixelRatio(view->devicePixelRatioF());
q->setModel(model);
q->setSelectionModel(model->selectionModel());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment