Changeset View
Standalone View
conf/editannottooldialog.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 32 | { | |||
---|---|---|---|---|---|
80 | m_type->addItem( i18n("Pop-up Note"), qVariantFromValue( ToolNoteLinked ) ); | 80 | m_type->addItem( i18n("Pop-up Note"), qVariantFromValue( ToolNoteLinked ) ); | ||
81 | m_type->addItem( i18n("Inline Note"), qVariantFromValue( ToolNoteInline ) ); | 81 | m_type->addItem( i18n("Inline Note"), qVariantFromValue( ToolNoteInline ) ); | ||
82 | m_type->addItem( i18n("Freehand Line"), qVariantFromValue( ToolInk ) ); | 82 | m_type->addItem( i18n("Freehand Line"), qVariantFromValue( ToolInk ) ); | ||
83 | m_type->addItem( i18n("Straight Line"), qVariantFromValue( ToolStraightLine ) ); | 83 | m_type->addItem( i18n("Straight Line"), qVariantFromValue( ToolStraightLine ) ); | ||
84 | m_type->addItem( i18n("Polygon"), qVariantFromValue( ToolPolygon ) ); | 84 | m_type->addItem( i18n("Polygon"), qVariantFromValue( ToolPolygon ) ); | ||
85 | m_type->addItem( i18n("Text markup"), qVariantFromValue( ToolTextMarkup ) ); | 85 | m_type->addItem( i18n("Text markup"), qVariantFromValue( ToolTextMarkup ) ); | ||
86 | m_type->addItem( i18n("Geometrical shape"), qVariantFromValue( ToolGeometricalShape ) ); | 86 | m_type->addItem( i18n("Geometrical shape"), qVariantFromValue( ToolGeometricalShape ) ); | ||
87 | m_type->addItem( i18n("Stamp"), qVariantFromValue( ToolStamp ) ); | 87 | m_type->addItem( i18n("Stamp"), qVariantFromValue( ToolStamp ) ); | ||
88 | m_type->addItem( i18n("Typewriter"), qVariantFromValue( ToolTypewriter ) ); | ||||
88 | 89 | | |||
89 | createStubAnnotation(); | 90 | createStubAnnotation(); | ||
90 | 91 | | |||
91 | if ( initialState.isNull() ) | 92 | if ( initialState.isNull() ) | ||
92 | { | 93 | { | ||
93 | setWindowTitle( i18n("Create annotation tool") ); | 94 | setWindowTitle( i18n("Create annotation tool") ); | ||
94 | } | 95 | } | ||
95 | else | 96 | else | ||
Show All 23 Lines | 117 | { | |||
119 | QDomDocument doc; | 120 | QDomDocument doc; | ||
120 | QDomElement toolElement = doc.createElement( QStringLiteral("tool") ); | 121 | QDomElement toolElement = doc.createElement( QStringLiteral("tool") ); | ||
121 | QDomElement engineElement = doc.createElement( QStringLiteral("engine") ); | 122 | QDomElement engineElement = doc.createElement( QStringLiteral("engine") ); | ||
122 | QDomElement annotationElement = doc.createElement( QStringLiteral("annotation") ); | 123 | QDomElement annotationElement = doc.createElement( QStringLiteral("annotation") ); | ||
123 | doc.appendChild( toolElement ); | 124 | doc.appendChild( toolElement ); | ||
124 | toolElement.appendChild( engineElement ); | 125 | toolElement.appendChild( engineElement ); | ||
125 | engineElement.appendChild( annotationElement ); | 126 | engineElement.appendChild( annotationElement ); | ||
126 | 127 | | |||
127 | const QString color = m_stubann->style().color().name(); | 128 | const QString color = m_stubann->style().color().name(QColor::HexArgb); | ||
tobiasdeiminger: So from now on ALL annotations (even ink, highlight, inline note etc) that are created by a… | |||||
There is no any problem in the newer Okular version as what I have found is that it respects both #RRGGBB and #AARRGGBB formats. I don't know about the older version but it should be both forward and backward compatible. And I agree there should be consistency in the color formats. dileepsankhla: There is no any problem in the newer Okular version as what I have found is that it respects… | |||||
Test for forwards compatibility (def: "allows a system to accept input intended for a later version of itself") is easy.
Because tools.xml was not yet patched to #AARRGGBB for all annotations, just let's simulate this patch:
$ unzip test.okular
$ vi metadata.xml # do :%s/color="#/color="#00/g
$ zip test_aarrggbb.okular content.xml test.txt metadata.xml
$ okular test_aarrggbb.okular
Just tried it, it works. Can you please come up with similar test steps for backwards compatiblity (def: "allows for interoperability with an older legacy system") and perform the test? Reconsidering it, I'm not sure if it's worth the while to open a new Differential patch for the tools.xml alpha channel patch. Probably it's ok to incorporate it in D13203. But let's at least write both the forwards and backwards compatibility test steps down in the Test Plan field of D13203. It's yet empty. May you please do this? tobiasdeiminger: > I don't know about the older version but it should be both forward and backward compatible. | |||||
I'm not sure if I understand this question. Of course not all color entries that appear somewhere in okular source code 😃 We shall just be consistent with const QString color = m_stubann->style().color().name(QColor::HexArgb); So adapt everything to #AARRGGBB that will affect Okular::Annotation::style()->color(). Afaikt this are the color=... attributes of <annotation> elements in tools.xml. But not the color=... attributes of <engine> elements, because they don't affect Okular::Annotation::style()->color(). Are there other places? tobiasdeiminger: > So if we adopt the new color format in the default tools in tools.xml, do we need to alter… | |||||
No, there are not. I'm updating the revision with tools.xml having <annotation> elements color attributes incorporating #AARRGGBB color format. dileepsankhla: > Are there other places?
No, there are not. I'm updating the revision with tools.xml having… | |||||
128 | const QString opacity = QString::number( m_stubann->style().opacity() ); | 129 | const QString opacity = QString::number( m_stubann->style().opacity() ); | ||
129 | const QString width = QString::number( m_stubann->style().width() ); | 130 | const QString width = QString::number( m_stubann->style().width() ); | ||
130 | 131 | | |||
131 | if ( toolType == ToolNoteLinked ) | 132 | if ( toolType == ToolNoteLinked ) | ||
132 | { | 133 | { | ||
133 | Okular::TextAnnotation * ta = static_cast<Okular::TextAnnotation*>( m_stubann ); | 134 | Okular::TextAnnotation * ta = static_cast<Okular::TextAnnotation*>( m_stubann ); | ||
134 | toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("note-linked") ); | 135 | toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("note-linked") ); | ||
135 | engineElement.setAttribute( QStringLiteral("type"), QStringLiteral("PickPoint") ); | 136 | engineElement.setAttribute( QStringLiteral("type"), QStringLiteral("PickPoint") ); | ||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Line(s) | 252 | { | |||
253 | toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("stamp") ); | 254 | toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("stamp") ); | ||
254 | engineElement.setAttribute( QStringLiteral("type"), QStringLiteral("PickPoint") ); | 255 | engineElement.setAttribute( QStringLiteral("type"), QStringLiteral("PickPoint") ); | ||
255 | engineElement.setAttribute( QStringLiteral("hoverIcon"), sa->stampIconName() ); | 256 | engineElement.setAttribute( QStringLiteral("hoverIcon"), sa->stampIconName() ); | ||
256 | engineElement.setAttribute( QStringLiteral("size"), QStringLiteral("64") ); | 257 | engineElement.setAttribute( QStringLiteral("size"), QStringLiteral("64") ); | ||
257 | engineElement.setAttribute( QStringLiteral("block"), QStringLiteral("true") ); | 258 | engineElement.setAttribute( QStringLiteral("block"), QStringLiteral("true") ); | ||
258 | annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("Stamp") ); | 259 | annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("Stamp") ); | ||
259 | annotationElement.setAttribute( QStringLiteral("icon"), sa->stampIconName() ); | 260 | annotationElement.setAttribute( QStringLiteral("icon"), sa->stampIconName() ); | ||
260 | } | 261 | } | ||
262 | else if ( toolType == ToolTypewriter ) | ||||
263 | { | ||||
264 | Okular::TextAnnotation * ta = static_cast<Okular::TextAnnotation*>( m_stubann ); | ||||
265 | toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("typewriter") ); | ||||
266 | engineElement.setAttribute( QStringLiteral("type"), QStringLiteral("PickPoint") ); | ||||
267 | engineElement.setAttribute( QStringLiteral("color"), QStringLiteral("#000000") ); | ||||
268 | engineElement.setAttribute( QStringLiteral("block"), QStringLiteral("true") ); | ||||
269 | annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("Typewriter") ); | ||||
270 | annotationElement.setAttribute( QStringLiteral("color"), color ); | ||||
271 | annotationElement.setAttribute( QStringLiteral("width"), width ); | ||||
272 | if ( ta->textFont() != QApplication::font() ) | ||||
273 | annotationElement.setAttribute( QStringLiteral("font"), ta->textFont().toString() ); | ||||
274 | } | ||||
261 | 275 | | |||
262 | if ( opacity != QStringLiteral("1") ) | 276 | if ( opacity != QStringLiteral("1") ) | ||
263 | annotationElement.setAttribute( QStringLiteral("opacity"), opacity ); | 277 | annotationElement.setAttribute( QStringLiteral("opacity"), opacity ); | ||
264 | 278 | | |||
265 | return doc; | 279 | return doc; | ||
266 | } | 280 | } | ||
267 | 281 | | |||
268 | void EditAnnotToolDialog::createStubAnnotation() | 282 | void EditAnnotToolDialog::createStubAnnotation() | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 338 | { | |||
329 | m_stubann = ga; | 343 | m_stubann = ga; | ||
330 | } | 344 | } | ||
331 | else if ( toolType == ToolStamp ) | 345 | else if ( toolType == ToolStamp ) | ||
332 | { | 346 | { | ||
333 | Okular::StampAnnotation * sa = new Okular::StampAnnotation(); | 347 | Okular::StampAnnotation * sa = new Okular::StampAnnotation(); | ||
334 | sa->setStampIconName( QStringLiteral("okular") ); | 348 | sa->setStampIconName( QStringLiteral("okular") ); | ||
335 | m_stubann = sa; | 349 | m_stubann = sa; | ||
336 | } | 350 | } | ||
351 | else if ( toolType == ToolTypewriter ) | ||||
352 | { | ||||
353 | Okular::TextAnnotation * ta = new Okular::TextAnnotation(); | ||||
354 | ta->setTextType( Okular::TextAnnotation::InPlace ); | ||||
355 | ta->setInplaceIntent( Okular::TextAnnotation::TypeWriter ); | ||||
356 | ta->style().setWidth( 0.0 ); | ||||
357 | ta->style().setColor( QColor(255,255,255,0) ); | ||||
358 | m_stubann = ta; | ||||
359 | } | ||||
337 | } | 360 | } | ||
338 | 361 | | |||
339 | void EditAnnotToolDialog::rebuildAppearanceBox() | 362 | void EditAnnotToolDialog::rebuildAppearanceBox() | ||
340 | { | 363 | { | ||
341 | // Remove previous widget (if any) | 364 | // Remove previous widget (if any) | ||
342 | if ( m_annotationWidget ) | 365 | if ( m_annotationWidget ) | ||
343 | { | 366 | { | ||
344 | delete m_annotationWidget->appearanceWidget(); | 367 | delete m_annotationWidget->appearanceWidget(); | ||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | 479 | { | |||
459 | ha->setHighlightType( Okular::HighlightAnnotation::StrikeOut ); | 482 | ha->setHighlightType( Okular::HighlightAnnotation::StrikeOut ); | ||
460 | } | 483 | } | ||
461 | else if ( annotType == QLatin1String("underline") ) | 484 | else if ( annotType == QLatin1String("underline") ) | ||
462 | { | 485 | { | ||
463 | setToolType( ToolTextMarkup ); | 486 | setToolType( ToolTextMarkup ); | ||
464 | Okular::HighlightAnnotation * ha = static_cast<Okular::HighlightAnnotation*>( m_stubann ); | 487 | Okular::HighlightAnnotation * ha = static_cast<Okular::HighlightAnnotation*>( m_stubann ); | ||
465 | ha->setHighlightType( Okular::HighlightAnnotation::Underline ); | 488 | ha->setHighlightType( Okular::HighlightAnnotation::Underline ); | ||
466 | } | 489 | } | ||
490 | else if ( annotType == QLatin1String("typewriter") ) | ||||
491 | { | ||||
492 | setToolType( ToolTypewriter ); | ||||
493 | Okular::TextAnnotation * ta = static_cast<Okular::TextAnnotation*>( m_stubann ); | ||||
494 | if ( annotationElement.hasAttribute( QStringLiteral("font") ) ) | ||||
495 | { | ||||
496 | QFont f; | ||||
497 | f.fromString( annotationElement.attribute( QStringLiteral("font") ) ); | ||||
498 | ta->setTextFont( f ); | ||||
499 | } | ||||
500 | } | ||||
467 | 501 | | |||
468 | // Common properties | 502 | // Common properties | ||
469 | if ( annotationElement.hasAttribute( QStringLiteral("color") ) ) | 503 | if ( annotationElement.hasAttribute( QStringLiteral("color") ) ) | ||
470 | m_stubann->style().setColor( QColor( annotationElement.attribute( QStringLiteral("color") ) ) ); | 504 | m_stubann->style().setColor( QColor( annotationElement.attribute( QStringLiteral("color") ) ) ); | ||
471 | if ( annotationElement.hasAttribute( QStringLiteral("opacity") ) ) | 505 | if ( annotationElement.hasAttribute( QStringLiteral("opacity") ) ) | ||
472 | m_stubann->style().setOpacity( annotationElement.attribute( QStringLiteral("opacity") ).toDouble() ); | 506 | m_stubann->style().setOpacity( annotationElement.attribute( QStringLiteral("opacity") ).toDouble() ); | ||
473 | if ( annotationElement.hasAttribute( QStringLiteral("width") ) ) | 507 | if ( annotationElement.hasAttribute( QStringLiteral("width") ) ) | ||
474 | m_stubann->style().setWidth( annotationElement.attribute( QStringLiteral("width") ).toDouble() ); | 508 | m_stubann->style().setWidth( annotationElement.attribute( QStringLiteral("width") ).toDouble() ); | ||
Show All 19 Lines |
So from now on ALL annotations (even ink, highlight, inline note etc) that are created by a user-defined tool will store color as #AARRGGBB in *.okular document archive, right? Formerly it was #RRGGBB.
What will happen if user A with new Okular saves an inline note to mydoc.okular and sends mydoc.okular to user B who has an older Okular version. Will the older version be able to deal with #AARRGGBB? How is it vice versa, user B sending something to user A?
If this change is indeed forwards and backwards compatible, I think it's good to go this way. We prepare other annotations types for transparency without destroying something. Then we should however also adapt the color=... attributes of the default tools in tools.xml to the new #AARRGGBB format, for the sake of consistency.