diff --git a/ui/annotationpropertiesdialog.cpp b/ui/annotationpropertiesdialog.cpp --- a/ui/annotationpropertiesdialog.cpp +++ b/ui/annotationpropertiesdialog.cpp @@ -10,6 +10,7 @@ #include "annotationpropertiesdialog.h" // qt/kde includes +#include #include #include #include @@ -61,25 +62,21 @@ QFrame* page = new QFrame( this ); addPage( page, i18n( "&General" ) ); // m_tabitem[1]->setIcon( QIcon::fromTheme( "fonts" ) ); - QGridLayout* gridlayout = new QGridLayout( page ); - tmplabel = new QLabel( i18n( "&Author:" ), page ); + QFormLayout * gridlayout = new QFormLayout( page ); AuthorEdit = new KLineEdit( ann->author(), page ); AuthorEdit->setEnabled( canEditAnnotations ); - tmplabel->setBuddy( AuthorEdit ); - gridlayout->addWidget( tmplabel, 0, 0, Qt::AlignRight ); - gridlayout->addWidget( AuthorEdit, 0, 1 ); + gridlayout->addRow( i18n( "&Author:" ), AuthorEdit ); tmplabel = new QLabel( page ); - tmplabel->setText( i18n( "Created: %1", QLocale().toString( ann->creationDate(), QLocale::LongFormat ) ) ); + tmplabel->setText( QLocale().toString( ann->creationDate(), QLocale::LongFormat ) ); tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse ); - gridlayout->addWidget( tmplabel, 1, 0, 1, 2 ); + gridlayout->addRow( i18n( "Created:" ), tmplabel ); m_modifyDateLabel = new QLabel( page ); - m_modifyDateLabel->setText( i18n( "Modified: %1", QLocale().toString( ann->modificationDate(), QLocale::LongFormat ) ) ); + m_modifyDateLabel->setText( QLocale().toString( ann->modificationDate(), QLocale::LongFormat ) ); m_modifyDateLabel->setTextInteractionFlags( Qt::TextSelectableByMouse ); - gridlayout->addWidget( m_modifyDateLabel, 2, 0, 1, 2 ); + gridlayout->addRow( i18n( "Modified:" ), m_modifyDateLabel ); - gridlayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ), 3, 0 ); //END tab 2 QWidget * extraWidget = m_annotWidget->extraWidget(); diff --git a/ui/annotationwidgets.h b/ui/annotationwidgets.h --- a/ui/annotationwidgets.h +++ b/ui/annotationwidgets.h @@ -17,6 +17,7 @@ class QCheckBox; class QComboBox; class QDoubleSpinBox; +class QFormLayout; class QLabel; class QWidget; class KColorButton; @@ -88,7 +89,7 @@ protected: QWidget * createAppearanceWidget(); - virtual QWidget * createStyleWidget(); + virtual void createStyleWidget(QFormLayout * formLayout); virtual QWidget * createExtraWidget(); private: @@ -103,7 +104,7 @@ }; class QVBoxLayout; -class QGridLayout; +class QFormLayout; class TextAnnotationWidget : public AnnotationWidget @@ -116,20 +117,20 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QFormLayout * formlayout) override; private: virtual bool hasColorButton() const override; virtual bool hasOpacityBox() const override; - void createPopupNoteStyleUi( QWidget * widget, QVBoxLayout * layout ); - void createInlineNoteStyleUi( QWidget * widget, QVBoxLayout * layout ); - void createTypewriterStyleUi( QWidget * widget, QVBoxLayout * layout ); - void addPixmapSelector( QWidget * widget, QLayout * layout ); - void addFontRequester( QWidget * widget, QGridLayout * layout ); - void addTextColorButton( QWidget * widget, QGridLayout * layout ); - void addTextAlignComboBox( QWidget * widget, QGridLayout * layout ); - void addWidthSpinBox( QWidget * widget, QGridLayout * layout ); + void createPopupNoteStyleUi( QWidget * widget, QFormLayout * formlayout ); + void createInlineNoteStyleUi( QWidget * widget, QFormLayout * formlayout ); + void createTypewriterStyleUi( QWidget * widget, QFormLayout * formlayout ); + void addPixmapSelector( QWidget * widget, QFormLayout * formlayout ); + void addFontRequester( QWidget * widget, QFormLayout * formlayout ); + void addTextColorButton( QWidget * widget, QFormLayout * formlayout ); + void addTextAlignComboBox( QWidget * widget, QFormLayout * formlayout ); + void addWidthSpinBox( QWidget * widget, QFormLayout * formlayout ); inline bool isTypewriter() const { return ( m_textAnn->inplaceIntent() == Okular::TextAnnotation::TypeWriter ); } @@ -152,7 +153,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QFormLayout * formlayout) override; private: Okular::StampAnnotation * m_stampAnn; @@ -170,7 +171,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QFormLayout * formlayout) override; private: Okular::LineAnnotation * m_lineAnn; @@ -195,7 +196,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QFormLayout * formlayout) override; private: Okular::HighlightAnnotation * m_hlAnn; @@ -213,7 +214,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QFormLayout * formlayout) override; private: Okular::GeomAnnotation * m_geomAnn; @@ -234,7 +235,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QFormLayout * formlayout) override; QWidget * createExtraWidget() override; private: @@ -253,7 +254,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QFormLayout * formlayout) override; private: Okular::CaretAnnotation * m_caretAnn; @@ -271,7 +272,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QFormLayout * formlayout) override; private: Okular::InkAnnotation * m_inkAnn; diff --git a/ui/annotationwidgets.cpp b/ui/annotationwidgets.cpp --- a/ui/annotationwidgets.cpp +++ b/ui/annotationwidgets.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "core/document.h" #include "guiutils.h" @@ -38,6 +39,7 @@ mainlay->setMargin( 0 ); m_comboItems = new KComboBox( this ); mainlay->addWidget( m_comboItems ); + mainlay->setAlignment( m_comboItems, Qt::AlignTop ); m_iconLabel = new QLabel( this ); mainlay->addWidget( m_iconLabel ); m_iconLabel->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); @@ -199,33 +201,25 @@ QWidget * AnnotationWidget::createAppearanceWidget() { QWidget * widget = new QWidget(); - QGridLayout * gridlayout = new QGridLayout( widget ); + QFormLayout * formlayout = new QFormLayout( widget ); + formlayout->setLabelAlignment( Qt::AlignRight ); + formlayout->setFieldGrowthPolicy( QFormLayout::AllNonFixedFieldsGrow ); if ( hasColorButton() ) { - QLabel * tmplabel = new QLabel( i18n( "&Color:" ), widget ); - gridlayout->addWidget( tmplabel, 0, 0, Qt::AlignRight ); m_colorBn = new KColorButton( widget ); m_colorBn->setColor( m_ann->style().color() ); - tmplabel->setBuddy( m_colorBn ); - gridlayout->addWidget( m_colorBn, 0, 1 ); + formlayout->addRow( i18n( "&Color:" ), m_colorBn ); } if ( hasOpacityBox() ) { - QLabel * tmplabel = new QLabel( i18n( "&Opacity:" ), widget ); - gridlayout->addWidget( tmplabel, 1, 0, Qt::AlignRight ); m_opacity = new QSpinBox( widget ); m_opacity->setRange( 0, 100 ); m_opacity->setValue( (int)( m_ann->style().opacity() * 100 ) ); m_opacity->setSuffix( i18nc( "Suffix for the opacity level, eg '80 %'", " %" ) ); - tmplabel->setBuddy( m_opacity ); - gridlayout->addWidget( m_opacity, 1, 1 ); + formlayout->addRow( i18n( "&Opacity:" ), m_opacity); } - QWidget * styleWidget = createStyleWidget(); - if ( styleWidget ) - gridlayout->addWidget( styleWidget, 2, 0, 1, 2 ); - - gridlayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ), 3, 0 ); + createStyleWidget( formlayout ); if ( m_colorBn ) connect( m_colorBn, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); @@ -235,9 +229,9 @@ return widget; } -QWidget * AnnotationWidget::createStyleWidget() +void AnnotationWidget::createStyleWidget(QFormLayout * formlayout) { - return nullptr; + Q_UNUSED( formlayout ); } QWidget * AnnotationWidget::createExtraWidget() @@ -252,25 +246,21 @@ m_textAnn = static_cast< Okular::TextAnnotation * >( ann ); } -QWidget * TextAnnotationWidget::createStyleWidget() +void TextAnnotationWidget::createStyleWidget(QFormLayout * formlayout) { - QWidget * widget = new QWidget(); - QVBoxLayout * layout = new QVBoxLayout( widget ); - layout->setMargin( 0 ); + QWidget * widget = (QWidget*)formlayout->parent(); if ( m_textAnn->textType() == Okular::TextAnnotation::Linked ) { - createPopupNoteStyleUi( widget, layout ); + createPopupNoteStyleUi( widget, formlayout ); } else if ( m_textAnn->textType() == Okular::TextAnnotation::InPlace ) { if ( isTypewriter() ) - createTypewriterStyleUi( widget, layout ); + createTypewriterStyleUi( widget, formlayout ); else - createInlineNoteStyleUi( widget, layout ); + createInlineNoteStyleUi( widget, formlayout ); } - - return widget; } bool TextAnnotationWidget::hasColorButton() const { @@ -307,89 +297,68 @@ } } -void TextAnnotationWidget::createPopupNoteStyleUi( QWidget * widget, QVBoxLayout * layout ) { - QGroupBox * gb = new QGroupBox( widget ); - layout->addWidget( gb ); - QHBoxLayout * gblay = new QHBoxLayout( gb ); - gb->setTitle( i18n( "Icon" ) ); - addPixmapSelector( gb, gblay ); +void TextAnnotationWidget::createPopupNoteStyleUi( QWidget * widget, QFormLayout * formlayout ) { + addPixmapSelector( widget, formlayout ); } -void TextAnnotationWidget::createInlineNoteStyleUi( QWidget * widget, QVBoxLayout * layout ) { - QGridLayout * innerlay = new QGridLayout(); - layout->addLayout( innerlay ); - addFontRequester( widget, innerlay ); - addTextAlignComboBox( widget, innerlay ); - addWidthSpinBox( widget, innerlay ); +void TextAnnotationWidget::createInlineNoteStyleUi( QWidget * widget, QFormLayout * formlayout ) { + addFontRequester( widget, formlayout ); + addTextAlignComboBox( widget, formlayout ); + addWidthSpinBox( widget, formlayout ); } -void TextAnnotationWidget::createTypewriterStyleUi( QWidget * widget, QVBoxLayout * layout ) { - QGridLayout * innerlay = new QGridLayout(); - layout->addLayout( innerlay ); - addFontRequester( widget, innerlay ); - addTextColorButton( widget, innerlay ); +void TextAnnotationWidget::createTypewriterStyleUi( QWidget * widget, QFormLayout * formlayout ) { + addFontRequester( widget, formlayout ); + addTextColorButton( widget, formlayout ); } -void TextAnnotationWidget::addPixmapSelector( QWidget * widget, QLayout * layout ) +void TextAnnotationWidget::addPixmapSelector( QWidget * widget, QFormLayout * formlayout ) { - m_pixmapSelector = new PixmapPreviewSelector( widget ); - layout->addWidget( m_pixmapSelector ); - m_pixmapSelector->addItem( i18n( "Comment" ), QStringLiteral("Comment") ); - m_pixmapSelector->addItem( i18n( "Help" ), QStringLiteral("Help") ); - m_pixmapSelector->addItem( i18n( "Insert" ), QStringLiteral("Insert") ); - m_pixmapSelector->addItem( i18n( "Key" ), QStringLiteral("Key") ); - m_pixmapSelector->addItem( i18n( "New Paragraph" ), QStringLiteral("NewParagraph") ); - m_pixmapSelector->addItem( i18n( "Note" ), QStringLiteral("Note") ); - m_pixmapSelector->addItem( i18n( "Paragraph" ), QStringLiteral("Paragraph") ); - m_pixmapSelector->setIcon( m_textAnn->textIcon() ); - connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); + m_pixmapSelector = new PixmapPreviewSelector( widget ); + formlayout->addRow( i18n( "Icon:" ), m_pixmapSelector ); + m_pixmapSelector->addItem( i18n( "Comment" ), QStringLiteral("Comment") ); + m_pixmapSelector->addItem( i18n( "Help" ), QStringLiteral("Help") ); + m_pixmapSelector->addItem( i18n( "Insert" ), QStringLiteral("Insert") ); + m_pixmapSelector->addItem( i18n( "Key" ), QStringLiteral("Key") ); + m_pixmapSelector->addItem( i18n( "New paragraph" ), QStringLiteral("NewParagraph") ); + m_pixmapSelector->addItem( i18n( "Note" ), QStringLiteral("Note") ); + m_pixmapSelector->addItem( i18n( "Paragraph" ), QStringLiteral("Paragraph") ); + m_pixmapSelector->setIcon( m_textAnn->textIcon() ); + connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); } -void TextAnnotationWidget::addFontRequester( QWidget * widget, QGridLayout * layout ) +void TextAnnotationWidget::addFontRequester( QWidget * widget, QFormLayout * formlayout ) { - const int row = layout->rowCount(); - QLabel * tmplabel = new QLabel( i18n( "Font:" ), widget ); - layout->addWidget( tmplabel, row, 0 ); m_fontReq = new KFontRequester( widget ); - layout->addWidget( m_fontReq, row, 1 ); + formlayout->addRow( i18n( "Font:" ), m_fontReq ); m_fontReq->setFont( m_textAnn->textFont() ); connect( m_fontReq, &KFontRequester::fontSelected, this, &AnnotationWidget::dataChanged ); } -void TextAnnotationWidget::addTextColorButton( QWidget * widget, QGridLayout * layout ) +void TextAnnotationWidget::addTextColorButton( QWidget * widget, QFormLayout * formlayout ) { - const int row = layout->rowCount(); - QLabel * tmplabel = new QLabel( i18n( "&Text Color:" ), widget ); - layout->addWidget( tmplabel, row, 0, Qt::AlignRight ); m_textColorBn = new KColorButton( widget ); m_textColorBn->setColor( m_textAnn->textColor() ); - tmplabel->setBuddy( m_textColorBn ); - layout->addWidget( m_textColorBn, row, 1 ); + formlayout->addRow( i18n( "&Text color:" ), m_textColorBn ); connect( m_textColorBn, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); } -void TextAnnotationWidget::addTextAlignComboBox( QWidget * widget, QGridLayout * layout ) +void TextAnnotationWidget::addTextAlignComboBox( QWidget * widget, QFormLayout * formlayout ) { - const int row = layout->rowCount(); - QLabel * tmplabel = new QLabel( i18n( "Align:" ), widget ); - layout->addWidget( tmplabel, row, 0 ); + m_textAlign = new KComboBox( widget ); - layout->addWidget( m_textAlign, row, 1 ); + formlayout->addRow( i18n( "Align:" ), m_textAlign ); m_textAlign->addItem( i18n("Left") ); m_textAlign->addItem( i18n("Center") ); m_textAlign->addItem( i18n("Right") ); m_textAlign->setCurrentIndex( m_textAnn->inplaceAlignment() ); connect( m_textAlign, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dataChanged()) ); } -void TextAnnotationWidget::addWidthSpinBox( QWidget * widget, QGridLayout * layout ) +void TextAnnotationWidget::addWidthSpinBox( QWidget * widget, QFormLayout * formlayout ) { - const int row = layout->rowCount(); - QLabel * tmplabel = new QLabel( i18n( "Border Width:" ), widget ); - layout->addWidget( tmplabel, row, 0, Qt::AlignRight ); m_spinWidth = new QDoubleSpinBox( widget ); - layout->addWidget( m_spinWidth, row, 1 ); - tmplabel->setBuddy( m_spinWidth ); + formlayout->addRow( i18n( "Border width:" ), m_spinWidth ); m_spinWidth->setRange( 0, 100 ); m_spinWidth->setValue( m_textAnn->style().width() ); m_spinWidth->setSingleStep( 0.1 ); @@ -402,17 +371,11 @@ m_stampAnn = static_cast< Okular::StampAnnotation * >( ann ); } -QWidget * StampAnnotationWidget::createStyleWidget() +void StampAnnotationWidget::createStyleWidget(QFormLayout * formlayout) { - QWidget * widget = new QWidget(); - QVBoxLayout * lay = new QVBoxLayout( widget ); - lay->setMargin( 0 ); - QGroupBox * gb = new QGroupBox( widget ); - lay->addWidget( gb ); - gb->setTitle( i18n( "Stamp Symbol" ) ); - QHBoxLayout * gblay = new QHBoxLayout( gb ); - m_pixmapSelector = new PixmapPreviewSelector( gb ); - gblay->addWidget( m_pixmapSelector ); + QWidget * widget = (QWidget*)formlayout->parent(); + m_pixmapSelector = new PixmapPreviewSelector( widget ); + formlayout->addRow( i18n( "Stamp symbol:" ), m_pixmapSelector ); m_pixmapSelector->setEditable( true ); m_pixmapSelector->addItem( i18n( "Okular" ), QStringLiteral("okular") ); @@ -437,8 +400,6 @@ m_pixmapSelector->setPreviewSize( 64 ); connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); - - return widget; } void StampAnnotationWidget::applyChanges() @@ -461,110 +422,81 @@ m_lineType = 2; // polyline } -QWidget * LineAnnotationWidget::createStyleWidget() +void LineAnnotationWidget::createStyleWidget(QFormLayout * formlayout) { - QWidget * widget = new QWidget(); - QVBoxLayout * lay = new QVBoxLayout( widget ); - lay->setMargin( 0 ); - if ( m_lineType == 0 ) - { - QGroupBox * gb = new QGroupBox( widget ); - lay->addWidget( gb ); - gb->setTitle( i18n( "Line Extensions" ) ); - QGridLayout * gridlay = new QGridLayout( gb ); - QLabel * tmplabel = new QLabel( i18n( "Leader Line Length:" ), gb ); - gridlay->addWidget( tmplabel, 0, 0, Qt::AlignRight ); - m_spinLL = new QDoubleSpinBox( gb ); - gridlay->addWidget( m_spinLL, 0, 1 ); - tmplabel->setBuddy( m_spinLL ); - tmplabel = new QLabel( i18n( "Leader Line Extensions Length:" ), gb ); - gridlay->addWidget( tmplabel, 1, 0, Qt::AlignRight ); - m_spinLLE = new QDoubleSpinBox( gb ); - gridlay->addWidget( m_spinLLE, 1, 1 ); - tmplabel->setBuddy( m_spinLLE ); - } + QWidget * widget = (QWidget*)formlayout->parent(); - QGroupBox * gb2 = new QGroupBox( widget ); - lay->addWidget( gb2 ); - gb2->setTitle( i18n( "Style" ) ); - QGridLayout * gridlay2 = new QGridLayout( gb2 ); - QLabel * tmplabel2 = new QLabel( i18n( "&Size:" ), gb2 ); - gridlay2->addWidget( tmplabel2, 0, 0, Qt::AlignRight ); - m_spinSize = new QDoubleSpinBox( gb2 ); - gridlay2->addWidget( m_spinSize, 0, 1 ); - tmplabel2->setBuddy( m_spinSize ); - - if ( m_lineType == 1 ) //Polygon - { - m_useColor = new QCheckBox( i18n( "Inner color:" ), gb2 ); - gridlay2->addWidget( m_useColor, 1, 0 ); - m_innerColor = new KColorButton( gb2 ); - gridlay2->addWidget( m_innerColor, 1, 1 ); - m_innerColor->setColor( m_lineAnn->lineInnerColor() ); - if ( m_lineAnn->lineInnerColor().isValid() ) - { - m_useColor->setChecked( true ); - } - else - { - m_innerColor->setEnabled( false ); - } - } + m_spinSize = new QDoubleSpinBox( widget ); + formlayout->addRow( i18n( "&Size:" ), m_spinSize ); - if ( m_lineType == 0 ) //Straight line - { - m_spinLL->setRange( -500, 500 ); - m_spinLL->setValue( m_lineAnn->lineLeadingForwardPoint() ); - m_spinLLE->setRange( 0, 500 ); - m_spinLLE->setValue( m_lineAnn->lineLeadingBackwardPoint() ); + m_spinSize->setRange( 1, 100 ); + m_spinSize->setValue( m_lineAnn->style().width() ); + connect( m_spinSize, QOverload::of(&QDoubleSpinBox::valueChanged), this, &LineAnnotationWidget::dataChanged ); + + // Straight line + if ( m_lineType == 0 ) + { //Line Term Styles - QLabel * tmplabel3 = new QLabel( i18n( "Line Start:" ), widget ); - QLabel * tmplabel4 = new QLabel( i18n( "Line End:" ), widget ); - gridlay2->addWidget( tmplabel3, 1, 0, Qt::AlignRight ); - gridlay2->addWidget( tmplabel4, 2, 0, Qt::AlignRight ); m_startStyleCombo = new QComboBox( widget ); + formlayout->addRow( i18n( "Line start:" ), m_startStyleCombo); m_endStyleCombo = new QComboBox( widget ); - tmplabel3->setBuddy( m_startStyleCombo ); - tmplabel4->setBuddy( m_endStyleCombo ); - gridlay2->addWidget( m_startStyleCombo, 1, 1, Qt::AlignLeft ); - gridlay2->addWidget( m_endStyleCombo, 2, 1, Qt::AlignLeft ); - tmplabel3->setToolTip( i18n("Only for PDF documents") ); - tmplabel4->setToolTip( i18n("Only for PDF documents") ); + formlayout->addRow( i18n( "Line end:" ), m_endStyleCombo); + formlayout->labelForField( m_startStyleCombo )->setToolTip( i18n("Only for PDF documents") ); + formlayout->labelForField( m_endStyleCombo )->setToolTip( i18n("Only for PDF documents") ); m_startStyleCombo->setToolTip( i18n("Only for PDF documents") ); m_endStyleCombo->setToolTip( i18n("Only for PDF documents") ); + //FIXME: Where does the tooltip goes?? - for ( const QString &i: { i18n( "Square" ), i18n( "Circle" ), i18n( "Diamond" ), i18n( "Open Arrow" ), i18n( "Closed Arrow" ), - i18n( "None" ), i18n( "Butt" ), i18n( "Right Open Arrow" ), i18n( "Right Closed Arrow" ), i18n( "Slash" ) } ) + for ( const QString &i: { i18n( "Square" ), i18n( "Circle" ), i18n( "Diamond" ), i18n( "Open arrow" ), i18n( "Closed arrow" ), + i18n( "None" ), i18n( "Butt" ), i18n( "Right open arrow" ), i18n( "Right closed arrow" ), i18n( "Slash" ) } ) { m_startStyleCombo->addItem( i ); m_endStyleCombo->addItem( i ); } m_startStyleCombo->setCurrentIndex( m_lineAnn->lineStartStyle() ); m_endStyleCombo->setCurrentIndex( m_lineAnn->lineEndStyle() ); - connect( m_startStyleCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &LineAnnotationWidget::dataChanged ); - connect( m_endStyleCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &LineAnnotationWidget::dataChanged ); - } + //Leaders lengths + m_spinLL = new QDoubleSpinBox( widget ); + formlayout->addRow( i18n( "Leader line length:" ), m_spinLL ); + m_spinLLE = new QDoubleSpinBox( widget ); + formlayout->addRow( i18n( "Leader line extensions length:" ), m_spinLLE ); - m_spinSize->setRange( 1, 100 ); - m_spinSize->setValue( m_lineAnn->style().width() ); + m_spinLL->setRange( -500, 500 ); + m_spinLL->setValue( m_lineAnn->lineLeadingForwardPoint() ); + m_spinLLE->setRange( 0, 500 ); + m_spinLLE->setValue( m_lineAnn->lineLeadingBackwardPoint() ); - if ( m_lineType == 0 ) - { + connect( m_startStyleCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &LineAnnotationWidget::dataChanged ); + connect( m_endStyleCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &LineAnnotationWidget::dataChanged ); connect( m_spinLL, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); connect( m_spinLLE, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); } - else if ( m_lineType == 1 ) + else if ( m_lineType == 1 ) // Polygon { + QHBoxLayout * colorlay = new QHBoxLayout(); + m_useColor = new QCheckBox( i18n( "Enabled" ), widget ); + colorlay->addWidget( m_useColor ); + m_innerColor = new KColorButton( widget ); + colorlay->addWidget( m_innerColor); + formlayout->addRow( i18n( "Shape fill:" ), colorlay ); + + m_innerColor->setColor( m_lineAnn->lineInnerColor() ); + if ( m_lineAnn->lineInnerColor().isValid() ) + { + m_useColor->setChecked( true ); + } + else + { + m_innerColor->setEnabled( false ); + } + connect( m_innerColor, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); connect( m_useColor, &QAbstractButton::toggled, this, &AnnotationWidget::dataChanged ); connect( m_useColor, &QCheckBox::toggled, m_innerColor, &KColorButton::setEnabled ); } - connect( m_spinSize, QOverload::of(&QDoubleSpinBox::valueChanged), this, &LineAnnotationWidget::dataChanged ); - - return widget; } void LineAnnotationWidget::applyChanges() @@ -602,28 +534,17 @@ m_inkAnn = static_cast< Okular::InkAnnotation * >( ann ); } -QWidget * InkAnnotationWidget::createStyleWidget() +void InkAnnotationWidget::createStyleWidget(QFormLayout * formlayout) { - QWidget * widget = new QWidget(); - QVBoxLayout * lay = new QVBoxLayout( widget ); - lay->setMargin( 0 ); - - QGroupBox * gb2 = new QGroupBox( widget ); - lay->addWidget( gb2 ); - gb2->setTitle( i18n( "Style" ) ); - QGridLayout * gridlay2 = new QGridLayout( gb2 ); - QLabel * tmplabel2 = new QLabel( i18n( "&Size:" ), gb2 ); - gridlay2->addWidget( tmplabel2, 0, 0, Qt::AlignRight ); - m_spinSize = new QDoubleSpinBox( gb2 ); - gridlay2->addWidget( m_spinSize, 0, 1 ); - tmplabel2->setBuddy( m_spinSize ); + QWidget * widget = (QWidget*)formlayout->parent(); + + m_spinSize = new QDoubleSpinBox( widget ); + formlayout->addRow( i18n( "&Size:" ), m_spinSize ); m_spinSize->setRange( 1, 100 ); m_spinSize->setValue( m_inkAnn->style().width() ); connect( m_spinSize, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); - - return widget; } void InkAnnotationWidget::applyChanges() @@ -640,28 +561,20 @@ m_hlAnn = static_cast< Okular::HighlightAnnotation * >( ann ); } -QWidget * HighlightAnnotationWidget::createStyleWidget() +void HighlightAnnotationWidget::createStyleWidget(QFormLayout * formlayout) { - QWidget * widget = new QWidget(); - QVBoxLayout * lay = new QVBoxLayout( widget ); - lay->setMargin( 0 ); - QHBoxLayout * typelay = new QHBoxLayout(); - lay->addLayout( typelay ); - QLabel * tmplabel = new QLabel( i18n( "Type:" ), widget ); - typelay->addWidget( tmplabel, 0, Qt::AlignRight ); + QWidget * widget = (QWidget*)formlayout->parent(); + m_typeCombo = new KComboBox( widget ); - tmplabel->setBuddy( m_typeCombo ); - typelay->addWidget( m_typeCombo ); + formlayout->addRow( i18n( "Type:" ), m_typeCombo ); m_typeCombo->addItem( i18n( "Highlight" ) ); m_typeCombo->addItem( i18n( "Squiggle" ) ); m_typeCombo->addItem( i18n( "Underline" ) ); m_typeCombo->addItem( i18n( "Strike out" ) ); m_typeCombo->setCurrentIndex( m_hlAnn->highlightType() ); connect( m_typeCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dataChanged()) ); - - return widget; } void HighlightAnnotationWidget::applyChanges() @@ -678,25 +591,20 @@ m_geomAnn = static_cast< Okular::GeomAnnotation * >( ann ); } -QWidget * GeomAnnotationWidget::createStyleWidget() +void GeomAnnotationWidget::createStyleWidget(QFormLayout * formlayout) { - QWidget * widget = new QWidget(); - QGridLayout * lay = new QGridLayout( widget ); - lay->setMargin( 0 ); - QLabel * tmplabel = new QLabel( i18n( "Type:" ), widget ); - lay->addWidget( tmplabel, 0, 0, Qt::AlignRight ); + QWidget * widget = (QWidget*)formlayout->parent(); + m_typeCombo = new KComboBox( widget ); - tmplabel->setBuddy( m_typeCombo ); - lay->addWidget( m_typeCombo, 0, 1 ); - m_useColor = new QCheckBox( i18n( "Inner color:" ), widget ); - lay->addWidget( m_useColor, 1, 0 ); + formlayout->addRow( i18n( "Type:" ), m_typeCombo ); + QHBoxLayout * colorlay = new QHBoxLayout(); + m_useColor = new QCheckBox( i18n( "Enabled" ), widget ); + colorlay->addWidget(m_useColor); m_innerColor = new KColorButton( widget ); - lay->addWidget( m_innerColor, 1, 1 ); - tmplabel = new QLabel( i18n( "&Size:" ), widget ); - lay->addWidget( tmplabel, 2, 0, Qt::AlignRight ); + colorlay->addWidget( m_innerColor); + formlayout->addRow( i18n( "Shape fill:" ), colorlay ); m_spinSize = new QDoubleSpinBox( widget ); - lay->addWidget( m_spinSize, 2, 1 ); - tmplabel->setBuddy( m_spinSize ); + formlayout->addRow( i18n( "&Size:" ), m_spinSize ); m_typeCombo->addItem( i18n( "Rectangle" ) ); m_typeCombo->addItem( i18n( "Ellipse" ) ); @@ -718,8 +626,6 @@ connect( m_useColor, &QAbstractButton::toggled, this, &AnnotationWidget::dataChanged ); connect(m_useColor, &QCheckBox::toggled, m_innerColor, &KColorButton::setEnabled); connect( m_spinSize, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); - - return widget; } void GeomAnnotationWidget::applyChanges() @@ -745,17 +651,12 @@ m_attachAnn = static_cast< Okular::FileAttachmentAnnotation * >( ann ); } -QWidget * FileAttachmentAnnotationWidget::createStyleWidget() +void FileAttachmentAnnotationWidget::createStyleWidget(QFormLayout * formlayout) { - QWidget * widget = new QWidget(); - QVBoxLayout * lay = new QVBoxLayout( widget ); - lay->setMargin( 0 ); - QGroupBox * gb = new QGroupBox( widget ); - lay->addWidget( gb ); - gb->setTitle( i18n( "File Attachment Symbol" ) ); - QHBoxLayout * gblay = new QHBoxLayout( gb ); - m_pixmapSelector = new PixmapPreviewSelector( gb ); - gblay->addWidget( m_pixmapSelector ); + QWidget * widget = (QWidget*)formlayout->parent(); + + m_pixmapSelector = new PixmapPreviewSelector( widget ); + formlayout->addRow( i18n( "File attachment symbol:" ), m_pixmapSelector ); m_pixmapSelector->setEditable( true ); m_pixmapSelector->addItem( i18nc( "Symbol for file attachment annotations", "Graph" ), QStringLiteral("graph") ); @@ -765,8 +666,6 @@ m_pixmapSelector->setIcon( m_attachAnn->fileIconName() ); connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); - - return widget; } QWidget * FileAttachmentAnnotationWidget::createExtraWidget() @@ -779,37 +678,38 @@ const QString sizeString = size <= 0 ? i18nc( "Not available size", "N/A" ) : KFormat().formatByteSize( size ); const QString descString = ef->description().isEmpty() ? i18n( "No description available." ) : ef->description(); - QGridLayout * lay = new QGridLayout( widget ); - lay->setMargin( 0 ); - QLabel * tmplabel = new QLabel( i18n( "Name: %1", ef->name() ), widget ); + QHBoxLayout * mainLay = new QHBoxLayout( widget ); + QFormLayout * lay = new QFormLayout(); + mainLay->addLayout( lay ); + + QLabel * tmplabel = new QLabel( ef->name() , widget ); tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse ); - lay->addWidget( tmplabel, 0, 0 ); + lay->addRow( i18n( "Name:" ), tmplabel ); - tmplabel = new QLabel( i18n( "Size: %1", sizeString ), widget ); + tmplabel = new QLabel( sizeString, widget ); tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse ); - lay->addWidget( tmplabel, 1, 0 ); + lay->addRow( i18n( "Size:" ), tmplabel ); - tmplabel = new QLabel( i18n( "Description:" ), widget ); - lay->addWidget( tmplabel, 2, 0 ); tmplabel = new QLabel( widget ); tmplabel->setTextFormat( Qt::PlainText ); tmplabel->setWordWrap( true ); tmplabel->setText( descString ); tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse ); - lay->addWidget( tmplabel, 3, 0, 1, 2 ); + lay->addRow( i18n( "Description:" ), tmplabel ); QMimeDatabase db; QMimeType mime = db.mimeTypeForFile( ef->name(), QMimeDatabase::MatchExtension); if ( mime.isValid() ) { tmplabel = new QLabel( widget ); tmplabel->setPixmap( QIcon::fromTheme( mime.iconName() ).pixmap( FILEATTACH_ICONSIZE, FILEATTACH_ICONSIZE ) ); tmplabel->setFixedSize( FILEATTACH_ICONSIZE, FILEATTACH_ICONSIZE ); - lay->addWidget( tmplabel, 0, 1, 3, 1, Qt::AlignTop ); + QVBoxLayout * tmpLayout = new QVBoxLayout( widget ); + tmpLayout->setAlignment( Qt::AlignTop ); + mainLay->addLayout( tmpLayout ); + tmpLayout->addWidget( tmplabel ); } - lay->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ), 4, 0 ); - return widget; } @@ -848,25 +748,18 @@ m_caretAnn = static_cast< Okular::CaretAnnotation * >( ann ); } -QWidget * CaretAnnotationWidget::createStyleWidget() +void CaretAnnotationWidget::createStyleWidget(QFormLayout * formlayout) { - QWidget * widget = new QWidget(); - QVBoxLayout * lay = new QVBoxLayout( widget ); - lay->setMargin( 0 ); - QGroupBox * gb = new QGroupBox( widget ); - lay->addWidget( gb ); - gb->setTitle( i18n( "Caret Symbol" ) ); - QHBoxLayout * gblay = new QHBoxLayout( gb ); - m_pixmapSelector = new PixmapPreviewSelector( gb ); - gblay->addWidget( m_pixmapSelector ); + QWidget * widget = (QWidget*)formlayout->parent(); + + m_pixmapSelector = new PixmapPreviewSelector( widget ); + formlayout->addRow( i18n( "Caret symbol:" ), m_pixmapSelector ); m_pixmapSelector->addItem( i18nc( "Symbol for caret annotations", "None" ), QStringLiteral("caret-none") ); m_pixmapSelector->addItem( i18nc( "Symbol for caret annotations", "P" ), QStringLiteral("caret-p") ); m_pixmapSelector->setIcon( caretSymbolToIcon( m_caretAnn->caretSymbol() ) ); connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); - - return widget; } void CaretAnnotationWidget::applyChanges()