Changeset View
Changeset View
Standalone View
Standalone View
ui/annotationwidgets.cpp
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Line(s) | 123 | { | |||
---|---|---|---|---|---|
154 | // cases not covered yet: return a generic widget | 154 | // cases not covered yet: return a generic widget | ||
155 | return new AnnotationWidget( ann ); | 155 | return new AnnotationWidget( ann ); | ||
156 | } | 156 | } | ||
157 | 157 | | |||
158 | 158 | | |||
159 | AnnotationWidget::AnnotationWidget( Okular::Annotation * ann ) | 159 | AnnotationWidget::AnnotationWidget( Okular::Annotation * ann ) | ||
160 | : QObject(), m_ann( ann ), m_appearanceWidget( nullptr ), m_extraWidget( nullptr ) | 160 | : QObject(), m_ann( ann ), m_appearanceWidget( nullptr ), m_extraWidget( nullptr ) | ||
161 | { | 161 | { | ||
162 | m_textAnn = static_cast< Okular::TextAnnotation * >( ann ); | ||||
162 | } | 163 | } | ||
163 | 164 | | |||
164 | AnnotationWidget::~AnnotationWidget() | 165 | AnnotationWidget::~AnnotationWidget() | ||
165 | { | 166 | { | ||
166 | } | 167 | } | ||
167 | 168 | | |||
168 | Okular::Annotation::SubType AnnotationWidget::annotationType() const | 169 | Okular::Annotation::SubType AnnotationWidget::annotationType() const | ||
169 | { | 170 | { | ||
Show All 15 Lines | 185 | if ( m_extraWidget ) | |||
185 | return m_extraWidget; | 186 | return m_extraWidget; | ||
186 | 187 | | |||
187 | m_extraWidget = createExtraWidget(); | 188 | m_extraWidget = createExtraWidget(); | ||
188 | return m_extraWidget; | 189 | return m_extraWidget; | ||
189 | } | 190 | } | ||
190 | 191 | | |||
191 | void AnnotationWidget::applyChanges() | 192 | void AnnotationWidget::applyChanges() | ||
192 | { | 193 | { | ||
194 | if ( m_textAnn->inplaceIntent() == Okular::TextAnnotation::TypeWriter ) | ||||
195 | return; | ||||
193 | m_ann->style().setColor( m_colorBn->color() ); | 196 | m_ann->style().setColor( m_colorBn->color() ); | ||
194 | m_ann->style().setOpacity( (double)m_opacity->value() / 100.0 ); | 197 | m_ann->style().setOpacity( (double)m_opacity->value() / 100.0 ); | ||
195 | } | 198 | } | ||
196 | 199 | | |||
197 | QWidget * AnnotationWidget::createAppearanceWidget() | 200 | QWidget * AnnotationWidget::createAppearanceWidget() | ||
198 | { | 201 | { | ||
199 | QWidget * widget = new QWidget(); | 202 | QWidget * widget = new QWidget(); | ||
200 | QGridLayout * gridlayout = new QGridLayout( widget ); | 203 | QGridLayout * gridlayout = new QGridLayout( widget ); | ||
201 | 204 | if ( m_textAnn->inplaceIntent() == Okular::TextAnnotation::Unknown ) | |||
205 | { | ||||
202 | QLabel * tmplabel = new QLabel( i18n( "&Color:" ), widget ); | 206 | QLabel * tmplabel = new QLabel( i18n( "&Color:" ), widget ); | ||
203 | gridlayout->addWidget( tmplabel, 0, 0, Qt::AlignRight ); | 207 | gridlayout->addWidget( tmplabel, 0, 0, Qt::AlignRight ); | ||
204 | m_colorBn = new KColorButton( widget ); | 208 | m_colorBn = new KColorButton( widget ); | ||
205 | m_colorBn->setColor( m_ann->style().color() ); | 209 | m_colorBn->setColor( m_ann->style().color() ); | ||
206 | tmplabel->setBuddy( m_colorBn ); | 210 | tmplabel->setBuddy( m_colorBn ); | ||
207 | gridlayout->addWidget( m_colorBn, 0, 1 ); | 211 | gridlayout->addWidget( m_colorBn, 0, 1 ); | ||
208 | 212 | | |||
209 | tmplabel = new QLabel( i18n( "&Opacity:" ), widget ); | 213 | tmplabel = new QLabel( i18n( "&Opacity:" ), widget ); | ||
210 | gridlayout->addWidget( tmplabel, 1, 0, Qt::AlignRight ); | 214 | gridlayout->addWidget( tmplabel, 1, 0, Qt::AlignRight ); | ||
211 | m_opacity = new QSpinBox( widget ); | 215 | m_opacity = new QSpinBox( widget ); | ||
212 | m_opacity->setRange( 0, 100 ); | 216 | m_opacity->setRange( 0, 100 ); | ||
213 | m_opacity->setValue( (int)( m_ann->style().opacity() * 100 ) ); | 217 | m_opacity->setValue( (int)( m_ann->style().opacity() * 100 ) ); | ||
214 | m_opacity->setSuffix( i18nc( "Suffix for the opacity level, eg '80 %'", " %" ) ); | 218 | m_opacity->setSuffix( i18nc( "Suffix for the opacity level, eg '80 %'", " %" ) ); | ||
215 | tmplabel->setBuddy( m_opacity ); | 219 | tmplabel->setBuddy( m_opacity ); | ||
216 | gridlayout->addWidget( m_opacity, 1, 1 ); | 220 | gridlayout->addWidget( m_opacity, 1, 1 ); | ||
217 | 221 | | |||
222 | connect( m_colorBn, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | ||||
223 | connect( m_opacity, SIGNAL(valueChanged(int)), this, SIGNAL(dataChanged()) ); | ||||
224 | } | ||||
225 | | ||||
218 | QWidget * styleWidget = createStyleWidget(); | 226 | QWidget * styleWidget = createStyleWidget(); | ||
219 | if ( styleWidget ) | 227 | if ( styleWidget ) | ||
220 | gridlayout->addWidget( styleWidget, 2, 0, 1, 2 ); | 228 | gridlayout->addWidget( styleWidget, 2, 0, 1, 2 ); | ||
221 | 229 | | |||
222 | gridlayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ), 3, 0 ); | 230 | gridlayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ), 3, 0 ); | ||
223 | 231 | | |||
224 | connect( m_colorBn, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | | |||
225 | connect( m_opacity, SIGNAL(valueChanged(int)), this, SIGNAL(dataChanged()) ); | | |||
226 | | ||||
227 | return widget; | 232 | return widget; | ||
228 | } | 233 | } | ||
229 | 234 | | |||
230 | QWidget * AnnotationWidget::createStyleWidget() | 235 | QWidget * AnnotationWidget::createStyleWidget() | ||
231 | { | 236 | { | ||
232 | return nullptr; | 237 | return nullptr; | ||
233 | } | 238 | } | ||
234 | 239 | | |||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 279 | { | |||
276 | lay->addLayout( innerlay ); | 281 | lay->addLayout( innerlay ); | ||
277 | 282 | | |||
278 | QLabel * tmplabel = new QLabel( i18n( "Font:" ), widget ); | 283 | QLabel * tmplabel = new QLabel( i18n( "Font:" ), widget ); | ||
279 | innerlay->addWidget( tmplabel, 0, 0 ); | 284 | innerlay->addWidget( tmplabel, 0, 0 ); | ||
280 | m_fontReq = new KFontRequester( widget ); | 285 | m_fontReq = new KFontRequester( widget ); | ||
281 | innerlay->addWidget( m_fontReq, 0, 1 ); | 286 | innerlay->addWidget( m_fontReq, 0, 1 ); | ||
282 | m_fontReq->setFont( m_textAnn->textFont() ); | 287 | m_fontReq->setFont( m_textAnn->textFont() ); | ||
283 | 288 | | |||
289 | connect( m_fontReq, &KFontRequester::fontSelected, this, &AnnotationWidget::dataChanged ); | ||||
290 | | ||||
291 | if ( m_textAnn->inplaceIntent() == Okular::TextAnnotation::TypeWriter ) | ||||
292 | return widget; | ||||
284 | tmplabel = new QLabel( i18n( "Align:" ), widget ); | 293 | tmplabel = new QLabel( i18n( "Align:" ), widget ); | ||
285 | innerlay->addWidget( tmplabel, 1, 0 ); | 294 | innerlay->addWidget( tmplabel, 1, 0 ); | ||
286 | m_textAlign = new KComboBox( widget ); | 295 | m_textAlign = new KComboBox( widget ); | ||
287 | innerlay->addWidget( m_textAlign, 1, 1 ); | 296 | innerlay->addWidget( m_textAlign, 1, 1 ); | ||
288 | m_textAlign->addItem( i18n("Left") ); | 297 | m_textAlign->addItem( i18n("Left") ); | ||
289 | m_textAlign->addItem( i18n("Center") ); | 298 | m_textAlign->addItem( i18n("Center") ); | ||
290 | m_textAlign->addItem( i18n("Right") ); | 299 | m_textAlign->addItem( i18n("Right") ); | ||
291 | m_textAlign->setCurrentIndex( m_textAnn->inplaceAlignment() ); | 300 | m_textAlign->setCurrentIndex( m_textAnn->inplaceAlignment() ); | ||
292 | 301 | | |||
293 | tmplabel = new QLabel( i18n( "Border Width:" ), widget ); | 302 | tmplabel = new QLabel( i18n( "Border Width:" ), widget ); | ||
294 | innerlay->addWidget( tmplabel, 2, 0, Qt::AlignRight ); | 303 | innerlay->addWidget( tmplabel, 2, 0, Qt::AlignRight ); | ||
295 | m_spinWidth = new QDoubleSpinBox( widget ); | 304 | m_spinWidth = new QDoubleSpinBox( widget ); | ||
296 | innerlay->addWidget( m_spinWidth, 2, 1 ); | 305 | innerlay->addWidget( m_spinWidth, 2, 1 ); | ||
297 | tmplabel->setBuddy( m_spinWidth ); | 306 | tmplabel->setBuddy( m_spinWidth ); | ||
298 | m_spinWidth->setRange( 0, 100 ); | 307 | m_spinWidth->setRange( 0, 100 ); | ||
299 | m_spinWidth->setValue( m_textAnn->style().width() ); | 308 | m_spinWidth->setValue( m_textAnn->style().width() ); | ||
300 | m_spinWidth->setSingleStep( 0.1 ); | 309 | m_spinWidth->setSingleStep( 0.1 ); | ||
301 | 310 | | |||
302 | connect( m_fontReq, &KFontRequester::fontSelected, this, &AnnotationWidget::dataChanged ); | | |||
303 | | ||||
304 | connect( m_textAlign, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dataChanged()) ); | 311 | connect( m_textAlign, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dataChanged()) ); | ||
305 | connect( m_spinWidth, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | 312 | connect( m_spinWidth, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | ||
306 | } | 313 | } | ||
307 | 314 | | |||
308 | return widget; | 315 | return widget; | ||
309 | } | 316 | } | ||
310 | 317 | | |||
311 | void TextAnnotationWidget::applyChanges() | 318 | void TextAnnotationWidget::applyChanges() | ||
312 | { | 319 | { | ||
313 | AnnotationWidget::applyChanges(); | 320 | AnnotationWidget::applyChanges(); | ||
314 | if ( m_textAnn->textType() == Okular::TextAnnotation::Linked ) | 321 | if ( m_textAnn->textType() == Okular::TextAnnotation::Linked ) | ||
315 | { | 322 | { | ||
316 | m_textAnn->setTextIcon( m_pixmapSelector->icon() ); | 323 | m_textAnn->setTextIcon( m_pixmapSelector->icon() ); | ||
317 | } | 324 | } | ||
318 | else if ( m_textAnn->textType() == Okular::TextAnnotation::InPlace ) | 325 | else if ( m_textAnn->textType() == Okular::TextAnnotation::InPlace ) | ||
319 | { | 326 | { | ||
320 | m_textAnn->setTextFont( m_fontReq->font() ); | 327 | m_textAnn->setTextFont( m_fontReq->font() ); | ||
328 | if ( m_textAnn->inplaceIntent() == Okular::TextAnnotation::TypeWriter ) | ||||
329 | return; | ||||
321 | m_textAnn->setInplaceAlignment( m_textAlign->currentIndex() ); | 330 | m_textAnn->setInplaceAlignment( m_textAlign->currentIndex() ); | ||
322 | m_textAnn->style().setWidth( m_spinWidth->value() ); | 331 | m_textAnn->style().setWidth( m_spinWidth->value() ); | ||
323 | } | 332 | } | ||
324 | } | 333 | } | ||
325 | 334 | | |||
326 | 335 | | |||
327 | StampAnnotationWidget::StampAnnotationWidget( Okular::Annotation * ann ) | 336 | StampAnnotationWidget::StampAnnotationWidget( Okular::Annotation * ann ) | ||
328 | : AnnotationWidget( ann ), m_pixmapSelector( nullptr ) | 337 | : AnnotationWidget( ann ), m_pixmapSelector( nullptr ) | ||
▲ Show 20 Lines • Show All 448 Lines • Show Last 20 Lines |