mirror of https://github.com/JakubMelka/PDF4QT.git
Finishing of dimension plugin
This commit is contained in:
parent
31b4dac927
commit
7b95507cac
|
@ -375,7 +375,31 @@ void PDFViewerMainWindow::loadPlugins()
|
||||||
|
|
||||||
menu->addAction(action);
|
menu->addAction(action);
|
||||||
toolbarButton->menu()->addAction(action);
|
toolbarButton->menu()->addAction(action);
|
||||||
connect(action, &QAction::triggered, toolbarButton, [action, toolbarButton](){ toolbarButton->setDefaultAction(action); });
|
|
||||||
|
auto onPluginActionTriggered = [toolbarButton, action]()
|
||||||
|
{
|
||||||
|
if (action->isEnabled())
|
||||||
|
{
|
||||||
|
toolbarButton->setDefaultAction(action);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
auto onPluginActionStateChanged = [toolbarButton, action]()
|
||||||
|
{
|
||||||
|
if (!action->isEnabled() && toolbarButton->defaultAction() == action)
|
||||||
|
{
|
||||||
|
for (QAction* action : toolbarButton->menu()->actions())
|
||||||
|
{
|
||||||
|
if (action->isEnabled())
|
||||||
|
{
|
||||||
|
toolbarButton->setDefaultAction(action);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
connect(action, &QAction::triggered, toolbarButton, onPluginActionTriggered);
|
||||||
|
connect(action, &QAction::changed, toolbarButton, onPluginActionStateChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,6 +290,13 @@ void DimensionsPlugin::drawPage(QPainter* painter,
|
||||||
painter->drawLine(line1);
|
painter->drawLine(line1);
|
||||||
painter->drawLine(line2);
|
painter->drawLine(line2);
|
||||||
|
|
||||||
|
qreal startAngle = line1.angle() * 16;
|
||||||
|
qreal angleLength = dimension.getMeasuredValue() * 16;
|
||||||
|
|
||||||
|
QRectF rect(-maxLength * 0.5, -maxLength * 0.5, maxLength, maxLength);
|
||||||
|
rect.translate(line1.p1());
|
||||||
|
painter->drawArc(rect, startAngle - angleLength, angleLength);
|
||||||
|
|
||||||
QPen penPoint(Qt::black);
|
QPen penPoint(Qt::black);
|
||||||
penPoint.setCapStyle(Qt::RoundCap);
|
penPoint.setCapStyle(Qt::RoundCap);
|
||||||
penPoint.setWidthF(pointSize);
|
penPoint.setWidthF(pointSize);
|
||||||
|
@ -299,6 +306,14 @@ void DimensionsPlugin::drawPage(QPainter* painter,
|
||||||
painter->drawPoint(line1.p2());
|
painter->drawPoint(line1.p2());
|
||||||
painter->drawPoint(line2.p2());
|
painter->drawPoint(line2.p2());
|
||||||
|
|
||||||
|
QMatrix textMatrix;
|
||||||
|
textMatrix.translate(line1.x1(), line1.y1());
|
||||||
|
textMatrix.rotate(-line1.angle() + dimension.getMeasuredValue() * 0.5);
|
||||||
|
|
||||||
|
QPointF textPoint = textMatrix.map(QPointF(maxLength * 0.25, 0.0));
|
||||||
|
QString text = QString("%1 %2").arg(locale.toString(dimension.getMeasuredValue() * m_angleUnit.scale, 'f', 2), m_angleUnit.symbol);
|
||||||
|
painter->drawText(textPoint, text);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue