Commit 171bd475 authored by Albert Astals Cid's avatar Albert Astals Cid

qt6: Make inplaceAlign return an enum not an int

parent f9480192
......@@ -1408,12 +1408,12 @@ public:
QString textIcon;
QFont textFont;
QColor textColor;
int inplaceAlign; // 0:left, 1:center, 2:right
TextAnnotation::InplaceAlignPosition inplaceAlign;
QVector<QPointF> inplaceCallout;
TextAnnotation::InplaceIntent inplaceIntent;
};
TextAnnotationPrivate::TextAnnotationPrivate() : AnnotationPrivate(), textType(TextAnnotation::Linked), textIcon(QStringLiteral("Note")), inplaceAlign(0), inplaceIntent(TextAnnotation::Unknown) { }
TextAnnotationPrivate::TextAnnotationPrivate() : AnnotationPrivate(), textType(TextAnnotation::Linked), textIcon(QStringLiteral("Note")), inplaceAlign(TextAnnotation::InplaceAlignLeft), inplaceIntent(TextAnnotation::Unknown) { }
Annotation *TextAnnotationPrivate::makeAlias()
{
......@@ -1590,7 +1590,7 @@ void TextAnnotation::setTextColor(const QColor &color)
d->setDefaultAppearanceToNative();
}
int TextAnnotation::inplaceAlign() const
TextAnnotation::InplaceAlignPosition TextAnnotation::inplaceAlign() const
{
Q_D(const TextAnnotation);
......@@ -1599,13 +1599,33 @@ int TextAnnotation::inplaceAlign() const
if (d->pdfAnnot->getType() == Annot::typeFreeText) {
const AnnotFreeText *ftextann = static_cast<const AnnotFreeText *>(d->pdfAnnot);
return ftextann->getQuadding();
switch (ftextann->getQuadding()) {
case quaddingLeftJustified:
return InplaceAlignLeft;
case quaddingCentered:
return InplaceAlignCenter;
case quaddingRightJustified:
return InplaceAlignRight;
}
}
return 0;
return InplaceAlignLeft;
}
static AnnotFreeText::AnnotFreeTextQuadding alignToQuadding(TextAnnotation::InplaceAlignPosition align)
{
switch (align) {
case TextAnnotation::InplaceAlignLeft:
return AnnotFreeText::quaddingLeftJustified;
case TextAnnotation::InplaceAlignCenter:
return AnnotFreeText::quaddingCentered;
case TextAnnotation::InplaceAlignRight:
return AnnotFreeText::quaddingRightJustified;
}
return AnnotFreeText::quaddingLeftJustified;
}
void TextAnnotation::setInplaceAlign(int align)
void TextAnnotation::setInplaceAlign(InplaceAlignPosition align)
{
Q_D(TextAnnotation);
......@@ -1616,7 +1636,7 @@ void TextAnnotation::setInplaceAlign(int align)
if (d->pdfAnnot->getType() == Annot::typeFreeText) {
AnnotFreeText *ftextann = static_cast<AnnotFreeText *>(d->pdfAnnot);
ftextann->setQuadding((AnnotFreeText::AnnotFreeTextQuadding)align);
ftextann->setQuadding(alignToQuadding(align));
}
}
......
......@@ -436,6 +436,12 @@ public:
Callout,
TypeWriter
};
enum InplaceAlignPosition
{
InplaceAlignLeft,
InplaceAlignCenter,
InplaceAlignRight
};
TextAnnotation(TextType type);
~TextAnnotation() override;
......@@ -472,9 +478,8 @@ public:
QColor textColor() const;
void setTextColor(const QColor &color);
// 0:left, 1:center, 2:right
int inplaceAlign() const;
void setInplaceAlign(int align);
InplaceAlignPosition inplaceAlign() const;
void setInplaceAlign(InplaceAlignPosition align);
QPointF calloutPoint(int id) const;
QVector<QPointF> calloutPoints() const;
......
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