mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-28 20:24:09 +00:00
Use automatic font size picking for new signature annotations
That way the text size changes depending on the available size and isn't hardcoded any more. This allows to make signatures much smaller than before. BUG: 443403
This commit is contained in:
parent
f7a5854912
commit
d30e86ba63
|
@ -2361,6 +2361,8 @@ public:
|
|||
QString m_leftText;
|
||||
QString m_imagePath;
|
||||
QString m_fieldPartialName;
|
||||
double m_fontSize = 10;
|
||||
double m_leftFontSize = 20;
|
||||
int m_page;
|
||||
std::function<SigningResult(const Okular::NewSignatureData &, const QString &)> m_signFunction;
|
||||
};
|
||||
|
@ -2426,6 +2428,30 @@ void SignatureAnnotation::setFieldPartialName(const QString &fieldPartialName)
|
|||
d->m_fieldPartialName = fieldPartialName;
|
||||
}
|
||||
|
||||
double SignatureAnnotation::fontSize() const
|
||||
{
|
||||
Q_D(const SignatureAnnotation);
|
||||
return d->m_fontSize;
|
||||
}
|
||||
|
||||
void SignatureAnnotation::setFontSize(double fontSize)
|
||||
{
|
||||
Q_D(SignatureAnnotation);
|
||||
d->m_fontSize = fontSize;
|
||||
}
|
||||
|
||||
double SignatureAnnotation::leftFontSize() const
|
||||
{
|
||||
Q_D(const SignatureAnnotation);
|
||||
return d->m_leftFontSize;
|
||||
}
|
||||
|
||||
void SignatureAnnotation::setLeftFontSize(double fontSize)
|
||||
{
|
||||
Q_D(SignatureAnnotation);
|
||||
d->m_leftFontSize = fontSize;
|
||||
}
|
||||
|
||||
void SignatureAnnotation::setSignFunction(std::function<SigningResult(const Okular::NewSignatureData &, const QString &)> func)
|
||||
{
|
||||
Q_D(SignatureAnnotation);
|
||||
|
|
|
@ -1353,6 +1353,12 @@ public:
|
|||
QString fieldPartialName() const;
|
||||
void setFieldPartialName(const QString &fieldPartialName);
|
||||
|
||||
double fontSize() const;
|
||||
void setFontSize(double fontSize);
|
||||
|
||||
double leftFontSize() const;
|
||||
void setLeftFontSize(double fontSize);
|
||||
|
||||
int page() const;
|
||||
void setPage(int page);
|
||||
|
||||
|
|
|
@ -6157,6 +6157,8 @@ struct Okular::NewSignatureDataPrivate {
|
|||
QString location;
|
||||
QString reason;
|
||||
QString backgroundImagePath;
|
||||
double fontSize = 10;
|
||||
double leftFontSize = 20;
|
||||
int page = -1;
|
||||
NormalizedRect boundingRectangle;
|
||||
};
|
||||
|
@ -6261,6 +6263,26 @@ void Okular::NewSignatureData::setBackgroundImagePath(const QString &path)
|
|||
d->backgroundImagePath = path;
|
||||
}
|
||||
|
||||
double Okular::NewSignatureData::fontSize() const
|
||||
{
|
||||
return d->fontSize;
|
||||
}
|
||||
|
||||
void Okular::NewSignatureData::setFontSize(double fontSize)
|
||||
{
|
||||
d->fontSize = fontSize;
|
||||
}
|
||||
|
||||
double Okular::NewSignatureData::leftFontSize() const
|
||||
{
|
||||
return d->leftFontSize;
|
||||
}
|
||||
|
||||
void Okular::NewSignatureData::setLeftFontSize(double fontSize)
|
||||
{
|
||||
d->leftFontSize = fontSize;
|
||||
}
|
||||
|
||||
#undef foreachObserver
|
||||
#undef foreachObserverD
|
||||
|
||||
|
|
|
@ -1674,6 +1674,18 @@ public:
|
|||
/// @since 23.08
|
||||
void setBackgroundImagePath(const QString &path);
|
||||
|
||||
/// @since 24.12
|
||||
double fontSize() const;
|
||||
|
||||
/// @since 24.12
|
||||
void setFontSize(double fontSize);
|
||||
|
||||
/// @since 24.12
|
||||
double leftFontSize() const;
|
||||
|
||||
/// @since 24.12
|
||||
void setLeftFontSize(double fontSize);
|
||||
|
||||
private:
|
||||
NewSignatureDataPrivate *const d;
|
||||
};
|
||||
|
|
|
@ -447,6 +447,8 @@ static Poppler::Annotation *createPopplerAnnotationFromOkularAnnotation(Okular::
|
|||
pSignatureAnnotation->setText(oSignatureAnnotation->text());
|
||||
pSignatureAnnotation->setImagePath(oSignatureAnnotation->imagePath());
|
||||
pSignatureAnnotation->setFieldPartialName(oSignatureAnnotation->fieldPartialName());
|
||||
pSignatureAnnotation->setFontSize(oSignatureAnnotation->fontSize());
|
||||
pSignatureAnnotation->setLeftFontSize(oSignatureAnnotation->leftFontSize());
|
||||
|
||||
oSignatureAnnotation->setSignFunction([pSignatureAnnotation](const Okular::NewSignatureData &oData, const QString &fileName) {
|
||||
Poppler::PDFConverter::NewSignatureData pData;
|
||||
|
|
|
@ -1484,6 +1484,8 @@ void PDFGenerator::okularToPoppler(const Okular::NewSignatureData &oData, Popple
|
|||
const QString datetime = QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd hh:mm:ss t"));
|
||||
pData->setSignatureText(i18n("Signed by: %1\n\nDate: %2", oData.certSubjectCommonName(), datetime));
|
||||
pData->setSignatureLeftText(oData.certSubjectCommonName());
|
||||
pData->setFontSize(oData.fontSize());
|
||||
pData->setLeftFontSize(oData.leftFontSize());
|
||||
const Okular::NormalizedRect bRect = oData.boundingRectangle();
|
||||
pData->setBoundingRectangle({bRect.left, bRect.top, bRect.width(), bRect.height()});
|
||||
pData->setFontColor(Qt::black);
|
||||
|
|
|
@ -5489,6 +5489,8 @@ void PageView::finishSigning()
|
|||
data.setDocumentPassword(d->signingInfo.documentPassword);
|
||||
data.setReason(d->signingInfo.reason);
|
||||
data.setLocation(d->signingInfo.location);
|
||||
data.setLeftFontSize(d->signatureAnnotation->leftFontSize());
|
||||
data.setFontSize(d->signatureAnnotation->fontSize());
|
||||
|
||||
Okular::SigningResult result = d->signatureAnnotation->sign(data, newFilePath);
|
||||
if (result == Okular::SigningSuccess) {
|
||||
|
|
|
@ -366,6 +366,9 @@ public:
|
|||
ann->setText(signatureText);
|
||||
ann->setImagePath(m_signingInformation->backgroundImagePath);
|
||||
|
||||
ann->setLeftFontSize(0);
|
||||
ann->setFontSize(0);
|
||||
|
||||
m_creationCompleted = false;
|
||||
clicked = false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue