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 All 39 Lines | 255 | { | |||
263 | return widget; | 263 | return widget; | ||
264 | } | 264 | } | ||
265 | 265 | | |||
266 | void AnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | 266 | void AnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
267 | { | 267 | { | ||
268 | Q_UNUSED( formlayout ); | 268 | Q_UNUSED( formlayout ); | ||
269 | } | 269 | } | ||
270 | 270 | | |||
271 | void AnnotationWidget::setAnnotTypeEditable( bool editable ) | ||||
272 | { | ||||
273 | m_typeEditable = editable; | ||||
274 | } | ||||
275 | | ||||
271 | void AnnotationWidget::addColorButton( QWidget * widget, QFormLayout * formlayout ) | 276 | void AnnotationWidget::addColorButton( QWidget * widget, QFormLayout * formlayout ) | ||
272 | { | 277 | { | ||
273 | m_colorBn = new KColorButton( widget ); | 278 | m_colorBn = new KColorButton( widget ); | ||
274 | m_colorBn->setColor( m_ann->style().color() ); | 279 | m_colorBn->setColor( m_ann->style().color() ); | ||
275 | formlayout->addRow( i18n( "&Color:" ), m_colorBn ); | 280 | formlayout->addRow( i18n( "&Color:" ), m_colorBn ); | ||
276 | connect( m_colorBn, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | 281 | connect( m_colorBn, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | ||
277 | } | 282 | } | ||
278 | 283 | | |||
279 | void AnnotationWidget::addOpacitySpinBox( QWidget * widget, QFormLayout * formlayout ) | 284 | void AnnotationWidget::addOpacitySpinBox( QWidget * widget, QFormLayout * formlayout ) | ||
280 | { | 285 | { | ||
281 | m_opacity = new QSpinBox( widget ); | 286 | m_opacity = new QSpinBox( widget ); | ||
282 | m_opacity->setRange( 0, 100 ); | 287 | m_opacity->setRange( 0, 100 ); | ||
283 | m_opacity->setValue( (int)( m_ann->style().opacity() * 100 ) ); | 288 | m_opacity->setValue( (int)( m_ann->style().opacity() * 100 ) ); | ||
284 | m_opacity->setSuffix( i18nc( "Suffix for the opacity level, eg '80 %'", " %" ) ); | 289 | m_opacity->setSuffix( i18nc( "Suffix for the opacity level, eg '80%'", "%" ) ); | ||
285 | formlayout->addRow( i18n( "&Opacity:" ), m_opacity); | 290 | formlayout->addRow( i18n( "&Opacity:" ), m_opacity); | ||
286 | connect( m_opacity, SIGNAL(valueChanged(int)), this, SIGNAL(dataChanged()) ); | 291 | connect( m_opacity, SIGNAL(valueChanged(int)), this, SIGNAL(dataChanged()) ); | ||
287 | } | 292 | } | ||
288 | 293 | | |||
289 | void AnnotationWidget::addVerticalSpacer( QFormLayout * formlayout ) | 294 | void AnnotationWidget::addVerticalSpacer( QFormLayout * formlayout ) | ||
290 | { | 295 | { | ||
291 | formlayout->addItem( new QSpacerItem( 0, 5, QSizePolicy::Fixed, QSizePolicy::Fixed ) ); | 296 | formlayout->addItem( new QSpacerItem( 0, 5, QSizePolicy::Fixed, QSizePolicy::Fixed ) ); | ||
292 | } | 297 | } | ||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Line(s) | 420 | { | |||
416 | m_spinWidth = new QDoubleSpinBox( widget ); | 421 | m_spinWidth = new QDoubleSpinBox( widget ); | ||
417 | formlayout->addRow( i18n( "Border &width:" ), m_spinWidth ); | 422 | formlayout->addRow( i18n( "Border &width:" ), m_spinWidth ); | ||
418 | m_spinWidth->setRange( 0, 100 ); | 423 | m_spinWidth->setRange( 0, 100 ); | ||
419 | m_spinWidth->setValue( m_textAnn->style().width() ); | 424 | m_spinWidth->setValue( m_textAnn->style().width() ); | ||
420 | m_spinWidth->setSingleStep( 0.1 ); | 425 | m_spinWidth->setSingleStep( 0.1 ); | ||
421 | connect( m_spinWidth, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | 426 | connect( m_spinWidth, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | ||
422 | } | 427 | } | ||
423 | 428 | | |||
429 | QList<QPair<QString, QString>> StampAnnotationWidget::defaultStamps() | ||||
430 | { | ||||
431 | QList<QPair<QString, QString>> stamps; | ||||
432 | stamps << QPair<QString, QString>( i18n( "Okular" ), QStringLiteral("okular") ); | ||||
433 | stamps << QPair<QString, QString>( i18n( "Bookmark" ), QStringLiteral("bookmark-new") ); | ||||
434 | stamps << QPair<QString, QString>( i18n( "KDE" ), QStringLiteral("kde") ); | ||||
435 | stamps << QPair<QString, QString>( i18n( "Information" ), QStringLiteral("help-about") ); | ||||
436 | stamps << QPair<QString, QString>( i18n( "Approved" ), QStringLiteral("Approved") ); | ||||
437 | stamps << QPair<QString, QString>( i18n( "As Is" ), QStringLiteral("AsIs") ); | ||||
438 | stamps << QPair<QString, QString>( i18n( "Confidential" ), QStringLiteral("Confidential") ); | ||||
439 | stamps << QPair<QString, QString>( i18n( "Departmental" ), QStringLiteral("Departmental") ); | ||||
440 | stamps << QPair<QString, QString>( i18n( "Draft" ), QStringLiteral("Draft") ); | ||||
441 | stamps << QPair<QString, QString>( i18n( "Experimental" ), QStringLiteral("Experimental") ); | ||||
442 | stamps << QPair<QString, QString>( i18n( "Final" ), QStringLiteral("Expired") ); | ||||
443 | stamps << QPair<QString, QString>( i18n( "For Comment" ), QStringLiteral("ForComment") ); | ||||
444 | stamps << QPair<QString, QString>( i18n( "For Public Release" ), QStringLiteral("ForPublicRelease") ); | ||||
445 | stamps << QPair<QString, QString>( i18n( "Not Approved" ), QStringLiteral("NotApproved") ); | ||||
446 | stamps << QPair<QString, QString>( i18n( "Not For Public Release" ), QStringLiteral("NotForPublicRelease") ); | ||||
447 | stamps << QPair<QString, QString>( i18n( "Sold" ), QStringLiteral("Sold") ); | ||||
448 | stamps << QPair<QString, QString>( i18n( "Top Secret" ), QStringLiteral("TopSecret") ); | ||||
449 | return stamps; | ||||
450 | } | ||||
451 | | ||||
424 | StampAnnotationWidget::StampAnnotationWidget( Okular::Annotation * ann ) | 452 | StampAnnotationWidget::StampAnnotationWidget( Okular::Annotation * ann ) | ||
425 | : AnnotationWidget( ann ), m_pixmapSelector( nullptr ) | 453 | : AnnotationWidget( ann ), m_pixmapSelector( nullptr ) | ||
426 | { | 454 | { | ||
427 | m_stampAnn = static_cast< Okular::StampAnnotation * >( ann ); | 455 | m_stampAnn = static_cast< Okular::StampAnnotation * >( ann ); | ||
428 | } | 456 | } | ||
429 | 457 | | |||
430 | void StampAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | 458 | void StampAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
431 | { | 459 | { | ||
Show All 9 Lines | |||||
441 | 469 | | |||
442 | addOpacitySpinBox( widget, formlayout ); | 470 | addOpacitySpinBox( widget, formlayout ); | ||
443 | addVerticalSpacer( formlayout ); | 471 | addVerticalSpacer( formlayout ); | ||
444 | 472 | | |||
445 | m_pixmapSelector = new PixmapPreviewSelector( widget, PixmapPreviewSelector::Below ); | 473 | m_pixmapSelector = new PixmapPreviewSelector( widget, PixmapPreviewSelector::Below ); | ||
446 | formlayout->addRow( i18n( "Stamp symbol:" ), m_pixmapSelector ); | 474 | formlayout->addRow( i18n( "Stamp symbol:" ), m_pixmapSelector ); | ||
447 | m_pixmapSelector->setEditable( true ); | 475 | m_pixmapSelector->setEditable( true ); | ||
448 | 476 | | |||
449 | m_pixmapSelector->addItem( i18n( "Okular" ), QStringLiteral("okular") ); | 477 | QPair<QString, QString> pair; | ||
450 | m_pixmapSelector->addItem( i18n( "Bookmark" ), QStringLiteral("bookmarks") ); | 478 | foreach(pair, defaultStamps()) | ||
451 | m_pixmapSelector->addItem( i18n( "KDE" ), QStringLiteral("kde") ); | 479 | { | ||
452 | m_pixmapSelector->addItem( i18n( "Information" ), QStringLiteral("help-about") ); | 480 | m_pixmapSelector->addItem(pair.first, pair.second); | ||
453 | m_pixmapSelector->addItem( i18n( "Approved" ), QStringLiteral("Approved") ); | 481 | } | ||
454 | m_pixmapSelector->addItem( i18n( "As Is" ), QStringLiteral("AsIs") ); | 482 | | ||
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() ); | 483 | m_pixmapSelector->setIcon( m_stampAnn->stampIconName() ); | ||
468 | m_pixmapSelector->setPreviewSize( 64 ); | 484 | m_pixmapSelector->setPreviewSize( 64 ); | ||
469 | 485 | | |||
470 | connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); | 486 | connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); | ||
471 | } | 487 | } | ||
472 | 488 | | |||
473 | void StampAnnotationWidget::applyChanges() | 489 | void StampAnnotationWidget::applyChanges() | ||
474 | { | 490 | { | ||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Line(s) | |||||
668 | { | 684 | { | ||
669 | m_hlAnn = static_cast< Okular::HighlightAnnotation * >( ann ); | 685 | m_hlAnn = static_cast< Okular::HighlightAnnotation * >( ann ); | ||
670 | } | 686 | } | ||
671 | 687 | | |||
672 | void HighlightAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | 688 | void HighlightAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
673 | { | 689 | { | ||
674 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | 690 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | ||
675 | 691 | | |||
692 | | ||||
676 | m_typeCombo = new KComboBox( widget ); | 693 | m_typeCombo = new KComboBox( widget ); | ||
694 | m_typeCombo->setVisible( m_typeEditable ); | ||||
695 | if( m_typeEditable ) | ||||
696 | { | ||||
677 | formlayout->addRow( i18n( "Type:" ), m_typeCombo ); | 697 | formlayout->addRow( i18n( "Type:" ), m_typeCombo ); | ||
698 | } | ||||
678 | m_typeCombo->addItem( i18n( "Highlight" ) ); | 699 | m_typeCombo->addItem( i18n( "Highlight" ) ); | ||
679 | m_typeCombo->addItem( i18n( "Squiggle" ) ); | 700 | m_typeCombo->addItem( i18n( "Squiggle" ) ); | ||
680 | m_typeCombo->addItem( i18n( "Underline" ) ); | 701 | m_typeCombo->addItem( i18n( "Underline" ) ); | ||
681 | m_typeCombo->addItem( i18n( "Strike out" ) ); | 702 | m_typeCombo->addItem( i18n( "Strike out" ) ); | ||
682 | m_typeCombo->setCurrentIndex( m_hlAnn->highlightType() ); | 703 | m_typeCombo->setCurrentIndex( m_hlAnn->highlightType() ); | ||
683 | 704 | | |||
684 | addVerticalSpacer( formlayout ); | 705 | addVerticalSpacer( formlayout ); | ||
685 | addColorButton( widget, formlayout ); | 706 | addColorButton( widget, formlayout ); | ||
Show All 15 Lines | |||||
701 | { | 722 | { | ||
702 | m_geomAnn = static_cast< Okular::GeomAnnotation * >( ann ); | 723 | m_geomAnn = static_cast< Okular::GeomAnnotation * >( ann ); | ||
703 | } | 724 | } | ||
704 | 725 | | |||
705 | void GeomAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | 726 | void GeomAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
706 | { | 727 | { | ||
707 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | 728 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | ||
708 | 729 | | |||
730 | | ||||
709 | m_typeCombo = new KComboBox( widget ); | 731 | m_typeCombo = new KComboBox( widget ); | ||
732 | m_typeCombo->setVisible( m_typeEditable ); | ||||
733 | if( m_typeEditable ) | ||||
734 | { | ||||
710 | formlayout->addRow( i18n( "Type:" ), m_typeCombo ); | 735 | formlayout->addRow( i18n( "Type:" ), m_typeCombo ); | ||
736 | } | ||||
711 | addVerticalSpacer( formlayout ); | 737 | addVerticalSpacer( formlayout ); | ||
712 | addColorButton( widget, formlayout ); | 738 | addColorButton( widget, formlayout ); | ||
713 | addOpacitySpinBox( widget, formlayout ); | 739 | addOpacitySpinBox( widget, formlayout ); | ||
714 | QHBoxLayout * colorlay = new QHBoxLayout(); | 740 | QHBoxLayout * colorlay = new QHBoxLayout(); | ||
715 | m_useColor = new QCheckBox( i18n( "Enabled" ), widget ); | 741 | m_useColor = new QCheckBox( i18n( "Enabled" ), widget ); | ||
716 | colorlay->addWidget(m_useColor); | 742 | colorlay->addWidget(m_useColor); | ||
717 | m_innerColor = new KColorButton( widget ); | 743 | m_innerColor = new KColorButton( widget ); | ||
718 | colorlay->addWidget( m_innerColor); | 744 | colorlay->addWidget( m_innerColor); | ||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |