Changeset View
Changeset View
Standalone View
Standalone View
ui/pageviewannotator.cpp
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Line(s) | 153 | if ( m_annotElement.hasAttribute( QStringLiteral("align") ) ) | |||
---|---|---|---|---|---|
154 | ta->setInplaceAlignment( m_annotElement.attribute( QStringLiteral("align") ).toInt() ); | 154 | ta->setInplaceAlignment( m_annotElement.attribute( QStringLiteral("align") ).toInt() ); | ||
155 | //set font | 155 | //set font | ||
156 | if ( m_annotElement.hasAttribute( QStringLiteral("font") ) ) | 156 | if ( m_annotElement.hasAttribute( QStringLiteral("font") ) ) | ||
157 | { | 157 | { | ||
158 | QFont f; | 158 | QFont f; | ||
159 | f.fromString( m_annotElement.attribute( QStringLiteral("font") ) ); | 159 | f.fromString( m_annotElement.attribute( QStringLiteral("font") ) ); | ||
160 | ta->setTextFont( f ); | 160 | ta->setTextFont( f ); | ||
161 | } | 161 | } | ||
162 | // set font color | ||||
163 | if ( m_annotElement.hasAttribute( QStringLiteral("textColor") ) ) | ||||
164 | { | ||||
165 | if ( inplaceIntent == Okular::TextAnnotation::TypeWriter ) | ||||
166 | ta->setTextColor( m_annotElement.attribute( QStringLiteral("textColor") ) ); | ||||
167 | else | ||||
168 | ta->setTextColor( Qt::black ); | ||||
169 | } | ||||
162 | //set width | 170 | //set width | ||
163 | if ( m_annotElement.hasAttribute( QStringLiteral ( "width" ) ) ) | 171 | if ( m_annotElement.hasAttribute( QStringLiteral ( "width" ) ) ) | ||
164 | { | 172 | { | ||
165 | ta->style().setWidth( m_annotElement.attribute( QStringLiteral ( "width" ) ).toDouble() ); | 173 | ta->style().setWidth( m_annotElement.attribute( QStringLiteral ( "width" ) ).toDouble() ); | ||
166 | } | 174 | } | ||
167 | //set boundary | 175 | //set boundary | ||
168 | rect.left = qMin(startpoint.x,point.x); | 176 | rect.left = qMin(startpoint.x,point.x); | ||
169 | rect.top = qMin(startpoint.y,point.y); | 177 | rect.top = qMin(startpoint.y,point.y); | ||
▲ Show 20 Lines • Show All 946 Lines • ▼ Show 20 Line(s) | 1117 | { | |||
1116 | if ( qApp->devicePixelRatio() > 1.05 ) { | 1124 | if ( qApp->devicePixelRatio() > 1.05 ) { | ||
1117 | imageVariant = "@2x"; | 1125 | imageVariant = "@2x"; | ||
1118 | } | 1126 | } | ||
1119 | 1127 | | |||
1120 | // Load base pixmap. We'll draw on top of it | 1128 | // Load base pixmap. We'll draw on top of it | ||
1121 | pixmap.load( QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString("okular/pics/tool-base-okular" + imageVariant + ".png") ) ); | 1129 | pixmap.load( QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString("okular/pics/tool-base-okular" + imageVariant + ".png") ) ); | ||
1122 | 1130 | | |||
1123 | /* Parse color, innerColor and icon (if present) */ | 1131 | /* Parse color, innerColor and icon (if present) */ | ||
1124 | QColor engineColor, innerColor, annotColor; | 1132 | QColor engineColor, innerColor, textColor, annotColor; | ||
1125 | QString icon; | 1133 | QString icon; | ||
1126 | QDomNodeList engineNodeList = toolElement.elementsByTagName( QStringLiteral("engine") ); | 1134 | QDomNodeList engineNodeList = toolElement.elementsByTagName( QStringLiteral("engine") ); | ||
1127 | if ( engineNodeList.size() > 0 ) | 1135 | if ( engineNodeList.size() > 0 ) | ||
1128 | { | 1136 | { | ||
1129 | QDomElement engineEl = engineNodeList.item( 0 ).toElement(); | 1137 | QDomElement engineEl = engineNodeList.item( 0 ).toElement(); | ||
1130 | if ( !engineEl.isNull() && engineEl.hasAttribute( QStringLiteral("color") ) ) | 1138 | if ( !engineEl.isNull() && engineEl.hasAttribute( QStringLiteral("color") ) ) | ||
1131 | engineColor = QColor( engineEl.attribute( QStringLiteral("color") ) ); | 1139 | engineColor = QColor( engineEl.attribute( QStringLiteral("color") ) ); | ||
1132 | } | 1140 | } | ||
1133 | QDomNodeList annotationNodeList = toolElement.elementsByTagName( QStringLiteral("annotation") ); | 1141 | QDomNodeList annotationNodeList = toolElement.elementsByTagName( QStringLiteral("annotation") ); | ||
1134 | if ( annotationNodeList.size() > 0 ) | 1142 | if ( annotationNodeList.size() > 0 ) | ||
1135 | { | 1143 | { | ||
1136 | QDomElement annotationEl = annotationNodeList.item( 0 ).toElement(); | 1144 | QDomElement annotationEl = annotationNodeList.item( 0 ).toElement(); | ||
1137 | if ( !annotationEl.isNull() && annotationEl.hasAttribute( QStringLiteral("color") ) ) | 1145 | if ( !annotationEl.isNull() ) | ||
1146 | { | ||||
1147 | if ( annotationEl.hasAttribute( QStringLiteral("color") ) ) | ||||
1138 | annotColor = annotationEl.attribute( QStringLiteral("color") ); | 1148 | annotColor = annotationEl.attribute( QStringLiteral("color") ); | ||
1139 | if ( !annotationEl.isNull() && annotationEl.hasAttribute( QStringLiteral("innerColor") ) ) | 1149 | if ( annotationEl.hasAttribute( QStringLiteral("innerColor") ) ) | ||
1140 | innerColor = QColor( annotationEl.attribute( QStringLiteral("innerColor") ) ); | 1150 | innerColor = QColor( annotationEl.attribute( QStringLiteral("innerColor") ) ); | ||
1141 | if ( !annotationEl.isNull() && annotationEl.hasAttribute( QStringLiteral("icon") ) ) | 1151 | if ( annotationEl.hasAttribute( QStringLiteral("textColor") ) ) | ||
1152 | textColor = QColor( annotationEl.attribute( QStringLiteral("textColor") ) ); | ||||
1153 | if ( annotationEl.hasAttribute( QStringLiteral("icon") ) ) | ||||
1142 | icon = annotationEl.attribute( QStringLiteral("icon") ); | 1154 | icon = annotationEl.attribute( QStringLiteral("icon") ); | ||
1143 | } | 1155 | } | ||
1156 | } | ||||
1144 | 1157 | | |||
1145 | QPainter p( &pixmap ); | 1158 | QPainter p( &pixmap ); | ||
1146 | 1159 | | |||
1147 | if ( annotType == QLatin1String("ellipse") ) | 1160 | if ( annotType == QLatin1String("ellipse") ) | ||
1148 | { | 1161 | { | ||
1149 | p.setRenderHint( QPainter::Antialiasing ); | 1162 | p.setRenderHint( QPainter::Antialiasing ); | ||
1150 | if ( innerColor.isValid() ) | 1163 | if ( innerColor.isValid() ) | ||
1151 | p.setBrush( innerColor ); | 1164 | p.setBrush( innerColor ); | ||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | |||||
1243 | { | 1256 | { | ||
1244 | p.setPen( QPen( engineColor, 1 ) ); | 1257 | p.setPen( QPen( engineColor, 1 ) ); | ||
1245 | p.drawLine( 1, 13, 16, 13 ); | 1258 | p.drawLine( 1, 13, 16, 13 ); | ||
1246 | p.drawLine( 0, 20, 19, 20 ); | 1259 | p.drawLine( 0, 20, 19, 20 ); | ||
1247 | } | 1260 | } | ||
1248 | else if ( annotType == QLatin1String("typewriter") ) | 1261 | else if ( annotType == QLatin1String("typewriter") ) | ||
1249 | { | 1262 | { | ||
1250 | QImage overlay( QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString("okular/pics/tool-typewriter-okular-colorizable" + imageVariant + ".png") ) ); | 1263 | QImage overlay( QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString("okular/pics/tool-typewriter-okular-colorizable" + imageVariant + ".png") ) ); | ||
1251 | /* Here we want to colorize the icon with font color instead of background color. Font color is black a.t.m. */ | 1264 | GuiUtils::colorizeImage( overlay, textColor ); | ||
1252 | GuiUtils::colorizeImage( overlay, Qt::black ); | | |||
1253 | p.drawImage( QPoint(-2,2), overlay ); | 1265 | p.drawImage( QPoint(-2,2), overlay ); | ||
1254 | } | 1266 | } | ||
1255 | else | 1267 | else | ||
1256 | { | 1268 | { | ||
1257 | /* Unrecognized annotation type -- It shouldn't happen */ | 1269 | /* Unrecognized annotation type -- It shouldn't happen */ | ||
1258 | p.setPen( QPen( engineColor ) ); | 1270 | p.setPen( QPen( engineColor ) ); | ||
1259 | p.drawText( QPoint(20, 31), QStringLiteral("?") ); | 1271 | p.drawText( QPoint(20, 31), QStringLiteral("?") ); | ||
1260 | } | 1272 | } | ||
1261 | 1273 | | |||
1262 | return pixmap; | 1274 | return pixmap; | ||
1263 | } | 1275 | } | ||
1264 | 1276 | | |||
1265 | #include "moc_pageviewannotator.cpp" | 1277 | #include "moc_pageviewannotator.cpp" | ||
1266 | 1278 | | |||
1267 | /* kate: replace-tabs on; indent-width 4; */ | 1279 | /* kate: replace-tabs on; indent-width 4; */ |