Add a combo box to change the QPicture scale of element picture

This is a test commit to see if we can fix the wrong scale of element in
some screen size.:
Add a QComboBox into the QToolBar of the diagram editor to change the
current scale factor of the element QPicture.
This commit is contained in:
joshua
2021-04-17 09:49:23 +02:00
parent b8d9d38d31
commit de2f161566
4 changed files with 45 additions and 0 deletions

View File

@@ -37,6 +37,8 @@
#include <QDomElement>
#include <utility>
qreal PICTURE_SCALE = 1;
class ElementXmlRetroCompatibility
{
friend class Element;
@@ -126,6 +128,11 @@ Element::Element(
});
}
void Element::setPictureScale(qreal scale)
{
PICTURE_SCALE = scale;
}
/**
@brief Element::~Element
*/
@@ -234,7 +241,17 @@ void Element::paint(
{
painter->drawPicture(0, 0, m_low_zoom_picture);
} else {
if (Q_UNLIKELY(PICTURE_SCALE != 1.0))
{
painter->save();
painter->scale(PICTURE_SCALE, PICTURE_SCALE);
painter->drawPicture(0, 0, m_picture);
painter->restore();
}
else
{
painter->drawPicture(0, 0, m_picture);
}
}
painter->restore(); //Restor the QPainter after use drawPicture