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 QGridLayout; class QLabel; class QWidget; class KColorButton; @@ -88,7 +89,7 @@ protected: QWidget * createAppearanceWidget(); - virtual QWidget * createStyleWidget(); + virtual void createStyleWidget(QGridLayout * gridLayout); virtual QWidget * createExtraWidget(); Okular::Annotation * m_ann; @@ -109,7 +110,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QGridLayout * gridLayout) override; private: Okular::TextAnnotation * m_textAnn; @@ -130,7 +131,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QGridLayout * gridLayout) override; private: Okular::StampAnnotation * m_stampAnn; @@ -148,7 +149,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QGridLayout * gridLayout) override; private: Okular::LineAnnotation * m_lineAnn; @@ -171,7 +172,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QGridLayout * gridLayout) override; private: Okular::HighlightAnnotation * m_hlAnn; @@ -189,7 +190,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QGridLayout * gridLayout) override; private: Okular::GeomAnnotation * m_geomAnn; @@ -210,7 +211,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QGridLayout * gridLayout) override; QWidget * createExtraWidget() override; private: @@ -229,7 +230,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QGridLayout * gridLayout) override; private: Okular::CaretAnnotation * m_caretAnn; @@ -247,7 +248,7 @@ void applyChanges() override; protected: - QWidget * createStyleWidget() override; + void createStyleWidget(QGridLayout * gridLayout) override; private: Okular::InkAnnotation * m_inkAnn; diff --git a/ui/annotationwidgets.cpp b/ui/annotationwidgets.cpp --- a/ui/annotationwidgets.cpp +++ b/ui/annotationwidgets.cpp @@ -215,21 +215,20 @@ tmplabel->setBuddy( m_opacity ); gridlayout->addWidget( m_opacity, 1, 1 ); - QWidget * styleWidget = createStyleWidget(); - if ( styleWidget ) - gridlayout->addWidget( styleWidget, 2, 0, 1, 2 ); + createStyleWidget(gridlayout); - gridlayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ), 3, 0 ); + gridlayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ), + gridlayout->rowCount()+1, 0 ); connect( m_colorBn, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); connect( m_opacity, SIGNAL(valueChanged(int)), this, SIGNAL(dataChanged()) ); return widget; } -QWidget * AnnotationWidget::createStyleWidget() +void AnnotationWidget::createStyleWidget(QGridLayout * gridLayout) { - return nullptr; + return; } QWidget * AnnotationWidget::createExtraWidget() @@ -244,20 +243,16 @@ m_textAnn = static_cast< Okular::TextAnnotation * >( ann ); } -QWidget * TextAnnotationWidget::createStyleWidget() +void TextAnnotationWidget::createStyleWidget(QGridLayout * gridLayout) { - QWidget * widget = new QWidget(); - QVBoxLayout * lay = new QVBoxLayout( widget ); - lay->setMargin( 0 ); - + int row = gridLayout->rowCount(); + QWidget * widget = (QWidget*)gridLayout->parent(); if ( m_textAnn->textType() == Okular::TextAnnotation::Linked ) { - QGroupBox * gb = new QGroupBox( widget ); - lay->addWidget( gb ); - gb->setTitle( i18n( "Icon" ) ); - QHBoxLayout * gblay = new QHBoxLayout( gb ); - m_pixmapSelector = new PixmapPreviewSelector( gb ); - gblay->addWidget( m_pixmapSelector ); + QLabel * icon = new QLabel(i18n( "Icon:" ), widget); + gridLayout->addWidget(icon, row, 0, Qt::AlignRight ); + m_pixmapSelector = new PixmapPreviewSelector( widget ); + gridLayout->addWidget( m_pixmapSelector, row, 1 ); m_pixmapSelector->addItem( i18n( "Comment" ), QStringLiteral("Comment") ); m_pixmapSelector->addItem( i18n( "Help" ), QStringLiteral("Help") ); @@ -272,28 +267,25 @@ } else if ( m_textAnn->textType() == Okular::TextAnnotation::InPlace ) { - QGridLayout * innerlay = new QGridLayout(); - lay->addLayout( innerlay ); - QLabel * tmplabel = new QLabel( i18n( "Font:" ), widget ); - innerlay->addWidget( tmplabel, 0, 0 ); + gridLayout->addWidget( tmplabel, row, 0, Qt::AlignRight ); m_fontReq = new KFontRequester( widget ); - innerlay->addWidget( m_fontReq, 0, 1 ); + gridLayout->addWidget( m_fontReq, row, 1 ); m_fontReq->setFont( m_textAnn->textFont() ); tmplabel = new QLabel( i18n( "Align:" ), widget ); - innerlay->addWidget( tmplabel, 1, 0 ); + gridLayout->addWidget( tmplabel, row+1, 0, Qt::AlignRight ); m_textAlign = new KComboBox( widget ); - innerlay->addWidget( m_textAlign, 1, 1 ); + gridLayout->addWidget( m_textAlign, row+1, 1 ); m_textAlign->addItem( i18n("Left") ); m_textAlign->addItem( i18n("Center") ); m_textAlign->addItem( i18n("Right") ); m_textAlign->setCurrentIndex( m_textAnn->inplaceAlignment() ); - tmplabel = new QLabel( i18n( "Border Width:" ), widget ); - innerlay->addWidget( tmplabel, 2, 0, Qt::AlignRight ); + tmplabel = new QLabel( i18n( "Border width:" ), widget ); + gridLayout->addWidget( tmplabel, row+2, 0, Qt::AlignRight ); m_spinWidth = new QDoubleSpinBox( widget ); - innerlay->addWidget( m_spinWidth, 2, 1 ); + gridLayout->addWidget( m_spinWidth, row+2, 1 ); tmplabel->setBuddy( m_spinWidth ); m_spinWidth->setRange( 0, 100 ); m_spinWidth->setValue( m_textAnn->style().width() ); @@ -305,7 +297,7 @@ connect( m_spinWidth, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); } - return widget; + return; } void TextAnnotationWidget::applyChanges() @@ -330,17 +322,16 @@ m_stampAnn = static_cast< Okular::StampAnnotation * >( ann ); } -QWidget * StampAnnotationWidget::createStyleWidget() +void StampAnnotationWidget::createStyleWidget(QGridLayout * gridLayout) { - 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 ); + int row = gridLayout->rowCount(); + QWidget * widget = (QWidget*)gridLayout->parent(); + QLabel * tmplabel = new QLabel( i18n( "Stamp symbol:" ), widget ); + gridLayout->addWidget( tmplabel, row, 0, Qt::AlignRight); + + QHBoxLayout * gblay = new QHBoxLayout( widget ); + m_pixmapSelector = new PixmapPreviewSelector( widget ); + gridLayout->addWidget( m_pixmapSelector, row, 1 ); m_pixmapSelector->setEditable( true ); m_pixmapSelector->addItem( i18n( "Okular" ), QStringLiteral("okular") ); @@ -366,7 +357,7 @@ connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); - return widget; + return; } void StampAnnotationWidget::applyChanges() @@ -389,45 +380,43 @@ m_lineType = 2; // polyline } -QWidget * LineAnnotationWidget::createStyleWidget() +void LineAnnotationWidget::createStyleWidget(QGridLayout * gridLayout) { - QWidget * widget = new QWidget(); - QVBoxLayout * lay = new QVBoxLayout( widget ); - lay->setMargin( 0 ); + int row = gridLayout->rowCount(); + QWidget * widget = (QWidget*)gridLayout->parent(); + + QLabel * tmplabel = new QLabel( i18n( "&Size:" ), widget ); + gridLayout->addWidget( tmplabel, row, 0, Qt::AlignRight ); + m_spinSize = new QDoubleSpinBox( widget ); + gridLayout->addWidget( m_spinSize, row, 1 ); + tmplabel->setBuddy( m_spinSize ); + + // Straight line 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 = new QLabel( i18n( "Leader line length:" ), widget ); + gridLayout->addWidget( tmplabel, row+1, 0, Qt::AlignRight ); + m_spinLL = new QDoubleSpinBox( widget ); + gridLayout->addWidget( m_spinLL, row+1, 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 = new QLabel( i18n( "Leader line extensions length:" ), widget ); + gridLayout->addWidget( tmplabel, row+2, 0, Qt::AlignRight ); + m_spinLLE = new QDoubleSpinBox( widget ); + gridLayout->addWidget( m_spinLLE, row+2, 1 ); tmplabel->setBuddy( m_spinLLE ); } - 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 ); - + // Polygon if ( m_lineType == 1 ) { - 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 ); + tmplabel = new QLabel( i18n( "Shape fill:" ), widget); + gridLayout->addWidget( tmplabel, row+1, 0, Qt::AlignRight ); + QHBoxLayout * colorlay = new QHBoxLayout(widget); + m_useColor = new QCheckBox( i18n( "Enabled" ), widget ); + colorlay->addWidget(m_useColor); + m_innerColor = new KColorButton( widget ); + colorlay->addWidget( m_innerColor); + gridLayout->addLayout( colorlay, row+1, 1 ); } if ( m_lineType == 0 ) @@ -465,7 +454,7 @@ } connect( m_spinSize, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); - return widget; + return; } void LineAnnotationWidget::applyChanges() @@ -498,28 +487,23 @@ m_inkAnn = static_cast< Okular::InkAnnotation * >( ann ); } -QWidget * InkAnnotationWidget::createStyleWidget() +void InkAnnotationWidget::createStyleWidget(QGridLayout * gridLayout) { - QWidget * widget = new QWidget(); - QVBoxLayout * lay = new QVBoxLayout( widget ); - lay->setMargin( 0 ); + int row = gridLayout->rowCount(); + QWidget * widget = (QWidget*)gridLayout->parent(); + QLabel * tmplabel = new QLabel( i18n( "&Size:" ), widget ); - 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 ); + gridLayout->addWidget( tmplabel, row, 0, Qt::AlignRight ); + m_spinSize = new QDoubleSpinBox( widget ); + gridLayout->addWidget( m_spinSize, row, 1 ); + tmplabel->setBuddy( 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; + return; } void InkAnnotationWidget::applyChanges() @@ -536,18 +520,15 @@ m_hlAnn = static_cast< Okular::HighlightAnnotation * >( ann ); } -QWidget * HighlightAnnotationWidget::createStyleWidget() +void HighlightAnnotationWidget::createStyleWidget(QGridLayout * gridLayout) { - QWidget * widget = new QWidget(); - QVBoxLayout * lay = new QVBoxLayout( widget ); - lay->setMargin( 0 ); - QHBoxLayout * typelay = new QHBoxLayout(); - lay->addLayout( typelay ); + int row = gridLayout->rowCount(); + QWidget * widget = (QWidget*)gridLayout->parent(); QLabel * tmplabel = new QLabel( i18n( "Type:" ), widget ); - typelay->addWidget( tmplabel, 0, Qt::AlignRight ); + gridLayout->addWidget( tmplabel, row, 0, Qt::AlignRight); m_typeCombo = new KComboBox( widget ); tmplabel->setBuddy( m_typeCombo ); - typelay->addWidget( m_typeCombo ); + gridLayout->addWidget( m_typeCombo, row, 1 ); m_typeCombo->addItem( i18n( "Highlight" ) ); m_typeCombo->addItem( i18n( "Squiggle" ) ); @@ -557,7 +538,7 @@ connect( m_typeCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dataChanged()) ); - return widget; + return; } void HighlightAnnotationWidget::applyChanges() @@ -574,24 +555,27 @@ m_geomAnn = static_cast< Okular::GeomAnnotation * >( ann ); } -QWidget * GeomAnnotationWidget::createStyleWidget() +void GeomAnnotationWidget::createStyleWidget(QGridLayout * gridLayout) { - QWidget * widget = new QWidget(); - QGridLayout * lay = new QGridLayout( widget ); - lay->setMargin( 0 ); + int row = gridLayout->rowCount(); + QWidget * widget = (QWidget*)gridLayout->parent(); QLabel * tmplabel = new QLabel( i18n( "Type:" ), widget ); - lay->addWidget( tmplabel, 0, 0, Qt::AlignRight ); + gridLayout->addWidget( tmplabel, row, 0, Qt::AlignRight); 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 ); + gridLayout->addWidget( m_typeCombo, row, 1 ); + tmplabel = new QLabel( i18n( "Shape fill:" ), widget); + gridLayout->addWidget( tmplabel, row+1, 0, Qt::AlignRight ); + QHBoxLayout * colorlay = new QHBoxLayout(widget); + m_useColor = new QCheckBox( i18n( "Enabled" ), widget ); + colorlay->addWidget(m_useColor); m_innerColor = new KColorButton( widget ); - lay->addWidget( m_innerColor, 1, 1 ); + colorlay->addWidget( m_innerColor); + gridLayout->addLayout( colorlay, row+1, 1 ); tmplabel = new QLabel( i18n( "&Size:" ), widget ); - lay->addWidget( tmplabel, 2, 0, Qt::AlignRight ); + gridLayout->addWidget( tmplabel, row+2, 0, Qt::AlignRight ); m_spinSize = new QDoubleSpinBox( widget ); - lay->addWidget( m_spinSize, 2, 1 ); + gridLayout->addWidget( m_spinSize, row+2, 1 ); tmplabel->setBuddy( m_spinSize ); m_typeCombo->addItem( i18n( "Rectangle" ) ); @@ -615,7 +599,7 @@ connect(m_useColor, &QCheckBox::toggled, m_innerColor, &KColorButton::setEnabled); connect( m_spinSize, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); - return widget; + return; } void GeomAnnotationWidget::applyChanges() @@ -641,7 +625,7 @@ m_attachAnn = static_cast< Okular::FileAttachmentAnnotation * >( ann ); } -QWidget * FileAttachmentAnnotationWidget::createStyleWidget() +void FileAttachmentAnnotationWidget::createStyleWidget(QGridLayout * gridLayout) { QWidget * widget = new QWidget(); QVBoxLayout * lay = new QVBoxLayout( widget ); @@ -662,7 +646,7 @@ connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); - return widget; + return; } QWidget * FileAttachmentAnnotationWidget::createExtraWidget() @@ -744,7 +728,7 @@ m_caretAnn = static_cast< Okular::CaretAnnotation * >( ann ); } -QWidget * CaretAnnotationWidget::createStyleWidget() +void CaretAnnotationWidget::createStyleWidget(QGridLayout * gridLayout) { QWidget * widget = new QWidget(); QVBoxLayout * lay = new QVBoxLayout( widget ); @@ -762,7 +746,7 @@ connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); - return widget; + return; } void CaretAnnotationWidget::applyChanges()