Changeset View
Changeset View
Standalone View
Standalone View
ui/annotationwidgets.cpp
Show First 20 Lines • Show All 206 Lines • ▼ Show 20 Line(s) | 206 | default: | |||
---|---|---|---|---|---|
207 | ; | 207 | ; | ||
208 | } | 208 | } | ||
209 | // cases not covered yet: return a generic widget | 209 | // cases not covered yet: return a generic widget | ||
210 | return new AnnotationWidget( ann ); | 210 | return new AnnotationWidget( ann ); | ||
211 | } | 211 | } | ||
212 | 212 | | |||
213 | 213 | | |||
214 | AnnotationWidget::AnnotationWidget( Okular::Annotation * ann ) | 214 | AnnotationWidget::AnnotationWidget( Okular::Annotation * ann ) | ||
215 | : m_ann( ann ) | 215 | : m_typeEditable( true ), m_ann( ann ) | ||
216 | { | 216 | { | ||
217 | } | 217 | } | ||
218 | 218 | | |||
219 | AnnotationWidget::~AnnotationWidget() | 219 | AnnotationWidget::~AnnotationWidget() | ||
220 | { | 220 | { | ||
221 | } | 221 | } | ||
222 | 222 | | |||
223 | Okular::Annotation::SubType AnnotationWidget::annotationType() const | 223 | Okular::Annotation::SubType AnnotationWidget::annotationType() const | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 272 | { | |||
276 | connect( m_colorBn, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | 276 | connect( m_colorBn, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | ||
277 | } | 277 | } | ||
278 | 278 | | |||
279 | void AnnotationWidget::addOpacitySpinBox( QWidget * widget, QFormLayout * formlayout ) | 279 | void AnnotationWidget::addOpacitySpinBox( QWidget * widget, QFormLayout * formlayout ) | ||
280 | { | 280 | { | ||
281 | m_opacity = new QSpinBox( widget ); | 281 | m_opacity = new QSpinBox( widget ); | ||
282 | m_opacity->setRange( 0, 100 ); | 282 | m_opacity->setRange( 0, 100 ); | ||
283 | m_opacity->setValue( (int)( m_ann->style().opacity() * 100 ) ); | 283 | m_opacity->setValue( (int)( m_ann->style().opacity() * 100 ) ); | ||
284 | m_opacity->setSuffix( i18nc( "Suffix for the opacity level, eg '80 %'", " %" ) ); | 284 | m_opacity->setSuffix( i18nc( "Suffix for the opacity level, eg '80%'", "%" ) ); | ||
285 | formlayout->addRow( i18n( "&Opacity:" ), m_opacity); | 285 | formlayout->addRow( i18n( "&Opacity:" ), m_opacity); | ||
286 | connect( m_opacity, SIGNAL(valueChanged(int)), this, SIGNAL(dataChanged()) ); | 286 | connect( m_opacity, SIGNAL(valueChanged(int)), this, SIGNAL(dataChanged()) ); | ||
287 | } | 287 | } | ||
288 | 288 | | |||
289 | void AnnotationWidget::addVerticalSpacer( QFormLayout * formlayout ) | 289 | void AnnotationWidget::addVerticalSpacer( QFormLayout * formlayout ) | ||
290 | { | 290 | { | ||
291 | formlayout->addItem( new QSpacerItem( 0, 5, QSizePolicy::Fixed, QSizePolicy::Fixed ) ); | 291 | formlayout->addItem( new QSpacerItem( 0, 5, QSizePolicy::Fixed, QSizePolicy::Fixed ) ); | ||
292 | } | 292 | } | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 332 | { | |||
341 | else | 341 | else | ||
342 | { | 342 | { | ||
343 | Q_ASSERT( m_textColorBn ); | 343 | Q_ASSERT( m_textColorBn ); | ||
344 | m_textAnn->setTextColor( m_textColorBn->color() ); | 344 | m_textAnn->setTextColor( m_textColorBn->color() ); | ||
345 | } | 345 | } | ||
346 | } | 346 | } | ||
347 | } | 347 | } | ||
348 | 348 | | |||
349 | | ||||
350 | void AnnotationWidget::setAnnotTypeEditable( bool editable ) | ||||
351 | { | ||||
352 | m_typeEditable = editable; | ||||
353 | } | ||||
354 | | ||||
349 | void TextAnnotationWidget::createPopupNoteStyleUi( QWidget * widget, QFormLayout * formlayout ) { | 355 | void TextAnnotationWidget::createPopupNoteStyleUi( QWidget * widget, QFormLayout * formlayout ) { | ||
350 | addColorButton( widget, formlayout ); | 356 | addColorButton( widget, formlayout ); | ||
351 | addOpacitySpinBox( widget, formlayout ); | 357 | addOpacitySpinBox( widget, formlayout ); | ||
352 | addVerticalSpacer( formlayout ); | 358 | addVerticalSpacer( formlayout ); | ||
353 | addPixmapSelector( widget, formlayout ); | 359 | addPixmapSelector( widget, formlayout ); | ||
354 | } | 360 | } | ||
355 | 361 | | |||
356 | void TextAnnotationWidget::createInlineNoteStyleUi( QWidget * widget, QFormLayout * formlayout ) { | 362 | void TextAnnotationWidget::createInlineNoteStyleUi( QWidget * widget, QFormLayout * formlayout ) { | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 421 | { | |||
416 | m_spinWidth = new QDoubleSpinBox( widget ); | 422 | m_spinWidth = new QDoubleSpinBox( widget ); | ||
417 | formlayout->addRow( i18n( "Border &width:" ), m_spinWidth ); | 423 | formlayout->addRow( i18n( "Border &width:" ), m_spinWidth ); | ||
418 | m_spinWidth->setRange( 0, 100 ); | 424 | m_spinWidth->setRange( 0, 100 ); | ||
419 | m_spinWidth->setValue( m_textAnn->style().width() ); | 425 | m_spinWidth->setValue( m_textAnn->style().width() ); | ||
420 | m_spinWidth->setSingleStep( 0.1 ); | 426 | m_spinWidth->setSingleStep( 0.1 ); | ||
421 | connect( m_spinWidth, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | 427 | connect( m_spinWidth, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | ||
422 | } | 428 | } | ||
423 | 429 | | |||
430 | const QList<QPair<QString, QString>> StampAnnotationWidget::defaultStamps = { | ||||
431 | { i18n( "Approved" ), QStringLiteral("Approved") }, | ||||
432 | { i18n( "As Is" ), QStringLiteral("AsIs") }, | ||||
433 | { i18n( "Confidential" ), QStringLiteral("Confidential") }, | ||||
434 | { i18n( "Departmental" ), QStringLiteral("Departmental") }, | ||||
435 | { i18n( "Draft" ), QStringLiteral("Draft") }, | ||||
436 | { i18n( "Experimental" ), QStringLiteral("Experimental") }, | ||||
437 | { i18n( "Final" ), QStringLiteral("Expired") }, | ||||
438 | { i18n( "For Comment" ), QStringLiteral("ForComment") }, | ||||
439 | { i18n( "For Public Release" ), QStringLiteral("ForPublicRelease") }, | ||||
440 | { i18n( "Not Approved" ), QStringLiteral("NotApproved") }, | ||||
441 | { i18n( "Not For Public Release" ), QStringLiteral("NotForPublicRelease") }, | ||||
442 | { i18n( "Sold" ), QStringLiteral("Sold") }, | ||||
443 | { i18n( "Top Secret" ), QStringLiteral("TopSecret") }, | ||||
444 | { i18n( "Bookmark" ), QStringLiteral("bookmark-new") }, | ||||
445 | { i18n( "Information" ), QStringLiteral("help-about") }, | ||||
446 | { i18n( "KDE" ), QStringLiteral("kde") }, | ||||
447 | { i18n( "Okular" ), QStringLiteral("okular") } | ||||
448 | }; | ||||
449 | | ||||
424 | StampAnnotationWidget::StampAnnotationWidget( Okular::Annotation * ann ) | 450 | StampAnnotationWidget::StampAnnotationWidget( Okular::Annotation * ann ) | ||
425 | : AnnotationWidget( ann ), m_pixmapSelector( nullptr ) | 451 | : AnnotationWidget( ann ), m_pixmapSelector( nullptr ) | ||
426 | { | 452 | { | ||
427 | m_stampAnn = static_cast< Okular::StampAnnotation * >( ann ); | 453 | m_stampAnn = static_cast< Okular::StampAnnotation * >( ann ); | ||
428 | } | 454 | } | ||
429 | 455 | | |||
430 | void StampAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | 456 | void StampAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
431 | { | 457 | { | ||
Show All 9 Lines | |||||
441 | 467 | | |||
442 | addOpacitySpinBox( widget, formlayout ); | 468 | addOpacitySpinBox( widget, formlayout ); | ||
443 | addVerticalSpacer( formlayout ); | 469 | addVerticalSpacer( formlayout ); | ||
444 | 470 | | |||
445 | m_pixmapSelector = new PixmapPreviewSelector( widget, PixmapPreviewSelector::Below ); | 471 | m_pixmapSelector = new PixmapPreviewSelector( widget, PixmapPreviewSelector::Below ); | ||
446 | formlayout->addRow( i18n( "Stamp symbol:" ), m_pixmapSelector ); | 472 | formlayout->addRow( i18n( "Stamp symbol:" ), m_pixmapSelector ); | ||
447 | m_pixmapSelector->setEditable( true ); | 473 | m_pixmapSelector->setEditable( true ); | ||
448 | 474 | | |||
449 | m_pixmapSelector->addItem( i18n( "Okular" ), QStringLiteral("okular") ); | 475 | QPair<QString, QString> pair; | ||
450 | m_pixmapSelector->addItem( i18n( "Bookmark" ), QStringLiteral("bookmarks") ); | 476 | foreach(pair, defaultStamps) | ||
451 | m_pixmapSelector->addItem( i18n( "KDE" ), QStringLiteral("kde") ); | 477 | { | ||
452 | m_pixmapSelector->addItem( i18n( "Information" ), QStringLiteral("help-about") ); | 478 | m_pixmapSelector->addItem(pair.first, pair.second); | ||
453 | m_pixmapSelector->addItem( i18n( "Approved" ), QStringLiteral("Approved") ); | 479 | } | ||
454 | m_pixmapSelector->addItem( i18n( "As Is" ), QStringLiteral("AsIs") ); | 480 | | ||
455 | m_pixmapSelector->addItem( i18n( "Confidential" ), QStringLiteral("Confidential") ); | | |||
456 | m_pixmapSelector->addItem( i18n( "Departmental" ), QStringLiteral("Departmental") ); | | |||
457 | m_pixmapSelector->addItem( i18n( "Draft" ), QStringLiteral("Draft") ); | | |||
458 | m_pixmapSelector->addItem( i18n( "Experimental" ), QStringLiteral("Experimental") ); | | |||
459 | m_pixmapSelector->addItem( i18n( "Expired" ), QStringLiteral("Expired") ); | | |||
460 | m_pixmapSelector->addItem( i18n( "Final" ), QStringLiteral("Final") ); | | |||
461 | m_pixmapSelector->addItem( i18n( "For Comment" ), QStringLiteral("ForComment") ); | | |||
462 | m_pixmapSelector->addItem( i18n( "For Public Release" ), QStringLiteral("ForPublicRelease") ); | | |||
463 | m_pixmapSelector->addItem( i18n( "Not Approved" ), QStringLiteral("NotApproved") ); | | |||
464 | m_pixmapSelector->addItem( i18n( "Not For Public Release" ), QStringLiteral("NotForPublicRelease") ); | | |||
465 | m_pixmapSelector->addItem( i18n( "Sold" ), QStringLiteral("Sold") ); | | |||
466 | m_pixmapSelector->addItem( i18n( "Top Secret" ), QStringLiteral("TopSecret") ); | | |||
467 | m_pixmapSelector->setIcon( m_stampAnn->stampIconName() ); | 481 | m_pixmapSelector->setIcon( m_stampAnn->stampIconName() ); | ||
468 | m_pixmapSelector->setPreviewSize( 64 ); | 482 | m_pixmapSelector->setPreviewSize( 64 ); | ||
469 | 483 | | |||
470 | connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); | 484 | connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); | ||
471 | } | 485 | } | ||
472 | 486 | | |||
473 | void StampAnnotationWidget::applyChanges() | 487 | void StampAnnotationWidget::applyChanges() | ||
474 | { | 488 | { | ||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Line(s) | |||||
668 | { | 682 | { | ||
669 | m_hlAnn = static_cast< Okular::HighlightAnnotation * >( ann ); | 683 | m_hlAnn = static_cast< Okular::HighlightAnnotation * >( ann ); | ||
670 | } | 684 | } | ||
671 | 685 | | |||
672 | void HighlightAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | 686 | void HighlightAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
673 | { | 687 | { | ||
674 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | 688 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | ||
675 | 689 | | |||
690 | | ||||
676 | m_typeCombo = new KComboBox( widget ); | 691 | m_typeCombo = new KComboBox( widget ); | ||
692 | m_typeCombo->setVisible( m_typeEditable ); | ||||
693 | if( m_typeEditable ) | ||||
694 | { | ||||
677 | formlayout->addRow( i18n( "Type:" ), m_typeCombo ); | 695 | formlayout->addRow( i18n( "Type:" ), m_typeCombo ); | ||
696 | } | ||||
678 | m_typeCombo->addItem( i18n( "Highlight" ) ); | 697 | m_typeCombo->addItem( i18n( "Highlight" ) ); | ||
679 | m_typeCombo->addItem( i18n( "Squiggle" ) ); | 698 | m_typeCombo->addItem( i18n( "Squiggle" ) ); | ||
680 | m_typeCombo->addItem( i18n( "Underline" ) ); | 699 | m_typeCombo->addItem( i18n( "Underline" ) ); | ||
681 | m_typeCombo->addItem( i18n( "Strike out" ) ); | 700 | m_typeCombo->addItem( i18n( "Strike out" ) ); | ||
682 | m_typeCombo->setCurrentIndex( m_hlAnn->highlightType() ); | 701 | m_typeCombo->setCurrentIndex( m_hlAnn->highlightType() ); | ||
683 | 702 | | |||
684 | addVerticalSpacer( formlayout ); | 703 | addVerticalSpacer( formlayout ); | ||
685 | addColorButton( widget, formlayout ); | 704 | addColorButton( widget, formlayout ); | ||
Show All 16 Lines | 720 | { | |||
702 | m_geomAnn = static_cast< Okular::GeomAnnotation * >( ann ); | 721 | m_geomAnn = static_cast< Okular::GeomAnnotation * >( ann ); | ||
703 | } | 722 | } | ||
704 | 723 | | |||
705 | void GeomAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | 724 | void GeomAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
706 | { | 725 | { | ||
707 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | 726 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | ||
708 | 727 | | |||
709 | m_typeCombo = new KComboBox( widget ); | 728 | m_typeCombo = new KComboBox( widget ); | ||
729 | m_typeCombo->setVisible( m_typeEditable ); | ||||
730 | if( m_typeEditable ) | ||||
731 | { | ||||
710 | formlayout->addRow( i18n( "Type:" ), m_typeCombo ); | 732 | formlayout->addRow( i18n( "Type:" ), m_typeCombo ); | ||
733 | } | ||||
711 | addVerticalSpacer( formlayout ); | 734 | addVerticalSpacer( formlayout ); | ||
712 | addColorButton( widget, formlayout ); | 735 | addColorButton( widget, formlayout ); | ||
713 | addOpacitySpinBox( widget, formlayout ); | 736 | addOpacitySpinBox( widget, formlayout ); | ||
714 | QHBoxLayout * colorlay = new QHBoxLayout(); | 737 | QHBoxLayout * colorlay = new QHBoxLayout(); | ||
715 | m_useColor = new QCheckBox( i18n( "Enabled" ), widget ); | 738 | m_useColor = new QCheckBox( i18n( "Enabled" ), widget ); | ||
716 | colorlay->addWidget(m_useColor); | 739 | colorlay->addWidget(m_useColor); | ||
717 | m_innerColor = new KColorButton( widget ); | 740 | m_innerColor = new KColorButton( widget ); | ||
718 | colorlay->addWidget( m_innerColor); | 741 | colorlay->addWidget( m_innerColor); | ||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |