Merge pull request #2711 from manongjohn/fix_schematic_spline_toggles

Fix schematic spline option icon zooming
This commit is contained in:
Rodney 2019-08-22 12:00:09 -05:00 committed by GitHub
commit bc1c45412d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 13 deletions

View file

@ -144,13 +144,13 @@ signals:
class SchematicToggle_SplineOptions final : public SchematicToggle { class SchematicToggle_SplineOptions final : public SchematicToggle {
Q_OBJECT Q_OBJECT
public: public:
SchematicToggle_SplineOptions(SchematicNode *parent, const QPixmap &pixmap, SchematicToggle_SplineOptions(SchematicNode *parent, const QIcon &imageIcon,
int flags) int flags)
: SchematicToggle(parent, QIcon(pixmap), QColor(0, 0, 0, 0), flags) {} : SchematicToggle(parent, imageIcon, QColor(0, 0, 0, 0), flags) {}
SchematicToggle_SplineOptions(SchematicNode *parent, const QPixmap &pixmap1, SchematicToggle_SplineOptions(SchematicNode *parent, const QIcon &imageIcon,
const QPixmap &pixmap2, int flags) const QIcon &imageIcon2, int flags)
: SchematicToggle(parent, QIcon(pixmap1), QIcon(pixmap2), : SchematicToggle(parent, imageIcon, imageIcon2, QColor(0, 0, 0, 0),
QColor(0, 0, 0, 0), flags) {} flags) {}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = 0) override; QWidget *widget = 0) override;

View file

@ -334,10 +334,9 @@ void SchematicToggle_SplineOptions::paint(
if (m_state != 0) { if (m_state != 0) {
QIcon &pix = QIcon &pix =
(m_state == 2 && !m_imageOn2.isNull()) ? m_imageOn2 : m_imageOn; (m_state == 2 && !m_imageOn2.isNull()) ? m_imageOn2 : m_imageOn;
QRect sourceRect = QRect sourceRect = scene()->views()[0]->matrix().mapRect(rect.toRect());
scene()->views()[0]->matrix().mapRect(QRect(0, 0, 18, 17)); QPixmap redPm = pix.pixmap(sourceRect.size());
QPixmap redPm = pix.pixmap(sourceRect.size()); QRect newRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
QRect newRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
sourceRect.height() * getDevPixRatio()); sourceRect.height() * getDevPixRatio());
painter->drawPixmap(rect, redPm, newRect); painter->drawPixmap(rect, redPm, newRect);
} }

View file

@ -1322,14 +1322,16 @@ StageSchematicNode::StageSchematicNode(StageSchematicScene *scene,
m_splineDock->setPos(x, m_height); m_splineDock->setPos(x, m_height);
m_pathToggle = new SchematicToggle_SplineOptions( m_pathToggle = new SchematicToggle_SplineOptions(
this, QPixmap(":Resources/schematic_spline_aim_rhomb.svg"), this, QIcon(":Resources/schematic_spline_aim_rhomb.svg"),
QPixmap(":Resources/schematic_spline_aim_square.svg"), 0); QIcon(":Resources/schematic_spline_aim_square.svg"), 0);
m_cpToggle = new SchematicToggle_SplineOptions( m_cpToggle = new SchematicToggle_SplineOptions(
this, QPixmap(":Resources/schematic_spline_cp.svg"), 0); this, QIcon(":Resources/schematic_spline_cp.svg"), 0);
m_pathToggle->setSize(7, 7); m_pathToggle->setSize(7, 7);
m_cpToggle->setSize(7, 7); m_cpToggle->setSize(7, 7);
m_cpToggle->setPos(m_splineDock->pos() - QPointF(7, 0)); m_cpToggle->setPos(m_splineDock->pos() - QPointF(7, 0));
m_pathToggle->setPos(m_cpToggle->pos() - QPointF(7, 0)); m_pathToggle->setPos(m_cpToggle->pos() - QPointF(7, 0));
m_pathToggle->setToolTip(tr("Toggle Autorotate Along Motion Path"));
m_cpToggle->setToolTip(tr("Toggle Link Motion Path to Control Points"));
if (m_stageObject->isPathEnabled()) { if (m_stageObject->isPathEnabled()) {
if (m_stageObject->isAimEnabled()) if (m_stageObject->isAimEnabled())