Changeset View
Standalone View
ui/annotationwidgets.cpp
Show All 23 Lines | |||||
24 | #include <KLocalizedString> | 24 | #include <KLocalizedString> | ||
25 | #include <QDebug> | 25 | #include <QDebug> | ||
26 | #include <QGuiApplication> | 26 | #include <QGuiApplication> | ||
27 | #include <QList> | 27 | #include <QList> | ||
28 | #include <QMimeDatabase> | 28 | #include <QMimeDatabase> | ||
29 | #include <QPair> | 29 | #include <QPair> | ||
30 | #include <QSize> | 30 | #include <QSize> | ||
31 | #include <KFormat> | 31 | #include <KFormat> | ||
32 | #include <QFormLayout> | ||||
32 | 33 | | |||
33 | #include "core/document.h" | 34 | #include "core/document.h" | ||
34 | #include "guiutils.h" | 35 | #include "guiutils.h" | ||
35 | #include "pagepainter.h" | 36 | #include "pagepainter.h" | ||
36 | 37 | | |||
37 | #define FILEATTACH_ICONSIZE 48 | 38 | #define FILEATTACH_ICONSIZE 48 | ||
38 | 39 | | |||
39 | PixmapPreviewSelector::PixmapPreviewSelector( QWidget * parent ) | 40 | PixmapPreviewSelector::PixmapPreviewSelector( QWidget * parent ) | ||
40 | : QWidget( parent ) | 41 | : QWidget( parent ) | ||
41 | { | 42 | { | ||
42 | QHBoxLayout * mainlay = new QHBoxLayout( this ); | 43 | QHBoxLayout * mainlay = new QHBoxLayout( this ); | ||
43 | mainlay->setMargin( 0 ); | 44 | mainlay->setMargin( 0 ); | ||
44 | m_comboItems = new KComboBox( this ); | 45 | m_comboItems = new KComboBox( this ); | ||
45 | mainlay->addWidget( m_comboItems ); | 46 | mainlay->addWidget( m_comboItems ); | ||
47 | mainlay->setAlignment( m_comboItems, Qt::AlignTop ); | ||||
46 | m_iconLabel = new QLabel( this ); | 48 | m_iconLabel = new QLabel( this ); | ||
47 | mainlay->addWidget( m_iconLabel ); | 49 | mainlay->addWidget( m_iconLabel ); | ||
48 | m_iconLabel->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); | 50 | m_iconLabel->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); | ||
49 | m_iconLabel->setAlignment( Qt::AlignCenter ); | 51 | m_iconLabel->setAlignment( Qt::AlignCenter ); | ||
50 | m_iconLabel->setFrameStyle( QFrame::StyledPanel ); | 52 | m_iconLabel->setFrameStyle( QFrame::StyledPanel ); | ||
51 | setPreviewSize( 32 ); | 53 | setPreviewSize( 32 ); | ||
52 | 54 | | |||
55 | setFocusPolicy( Qt::TabFocus ); | ||||
56 | setFocusProxy( m_comboItems ); | ||||
57 | | ||||
53 | connect( m_comboItems, SIGNAL(currentIndexChanged(QString)), this, SLOT(iconComboChanged(QString)) ); | 58 | connect( m_comboItems, SIGNAL(currentIndexChanged(QString)), this, SLOT(iconComboChanged(QString)) ); | ||
54 | connect( m_comboItems, &QComboBox::editTextChanged, this, &PixmapPreviewSelector::iconComboChanged ); | 59 | connect( m_comboItems, &QComboBox::editTextChanged, this, &PixmapPreviewSelector::iconComboChanged ); | ||
55 | } | 60 | } | ||
56 | 61 | | |||
57 | PixmapPreviewSelector::~PixmapPreviewSelector() | 62 | PixmapPreviewSelector::~PixmapPreviewSelector() | ||
58 | { | 63 | { | ||
59 | } | 64 | } | ||
60 | 65 | | |||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Line(s) | 203 | if (m_colorBn) | |||
199 | m_ann->style().setColor( m_colorBn->color() ); | 204 | m_ann->style().setColor( m_colorBn->color() ); | ||
200 | if (m_opacity) | 205 | if (m_opacity) | ||
201 | m_ann->style().setOpacity( (double)m_opacity->value() / 100.0 ); | 206 | m_ann->style().setOpacity( (double)m_opacity->value() / 100.0 ); | ||
202 | } | 207 | } | ||
203 | 208 | | |||
204 | QWidget * AnnotationWidget::createAppearanceWidget() | 209 | QWidget * AnnotationWidget::createAppearanceWidget() | ||
205 | { | 210 | { | ||
206 | QWidget * widget = new QWidget(); | 211 | QWidget * widget = new QWidget(); | ||
207 | QGridLayout * gridlayout = new QGridLayout( widget ); | 212 | QFormLayout * formlayout = new QFormLayout( widget ); | ||
208 | if ( hasColorButton() ) | 213 | formlayout->setLabelAlignment( Qt::AlignRight ); | ||
simgunz: Is it correct to set this growth policy? I have not found any guideline on the HIG. Compared to… | |||||
For this one, FieldsStayAtSizeHint might be better, and then we just set sensible sizehints for anything that winds up too small. That's basically what we're doing for all our QML software. In general we're trying to move towards making the controls optimally sized in the first place and then static in size when the window grows or shrinks. We often manually set the width of spinboxes, comboboxes, and text fields to make sure they're all the same width. ngraham: For this one, `FieldsStayAtSizeHint` might be better, and then we just set sensible sizehints… | |||||
Let's not have static sizes, this is not a phone screen where you can't resize windows. aacid: Let's not have static sizes, this is not a phone screen where you can't resize windows. | |||||
214 | formlayout->setFieldGrowthPolicy( QFormLayout::AllNonFixedFieldsGrow ); | ||||
215 | | ||||
216 | createStyleWidget( formlayout ); | ||||
217 | | ||||
218 | return widget; | ||||
219 | } | ||||
220 | | ||||
221 | void AnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||||
222 | { | ||||
223 | Q_UNUSED( formlayout ); | ||||
224 | } | ||||
225 | | ||||
226 | void AnnotationWidget::addColorButton( QWidget * widget, QFormLayout * formlayout ) | ||||
209 | { | 227 | { | ||
210 | QLabel * tmplabel = new QLabel( i18n( "&Color:" ), widget ); | | |||
211 | gridlayout->addWidget( tmplabel, 0, 0, Qt::AlignRight ); | | |||
212 | m_colorBn = new KColorButton( widget ); | 228 | m_colorBn = new KColorButton( widget ); | ||
213 | m_colorBn->setColor( m_ann->style().color() ); | 229 | m_colorBn->setColor( m_ann->style().color() ); | ||
214 | tmplabel->setBuddy( m_colorBn ); | 230 | formlayout->addRow( i18n( "&Color:" ), m_colorBn ); | ||
215 | gridlayout->addWidget( m_colorBn, 0, 1 ); | 231 | connect( m_colorBn, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | ||
216 | } | 232 | } | ||
217 | if ( hasOpacityBox() ) | 233 | | ||
234 | void AnnotationWidget::addOpacitySpinBox( QWidget * widget, QFormLayout * formlayout ) | ||||
218 | { | 235 | { | ||
219 | QLabel * tmplabel = new QLabel( i18n( "&Opacity:" ), widget ); | | |||
220 | gridlayout->addWidget( tmplabel, 1, 0, Qt::AlignRight ); | | |||
221 | m_opacity = new QSpinBox( widget ); | 236 | m_opacity = new QSpinBox( widget ); | ||
222 | m_opacity->setRange( 0, 100 ); | 237 | m_opacity->setRange( 0, 100 ); | ||
223 | m_opacity->setValue( (int)( m_ann->style().opacity() * 100 ) ); | 238 | m_opacity->setValue( (int)( m_ann->style().opacity() * 100 ) ); | ||
224 | m_opacity->setSuffix( i18nc( "Suffix for the opacity level, eg '80 %'", " %" ) ); | 239 | m_opacity->setSuffix( i18nc( "Suffix for the opacity level, eg '80 %'", " %" ) ); | ||
225 | tmplabel->setBuddy( m_opacity ); | 240 | formlayout->addRow( i18n( "&Opacity:" ), m_opacity); | ||
226 | gridlayout->addWidget( m_opacity, 1, 1 ); | | |||
227 | } | | |||
228 | | ||||
229 | QWidget * styleWidget = createStyleWidget(); | | |||
230 | if ( styleWidget ) | | |||
231 | gridlayout->addWidget( styleWidget, 2, 0, 1, 2 ); | | |||
232 | | ||||
233 | gridlayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ), 3, 0 ); | | |||
234 | | ||||
235 | if ( m_colorBn ) | | |||
236 | connect( m_colorBn, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | | |||
237 | if ( m_opacity ) | | |||
238 | connect( m_opacity, SIGNAL(valueChanged(int)), this, SIGNAL(dataChanged()) ); | 241 | connect( m_opacity, SIGNAL(valueChanged(int)), this, SIGNAL(dataChanged()) ); | ||
239 | | ||||
240 | return widget; | | |||
241 | } | 242 | } | ||
242 | 243 | | |||
243 | QWidget * AnnotationWidget::createStyleWidget() | 244 | void AnnotationWidget::addVerticalSpacer( QFormLayout * formlayout ) | ||
244 | { | 245 | { | ||
245 | return nullptr; | 246 | formlayout->addItem( new QSpacerItem( 0, 5, QSizePolicy::Fixed, QSizePolicy::Fixed ) ); | ||
246 | } | 247 | } | ||
247 | 248 | | |||
248 | QWidget * AnnotationWidget::createExtraWidget() | 249 | QWidget * AnnotationWidget::createExtraWidget() | ||
249 | { | 250 | { | ||
250 | return nullptr; | 251 | return nullptr; | ||
251 | } | 252 | } | ||
252 | 253 | | |||
253 | 254 | | |||
254 | TextAnnotationWidget::TextAnnotationWidget( Okular::Annotation * ann ) | 255 | TextAnnotationWidget::TextAnnotationWidget( Okular::Annotation * ann ) | ||
255 | : AnnotationWidget( ann ) | 256 | : AnnotationWidget( ann ) | ||
256 | { | 257 | { | ||
257 | m_textAnn = static_cast< Okular::TextAnnotation * >( ann ); | 258 | m_textAnn = static_cast< Okular::TextAnnotation * >( ann ); | ||
258 | } | 259 | } | ||
259 | 260 | | |||
260 | QWidget * TextAnnotationWidget::createStyleWidget() | 261 | void TextAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
261 | { | 262 | { | ||
262 | QWidget * widget = new QWidget(); | 263 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | ||
263 | QVBoxLayout * layout = new QVBoxLayout( widget ); | | |||
264 | layout->setMargin( 0 ); | | |||
265 | 264 | | |||
266 | if ( m_textAnn->textType() == Okular::TextAnnotation::Linked ) | 265 | if ( m_textAnn->textType() == Okular::TextAnnotation::Linked ) | ||
267 | { | 266 | { | ||
268 | createPopupNoteStyleUi( widget, layout ); | 267 | createPopupNoteStyleUi( widget, formlayout ); | ||
269 | } | 268 | } | ||
270 | else if ( m_textAnn->textType() == Okular::TextAnnotation::InPlace ) | 269 | else if ( m_textAnn->textType() == Okular::TextAnnotation::InPlace ) | ||
271 | { | 270 | { | ||
272 | if ( isTypewriter() ) | 271 | if ( isTypewriter() ) | ||
273 | createTypewriterStyleUi( widget, layout ); | 272 | createTypewriterStyleUi( widget, formlayout ); | ||
274 | else | 273 | else | ||
275 | createInlineNoteStyleUi( widget, layout ); | 274 | createInlineNoteStyleUi( widget, formlayout ); | ||
276 | } | 275 | } | ||
277 | | ||||
278 | return widget; | | |||
279 | } | | |||
280 | | ||||
281 | bool TextAnnotationWidget::hasColorButton() const { | | |||
282 | return !isTypewriter(); | | |||
283 | } | | |||
284 | | ||||
285 | bool TextAnnotationWidget::hasOpacityBox() const { | | |||
286 | return !isTypewriter(); | | |||
287 | } | 276 | } | ||
288 | 277 | | |||
289 | void TextAnnotationWidget::applyChanges() | 278 | void TextAnnotationWidget::applyChanges() | ||
290 | { | 279 | { | ||
291 | AnnotationWidget::applyChanges(); | 280 | AnnotationWidget::applyChanges(); | ||
292 | if ( m_textAnn->textType() == Okular::TextAnnotation::Linked ) | 281 | if ( m_textAnn->textType() == Okular::TextAnnotation::Linked ) | ||
293 | { | 282 | { | ||
294 | Q_ASSERT( m_pixmapSelector ); | 283 | Q_ASSERT( m_pixmapSelector ); | ||
Show All 12 Lines | 287 | { | |||
307 | else | 296 | else | ||
308 | { | 297 | { | ||
309 | Q_ASSERT( m_textColorBn ); | 298 | Q_ASSERT( m_textColorBn ); | ||
310 | m_textAnn->setTextColor( m_textColorBn->color() ); | 299 | m_textAnn->setTextColor( m_textColorBn->color() ); | ||
311 | } | 300 | } | ||
312 | } | 301 | } | ||
313 | } | 302 | } | ||
314 | 303 | | |||
315 | void TextAnnotationWidget::createPopupNoteStyleUi( QWidget * widget, QVBoxLayout * layout ) { | 304 | void TextAnnotationWidget::createPopupNoteStyleUi( QWidget * widget, QFormLayout * formlayout ) { | ||
316 | QGroupBox * gb = new QGroupBox( widget ); | 305 | addColorButton( widget, formlayout ); | ||
317 | layout->addWidget( gb ); | 306 | addOpacitySpinBox( widget, formlayout ); | ||
318 | QHBoxLayout * gblay = new QHBoxLayout( gb ); | 307 | addVerticalSpacer( formlayout ); | ||
319 | gb->setTitle( i18n( "Icon" ) ); | 308 | addPixmapSelector( widget, formlayout ); | ||
320 | addPixmapSelector( gb, gblay ); | 309 | } | ||
321 | } | 310 | | ||
322 | 311 | void TextAnnotationWidget::createInlineNoteStyleUi( QWidget * widget, QFormLayout * formlayout ) { | |||
323 | void TextAnnotationWidget::createInlineNoteStyleUi( QWidget * widget, QVBoxLayout * layout ) { | 312 | addColorButton( widget, formlayout ); | ||
324 | QGridLayout * innerlay = new QGridLayout(); | 313 | addOpacitySpinBox( widget, formlayout ); | ||
325 | layout->addLayout( innerlay ); | 314 | addVerticalSpacer( formlayout ); | ||
326 | addFontRequester( widget, innerlay ); | 315 | addFontRequester( widget, formlayout ); | ||
327 | addTextAlignComboBox( widget, innerlay ); | 316 | addTextAlignComboBox( widget, formlayout ); | ||
328 | addWidthSpinBox( widget, innerlay ); | 317 | addVerticalSpacer( formlayout ); | ||
329 | } | 318 | addWidthSpinBox( widget, formlayout ); | ||
330 | 319 | } | |||
331 | void TextAnnotationWidget::createTypewriterStyleUi( QWidget * widget, QVBoxLayout * layout ) { | 320 | | ||
332 | QGridLayout * innerlay = new QGridLayout(); | 321 | void TextAnnotationWidget::createTypewriterStyleUi( QWidget * widget, QFormLayout * formlayout ) { | ||
333 | layout->addLayout( innerlay ); | 322 | addFontRequester( widget, formlayout ); | ||
334 | addFontRequester( widget, innerlay ); | 323 | addTextColorButton( widget, formlayout ); | ||
335 | addTextColorButton( widget, innerlay ); | | |||
336 | } | 324 | } | ||
337 | 325 | | |||
338 | void TextAnnotationWidget::addPixmapSelector( QWidget * widget, QLayout * layout ) | 326 | void TextAnnotationWidget::addPixmapSelector( QWidget * widget, QFormLayout * formlayout ) | ||
339 | { | 327 | { | ||
340 | m_pixmapSelector = new PixmapPreviewSelector( widget ); | 328 | m_pixmapSelector = new PixmapPreviewSelector( widget ); | ||
341 | layout->addWidget( m_pixmapSelector ); | 329 | formlayout->addRow( i18n( "Icon:" ), m_pixmapSelector ); | ||
342 | m_pixmapSelector->addItem( i18n( "Comment" ), QStringLiteral("Comment") ); | 330 | m_pixmapSelector->addItem( i18n( "Comment" ), QStringLiteral("Comment") ); | ||
343 | m_pixmapSelector->addItem( i18n( "Help" ), QStringLiteral("Help") ); | 331 | m_pixmapSelector->addItem( i18n( "Help" ), QStringLiteral("Help") ); | ||
344 | m_pixmapSelector->addItem( i18n( "Insert" ), QStringLiteral("Insert") ); | 332 | m_pixmapSelector->addItem( i18n( "Insert" ), QStringLiteral("Insert") ); | ||
345 | m_pixmapSelector->addItem( i18n( "Key" ), QStringLiteral("Key") ); | 333 | m_pixmapSelector->addItem( i18n( "Key" ), QStringLiteral("Key") ); | ||
346 | m_pixmapSelector->addItem( i18n( "New Paragraph" ), QStringLiteral("NewParagraph") ); | 334 | m_pixmapSelector->addItem( i18n( "New paragraph" ), QStringLiteral("NewParagraph") ); | ||
347 | m_pixmapSelector->addItem( i18n( "Note" ), QStringLiteral("Note") ); | 335 | m_pixmapSelector->addItem( i18n( "Note" ), QStringLiteral("Note") ); | ||
348 | m_pixmapSelector->addItem( i18n( "Paragraph" ), QStringLiteral("Paragraph") ); | 336 | m_pixmapSelector->addItem( i18n( "Paragraph" ), QStringLiteral("Paragraph") ); | ||
349 | m_pixmapSelector->setIcon( m_textAnn->textIcon() ); | 337 | m_pixmapSelector->setIcon( m_textAnn->textIcon() ); | ||
350 | connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); | 338 | connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); | ||
351 | } | 339 | } | ||
352 | 340 | | |||
353 | void TextAnnotationWidget::addFontRequester( QWidget * widget, QGridLayout * layout ) | 341 | void TextAnnotationWidget::addFontRequester( QWidget * widget, QFormLayout * formlayout ) | ||
354 | { | 342 | { | ||
355 | const int row = layout->rowCount(); | | |||
356 | QLabel * tmplabel = new QLabel( i18n( "Font:" ), widget ); | | |||
357 | layout->addWidget( tmplabel, row, 0 ); | | |||
358 | m_fontReq = new KFontRequester( widget ); | 343 | m_fontReq = new KFontRequester( widget ); | ||
359 | layout->addWidget( m_fontReq, row, 1 ); | 344 | formlayout->addRow( i18n( "Font:" ), m_fontReq ); | ||
360 | m_fontReq->setFont( m_textAnn->textFont() ); | 345 | m_fontReq->setFont( m_textAnn->textFont() ); | ||
361 | connect( m_fontReq, &KFontRequester::fontSelected, this, &AnnotationWidget::dataChanged ); | 346 | connect( m_fontReq, &KFontRequester::fontSelected, this, &AnnotationWidget::dataChanged ); | ||
362 | } | 347 | } | ||
363 | 348 | | |||
364 | void TextAnnotationWidget::addTextColorButton( QWidget * widget, QGridLayout * layout ) | 349 | void TextAnnotationWidget::addTextColorButton( QWidget * widget, QFormLayout * formlayout ) | ||
365 | { | 350 | { | ||
366 | const int row = layout->rowCount(); | | |||
367 | QLabel * tmplabel = new QLabel( i18n( "&Text Color:" ), widget ); | | |||
368 | layout->addWidget( tmplabel, row, 0, Qt::AlignRight ); | | |||
369 | m_textColorBn = new KColorButton( widget ); | 351 | m_textColorBn = new KColorButton( widget ); | ||
370 | m_textColorBn->setColor( m_textAnn->textColor() ); | 352 | m_textColorBn->setColor( m_textAnn->textColor() ); | ||
371 | tmplabel->setBuddy( m_textColorBn ); | 353 | formlayout->addRow( i18n( "Text &color:" ), m_textColorBn ); | ||
372 | layout->addWidget( m_textColorBn, row, 1 ); | | |||
373 | connect( m_textColorBn, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | 354 | connect( m_textColorBn, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | ||
374 | } | 355 | } | ||
375 | 356 | | |||
376 | void TextAnnotationWidget::addTextAlignComboBox( QWidget * widget, QGridLayout * layout ) | 357 | void TextAnnotationWidget::addTextAlignComboBox( QWidget * widget, QFormLayout * formlayout ) | ||
377 | { | 358 | { | ||
378 | const int row = layout->rowCount(); | 359 | | ||
379 | QLabel * tmplabel = new QLabel( i18n( "Align:" ), widget ); | | |||
380 | layout->addWidget( tmplabel, row, 0 ); | | |||
381 | m_textAlign = new KComboBox( widget ); | 360 | m_textAlign = new KComboBox( widget ); | ||
382 | layout->addWidget( m_textAlign, row, 1 ); | 361 | formlayout->addRow( i18n( "&Align:" ), m_textAlign ); | ||
383 | m_textAlign->addItem( i18n("Left") ); | 362 | m_textAlign->addItem( i18n("Left") ); | ||
384 | m_textAlign->addItem( i18n("Center") ); | 363 | m_textAlign->addItem( i18n("Center") ); | ||
385 | m_textAlign->addItem( i18n("Right") ); | 364 | m_textAlign->addItem( i18n("Right") ); | ||
386 | m_textAlign->setCurrentIndex( m_textAnn->inplaceAlignment() ); | 365 | m_textAlign->setCurrentIndex( m_textAnn->inplaceAlignment() ); | ||
387 | connect( m_textAlign, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dataChanged()) ); | 366 | connect( m_textAlign, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dataChanged()) ); | ||
388 | } | 367 | } | ||
389 | 368 | | |||
390 | void TextAnnotationWidget::addWidthSpinBox( QWidget * widget, QGridLayout * layout ) | 369 | void TextAnnotationWidget::addWidthSpinBox( QWidget * widget, QFormLayout * formlayout ) | ||
391 | { | 370 | { | ||
392 | const int row = layout->rowCount(); | | |||
393 | QLabel * tmplabel = new QLabel( i18n( "Border Width:" ), widget ); | | |||
394 | layout->addWidget( tmplabel, row, 0, Qt::AlignRight ); | | |||
395 | m_spinWidth = new QDoubleSpinBox( widget ); | 371 | m_spinWidth = new QDoubleSpinBox( widget ); | ||
396 | layout->addWidget( m_spinWidth, row, 1 ); | 372 | formlayout->addRow( i18n( "Border &width:" ), m_spinWidth ); | ||
397 | tmplabel->setBuddy( m_spinWidth ); | | |||
398 | m_spinWidth->setRange( 0, 100 ); | 373 | m_spinWidth->setRange( 0, 100 ); | ||
399 | m_spinWidth->setValue( m_textAnn->style().width() ); | 374 | m_spinWidth->setValue( m_textAnn->style().width() ); | ||
400 | m_spinWidth->setSingleStep( 0.1 ); | 375 | m_spinWidth->setSingleStep( 0.1 ); | ||
401 | connect( m_spinWidth, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | 376 | connect( m_spinWidth, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | ||
402 | } | 377 | } | ||
403 | 378 | | |||
404 | StampAnnotationWidget::StampAnnotationWidget( Okular::Annotation * ann ) | 379 | StampAnnotationWidget::StampAnnotationWidget( Okular::Annotation * ann ) | ||
405 | : AnnotationWidget( ann ), m_pixmapSelector( nullptr ) | 380 | : AnnotationWidget( ann ), m_pixmapSelector( nullptr ) | ||
406 | { | 381 | { | ||
407 | m_stampAnn = static_cast< Okular::StampAnnotation * >( ann ); | 382 | m_stampAnn = static_cast< Okular::StampAnnotation * >( ann ); | ||
408 | } | 383 | } | ||
409 | 384 | | |||
410 | QWidget * StampAnnotationWidget::createStyleWidget() | 385 | void StampAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
411 | { | 386 | { | ||
412 | QWidget * widget = new QWidget(); | 387 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | ||
413 | QVBoxLayout * lay = new QVBoxLayout( widget ); | 388 | | ||
414 | lay->setMargin( 0 ); | 389 | addOpacitySpinBox( widget, formlayout ); | ||
davidhurka: Capitalize symbol? | |||||
KDE HIG prescribe sentence style capitalization for labels in a form layout: https://hig.kde.org/style/writing/capitalization.html simgunz: KDE HIG prescribe sentence style capitalization for labels in a form layout: https://hig.kde. | |||||
415 | QGroupBox * gb = new QGroupBox( widget ); | 390 | addVerticalSpacer( formlayout ); | ||
416 | lay->addWidget( gb ); | 391 | | ||
417 | gb->setTitle( i18n( "Stamp Symbol" ) ); | 392 | m_pixmapSelector = new PixmapPreviewSelector( widget ); | ||
418 | QHBoxLayout * gblay = new QHBoxLayout( gb ); | 393 | formlayout->addRow( i18n( "Stamp symbol:" ), m_pixmapSelector ); | ||
419 | m_pixmapSelector = new PixmapPreviewSelector( gb ); | | |||
420 | gblay->addWidget( m_pixmapSelector ); | | |||
421 | m_pixmapSelector->setEditable( true ); | 394 | m_pixmapSelector->setEditable( true ); | ||
davidhurka: Why is this editable? Entering a path to an image does not work. | |||||
davidhurka: Read in the user documentatio that it theoretically works. | |||||
Sometimes works. :-) Try with a path to an icon. In any case I'll improve the Stamp tool soon, adding a 'select file' button. I have some code ready that I'll share soon. simgunz: Sometimes works. :-) Try with a path to an icon. In any case I'll improve the Stamp tool soon… | |||||
Once you do that, it will fix https://bugs.kde.org/show_bug.cgi?id=383652 :) ngraham: Once you do that, it will fix https://bugs.kde.org/show_bug.cgi?id=383652 :) | |||||
422 | 395 | | |||
423 | m_pixmapSelector->addItem( i18n( "Okular" ), QStringLiteral("okular") ); | 396 | m_pixmapSelector->addItem( i18n( "Okular" ), QStringLiteral("okular") ); | ||
424 | m_pixmapSelector->addItem( i18n( "Bookmark" ), QStringLiteral("bookmarks") ); | 397 | m_pixmapSelector->addItem( i18n( "Bookmark" ), QStringLiteral("bookmarks") ); | ||
425 | m_pixmapSelector->addItem( i18n( "KDE" ), QStringLiteral("kde") ); | 398 | m_pixmapSelector->addItem( i18n( "KDE" ), QStringLiteral("kde") ); | ||
426 | m_pixmapSelector->addItem( i18n( "Information" ), QStringLiteral("help-about") ); | 399 | m_pixmapSelector->addItem( i18n( "Information" ), QStringLiteral("help-about") ); | ||
427 | m_pixmapSelector->addItem( i18n( "Approved" ), QStringLiteral("Approved") ); | 400 | m_pixmapSelector->addItem( i18n( "Approved" ), QStringLiteral("Approved") ); | ||
428 | m_pixmapSelector->addItem( i18n( "As Is" ), QStringLiteral("AsIs") ); | 401 | m_pixmapSelector->addItem( i18n( "As Is" ), QStringLiteral("AsIs") ); | ||
429 | m_pixmapSelector->addItem( i18n( "Confidential" ), QStringLiteral("Confidential") ); | 402 | m_pixmapSelector->addItem( i18n( "Confidential" ), QStringLiteral("Confidential") ); | ||
430 | m_pixmapSelector->addItem( i18n( "Departmental" ), QStringLiteral("Departmental") ); | 403 | m_pixmapSelector->addItem( i18n( "Departmental" ), QStringLiteral("Departmental") ); | ||
431 | m_pixmapSelector->addItem( i18n( "Draft" ), QStringLiteral("Draft") ); | 404 | m_pixmapSelector->addItem( i18n( "Draft" ), QStringLiteral("Draft") ); | ||
432 | m_pixmapSelector->addItem( i18n( "Experimental" ), QStringLiteral("Experimental") ); | 405 | m_pixmapSelector->addItem( i18n( "Experimental" ), QStringLiteral("Experimental") ); | ||
433 | m_pixmapSelector->addItem( i18n( "Expired" ), QStringLiteral("Expired") ); | 406 | m_pixmapSelector->addItem( i18n( "Expired" ), QStringLiteral("Expired") ); | ||
434 | m_pixmapSelector->addItem( i18n( "Final" ), QStringLiteral("Final") ); | 407 | m_pixmapSelector->addItem( i18n( "Final" ), QStringLiteral("Final") ); | ||
435 | m_pixmapSelector->addItem( i18n( "For Comment" ), QStringLiteral("ForComment") ); | 408 | m_pixmapSelector->addItem( i18n( "For Comment" ), QStringLiteral("ForComment") ); | ||
436 | m_pixmapSelector->addItem( i18n( "For Public Release" ), QStringLiteral("ForPublicRelease") ); | 409 | m_pixmapSelector->addItem( i18n( "For Public Release" ), QStringLiteral("ForPublicRelease") ); | ||
437 | m_pixmapSelector->addItem( i18n( "Not Approved" ), QStringLiteral("NotApproved") ); | 410 | m_pixmapSelector->addItem( i18n( "Not Approved" ), QStringLiteral("NotApproved") ); | ||
438 | m_pixmapSelector->addItem( i18n( "Not For Public Release" ), QStringLiteral("NotForPublicRelease") ); | 411 | m_pixmapSelector->addItem( i18n( "Not For Public Release" ), QStringLiteral("NotForPublicRelease") ); | ||
439 | m_pixmapSelector->addItem( i18n( "Sold" ), QStringLiteral("Sold") ); | 412 | m_pixmapSelector->addItem( i18n( "Sold" ), QStringLiteral("Sold") ); | ||
440 | m_pixmapSelector->addItem( i18n( "Top Secret" ), QStringLiteral("TopSecret") ); | 413 | m_pixmapSelector->addItem( i18n( "Top Secret" ), QStringLiteral("TopSecret") ); | ||
441 | m_pixmapSelector->setIcon( m_stampAnn->stampIconName() ); | 414 | m_pixmapSelector->setIcon( m_stampAnn->stampIconName() ); | ||
442 | m_pixmapSelector->setPreviewSize( 64 ); | 415 | m_pixmapSelector->setPreviewSize( 64 ); | ||
443 | 416 | | |||
444 | connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); | 417 | connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); | ||
445 | | ||||
446 | return widget; | | |||
447 | } | 418 | } | ||
448 | 419 | | |||
449 | void StampAnnotationWidget::applyChanges() | 420 | void StampAnnotationWidget::applyChanges() | ||
450 | { | 421 | { | ||
451 | AnnotationWidget::applyChanges(); | 422 | AnnotationWidget::applyChanges(); | ||
452 | m_stampAnn->setStampIconName( m_pixmapSelector->icon() ); | 423 | m_stampAnn->setStampIconName( m_pixmapSelector->icon() ); | ||
453 | } | 424 | } | ||
454 | 425 | | |||
455 | 426 | | |||
456 | 427 | | |||
457 | LineAnnotationWidget::LineAnnotationWidget( Okular::Annotation * ann ) | 428 | LineAnnotationWidget::LineAnnotationWidget( Okular::Annotation * ann ) | ||
458 | : AnnotationWidget( ann ) | 429 | : AnnotationWidget( ann ) | ||
459 | { | 430 | { | ||
460 | m_lineAnn = static_cast< Okular::LineAnnotation * >( ann ); | 431 | m_lineAnn = static_cast< Okular::LineAnnotation * >( ann ); | ||
461 | if ( m_lineAnn->linePoints().count() == 2 ) | 432 | if ( m_lineAnn->linePoints().count() == 2 ) | ||
462 | m_lineType = 0; // line | 433 | m_lineType = 0; // line | ||
463 | else if ( m_lineAnn->lineClosed() ) | 434 | else if ( m_lineAnn->lineClosed() ) | ||
464 | m_lineType = 1; // polygon | 435 | m_lineType = 1; // polygon | ||
465 | else | 436 | else | ||
466 | m_lineType = 2; // polyline | 437 | m_lineType = 2; // polyline | ||
467 | } | 438 | } | ||
468 | 439 | | |||
469 | QWidget * LineAnnotationWidget::createStyleWidget() | 440 | void LineAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
470 | { | 441 | { | ||
471 | QWidget * widget = new QWidget(); | 442 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | ||
472 | QVBoxLayout * lay = new QVBoxLayout( widget ); | 443 | | ||
473 | lay->setMargin( 0 ); | 444 | addColorButton( widget, formlayout ); | ||
474 | if ( m_lineType == 0 ) | 445 | addOpacitySpinBox( widget, formlayout ); | ||
475 | { | | |||
476 | QGroupBox * gb = new QGroupBox( widget ); | | |||
477 | lay->addWidget( gb ); | | |||
478 | gb->setTitle( i18n( "Line Extensions" ) ); | | |||
479 | QGridLayout * gridlay = new QGridLayout( gb ); | | |||
480 | QLabel * tmplabel = new QLabel( i18n( "Leader Line Length:" ), gb ); | | |||
481 | gridlay->addWidget( tmplabel, 0, 0, Qt::AlignRight ); | | |||
482 | m_spinLL = new QDoubleSpinBox( gb ); | | |||
483 | gridlay->addWidget( m_spinLL, 0, 1 ); | | |||
484 | tmplabel->setBuddy( m_spinLL ); | | |||
485 | tmplabel = new QLabel( i18n( "Leader Line Extensions Length:" ), gb ); | | |||
486 | gridlay->addWidget( tmplabel, 1, 0, Qt::AlignRight ); | | |||
487 | m_spinLLE = new QDoubleSpinBox( gb ); | | |||
488 | gridlay->addWidget( m_spinLLE, 1, 1 ); | | |||
489 | tmplabel->setBuddy( m_spinLLE ); | | |||
490 | } | | |||
491 | | ||||
492 | QGroupBox * gb2 = new QGroupBox( widget ); | | |||
493 | lay->addWidget( gb2 ); | | |||
494 | gb2->setTitle( i18n( "Style" ) ); | | |||
495 | QGridLayout * gridlay2 = new QGridLayout( gb2 ); | | |||
496 | QLabel * tmplabel2 = new QLabel( i18n( "&Size:" ), gb2 ); | | |||
497 | gridlay2->addWidget( tmplabel2, 0, 0, Qt::AlignRight ); | | |||
498 | m_spinSize = new QDoubleSpinBox( gb2 ); | | |||
499 | gridlay2->addWidget( m_spinSize, 0, 1 ); | | |||
500 | tmplabel2->setBuddy( m_spinSize ); | | |||
501 | | ||||
502 | if ( m_lineType == 1 ) //Polygon | | |||
503 | { | | |||
504 | m_useColor = new QCheckBox( i18n( "Inner color:" ), gb2 ); | | |||
505 | gridlay2->addWidget( m_useColor, 1, 0 ); | | |||
506 | m_innerColor = new KColorButton( gb2 ); | | |||
507 | gridlay2->addWidget( m_innerColor, 1, 1 ); | | |||
508 | m_innerColor->setColor( m_lineAnn->lineInnerColor() ); | | |||
509 | if ( m_lineAnn->lineInnerColor().isValid() ) | | |||
510 | { | | |||
511 | m_useColor->setChecked( true ); | | |||
512 | } | | |||
513 | else | | |||
514 | { | | |||
515 | m_innerColor->setEnabled( false ); | | |||
516 | } | | |||
517 | } | | |||
518 | 446 | | |||
519 | if ( m_lineType == 0 ) //Straight line | 447 | m_spinSize = new QDoubleSpinBox( widget ); | ||
448 | m_spinSize->setRange( 1, 100 ); | ||||
449 | m_spinSize->setValue( m_lineAnn->style().width() ); | ||||
450 | | ||||
451 | connect( m_spinSize, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &LineAnnotationWidget::dataChanged ); | ||||
452 | | ||||
453 | // Straight line | ||||
454 | if ( m_lineType == 0 ) | ||||
520 | { | 455 | { | ||
521 | m_spinLL->setRange( -500, 500 ); | 456 | addVerticalSpacer( formlayout ); | ||
522 | m_spinLL->setValue( m_lineAnn->lineLeadingForwardPoint() ); | 457 | formlayout->addRow( i18n( "&Width:" ), m_spinSize ); | ||
523 | m_spinLLE->setRange( 0, 500 ); | | |||
524 | m_spinLLE->setValue( m_lineAnn->lineLeadingBackwardPoint() ); | | |||
525 | 458 | | |||
526 | //Line Term Styles | 459 | //Line Term Styles | ||
527 | QLabel * tmplabel3 = new QLabel( i18n( "Line Start:" ), widget ); | 460 | addVerticalSpacer( formlayout ); | ||
528 | QLabel * tmplabel4 = new QLabel( i18n( "Line End:" ), widget ); | | |||
529 | gridlay2->addWidget( tmplabel3, 1, 0, Qt::AlignRight ); | | |||
530 | gridlay2->addWidget( tmplabel4, 2, 0, Qt::AlignRight ); | | |||
531 | m_startStyleCombo = new QComboBox( widget ); | 461 | m_startStyleCombo = new QComboBox( widget ); | ||
462 | formlayout->addRow( i18n( "Line start:" ), m_startStyleCombo); | ||||
532 | m_endStyleCombo = new QComboBox( widget ); | 463 | m_endStyleCombo = new QComboBox( widget ); | ||
533 | tmplabel3->setBuddy( m_startStyleCombo ); | 464 | formlayout->addRow( i18n( "Line end:" ), m_endStyleCombo); | ||
534 | tmplabel4->setBuddy( m_endStyleCombo ); | 465 | //FIXME: Where does the tooltip goes?? | ||
you're going to have conflicts, AFAICS this "only for PDF documents" is gone. aacid: you're going to have conflicts, AFAICS this "only for PDF documents" is gone. | |||||
535 | gridlay2->addWidget( m_startStyleCombo, 1, 1, Qt::AlignLeft ); | | |||
536 | gridlay2->addWidget( m_endStyleCombo, 2, 1, Qt::AlignLeft ); | | |||
537 | 466 | | |||
538 | const QList<QPair<Okular::LineAnnotation::TermStyle, QString>> termStyles | 467 | const QList<QPair<Okular::LineAnnotation::TermStyle, QString>> termStyles | ||
539 | { | 468 | { | ||
540 | { Okular::LineAnnotation::Square, i18n( "Square" ) }, | 469 | { Okular::LineAnnotation::Square, i18n( "Square" ) }, | ||
541 | { Okular::LineAnnotation::Circle, i18n( "Circle" ) }, | 470 | { Okular::LineAnnotation::Circle, i18n( "Circle" ) }, | ||
542 | { Okular::LineAnnotation::Diamond, i18n( "Diamond" ) }, | 471 | { Okular::LineAnnotation::Diamond, i18n( "Diamond" ) }, | ||
543 | { Okular::LineAnnotation::OpenArrow, i18n( "Open Arrow" ) }, | 472 | { Okular::LineAnnotation::OpenArrow, i18n( "Open Arrow" ) }, | ||
544 | { Okular::LineAnnotation::ClosedArrow, i18n( "Closed Arrow" ) }, | 473 | { Okular::LineAnnotation::ClosedArrow, i18n( "Closed Arrow" ) }, | ||
545 | { Okular::LineAnnotation::None, i18n( "None" ) }, | 474 | { Okular::LineAnnotation::None, i18n( "None" ) }, | ||
546 | { Okular::LineAnnotation::Butt, i18n( "Butt" ) }, | 475 | { Okular::LineAnnotation::Butt, i18n( "Butt" ) }, | ||
547 | { Okular::LineAnnotation::ROpenArrow, i18n( "Right Open Arrow" ) }, | 476 | { Okular::LineAnnotation::ROpenArrow, i18n( "Right Open Arrow" ) }, | ||
548 | { Okular::LineAnnotation::RClosedArrow, i18n( "Right Closed Arrow" ) }, | 477 | { Okular::LineAnnotation::RClosedArrow, i18n( "Right Closed Arrow" ) }, | ||
549 | { Okular::LineAnnotation::Slash, i18n( "Slash" ) } | 478 | { Okular::LineAnnotation::Slash, i18n( "Slash" ) } | ||
550 | }; | 479 | }; | ||
551 | for ( const auto &item: termStyles ) | 480 | for ( const auto &item: termStyles ) | ||
552 | { | 481 | { | ||
553 | const QIcon icon = endStyleIcon( item.first, QGuiApplication::palette().color( QPalette::WindowText ) ); | 482 | const QIcon icon = endStyleIcon( item.first, QGuiApplication::palette().color( QPalette::WindowText ) ); | ||
554 | m_startStyleCombo->addItem( icon, item.second ); | 483 | m_startStyleCombo->addItem( icon, item.second ); | ||
555 | m_endStyleCombo->addItem( icon, item.second ); | 484 | m_endStyleCombo->addItem( icon, item.second ); | ||
556 | } | 485 | } | ||
557 | 486 | | |||
558 | m_startStyleCombo->setCurrentIndex( m_lineAnn->lineStartStyle() ); | 487 | m_startStyleCombo->setCurrentIndex( m_lineAnn->lineStartStyle() ); | ||
559 | m_endStyleCombo->setCurrentIndex( m_lineAnn->lineEndStyle() ); | 488 | m_endStyleCombo->setCurrentIndex( m_lineAnn->lineEndStyle() ); | ||
560 | connect( m_startStyleCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LineAnnotationWidget::dataChanged ); | | |||
561 | connect( m_endStyleCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LineAnnotationWidget::dataChanged ); | | |||
562 | 489 | | |||
563 | } | 490 | //Leaders lengths | ||
491 | addVerticalSpacer( formlayout ); | ||||
492 | m_spinLL = new QDoubleSpinBox( widget ); | ||||
493 | formlayout->addRow( i18n( "Leader line length:" ), m_spinLL ); | ||||
494 | m_spinLLE = new QDoubleSpinBox( widget ); | ||||
495 | formlayout->addRow( i18n( "Leader line extensions length:" ), m_spinLLE ); | ||||
564 | 496 | | |||
565 | m_spinSize->setRange( 1, 100 ); | 497 | m_spinLL->setRange( -500, 500 ); | ||
566 | m_spinSize->setValue( m_lineAnn->style().width() ); | 498 | m_spinLL->setValue( m_lineAnn->lineLeadingForwardPoint() ); | ||
499 | m_spinLLE->setRange( 0, 500 ); | ||||
500 | m_spinLLE->setValue( m_lineAnn->lineLeadingBackwardPoint() ); | ||||
567 | 501 | | |||
568 | if ( m_lineType == 0 ) | 502 | connect( m_startStyleCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LineAnnotationWidget::dataChanged ); | ||
569 | { | 503 | connect( m_endStyleCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LineAnnotationWidget::dataChanged ); | ||
570 | connect( m_spinLL, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | 504 | connect( m_spinLL, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | ||
571 | connect( m_spinLLE, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | 505 | connect( m_spinLLE, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | ||
572 | } | 506 | } | ||
573 | else if ( m_lineType == 1 ) | 507 | else if ( m_lineType == 1 ) // Polygon | ||
574 | { | 508 | { | ||
509 | QHBoxLayout * colorlay = new QHBoxLayout(); | ||||
510 | m_useColor = new QCheckBox( i18n( "Enabled" ), widget ); | ||||
511 | colorlay->addWidget( m_useColor ); | ||||
512 | m_innerColor = new KColorButton( widget ); | ||||
513 | colorlay->addWidget( m_innerColor); | ||||
514 | formlayout->addRow( i18n( "Shape fill:" ), colorlay ); | ||||
515 | | ||||
516 | m_innerColor->setColor( m_lineAnn->lineInnerColor() ); | ||||
517 | if ( m_lineAnn->lineInnerColor().isValid() ) | ||||
518 | { | ||||
519 | m_useColor->setChecked( true ); | ||||
520 | } | ||||
521 | else | ||||
522 | { | ||||
523 | m_innerColor->setEnabled( false ); | ||||
524 | } | ||||
525 | | ||||
526 | addVerticalSpacer( formlayout ); | ||||
527 | formlayout->addRow( i18n( "&Width:" ), m_spinSize ); | ||||
528 | | ||||
575 | connect( m_innerColor, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | 529 | connect( m_innerColor, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | ||
576 | connect( m_useColor, &QAbstractButton::toggled, this, &AnnotationWidget::dataChanged ); | 530 | connect( m_useColor, &QAbstractButton::toggled, this, &AnnotationWidget::dataChanged ); | ||
577 | connect( m_useColor, &QCheckBox::toggled, m_innerColor, &KColorButton::setEnabled ); | 531 | connect( m_useColor, &QCheckBox::toggled, m_innerColor, &KColorButton::setEnabled ); | ||
578 | } | 532 | } | ||
579 | connect( m_spinSize, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &LineAnnotationWidget::dataChanged ); | | |||
580 | | ||||
581 | return widget; | | |||
582 | } | 533 | } | ||
583 | 534 | | |||
584 | void LineAnnotationWidget::applyChanges() | 535 | void LineAnnotationWidget::applyChanges() | ||
585 | { | 536 | { | ||
586 | AnnotationWidget::applyChanges(); | 537 | AnnotationWidget::applyChanges(); | ||
587 | if ( m_lineType == 0 ) | 538 | if ( m_lineType == 0 ) | ||
588 | { | 539 | { | ||
589 | Q_ASSERT(m_spinLL && m_spinLLE && m_startStyleCombo && m_endStyleCombo); | 540 | Q_ASSERT(m_spinLL && m_spinLLE && m_startStyleCombo && m_endStyleCombo); | ||
Show All 38 Lines | |||||
628 | 579 | | |||
629 | 580 | | |||
630 | InkAnnotationWidget::InkAnnotationWidget( Okular::Annotation * ann ) | 581 | InkAnnotationWidget::InkAnnotationWidget( Okular::Annotation * ann ) | ||
631 | : AnnotationWidget( ann ) | 582 | : AnnotationWidget( ann ) | ||
632 | { | 583 | { | ||
633 | m_inkAnn = static_cast< Okular::InkAnnotation * >( ann ); | 584 | m_inkAnn = static_cast< Okular::InkAnnotation * >( ann ); | ||
634 | } | 585 | } | ||
635 | 586 | | |||
636 | QWidget * InkAnnotationWidget::createStyleWidget() | 587 | void InkAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
637 | { | 588 | { | ||
638 | QWidget * widget = new QWidget(); | 589 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | ||
639 | QVBoxLayout * lay = new QVBoxLayout( widget ); | 590 | | ||
640 | lay->setMargin( 0 ); | 591 | addColorButton( widget, formlayout ); | ||
592 | addOpacitySpinBox( widget, formlayout ); | ||||
593 | | ||||
594 | addVerticalSpacer( formlayout ); | ||||
641 | 595 | | |||
642 | QGroupBox * gb2 = new QGroupBox( widget ); | 596 | m_spinSize = new QDoubleSpinBox( widget ); | ||
643 | lay->addWidget( gb2 ); | 597 | formlayout->addRow( i18n( "&Width:" ), m_spinSize ); | ||
644 | gb2->setTitle( i18n( "Style" ) ); | | |||
645 | QGridLayout * gridlay2 = new QGridLayout( gb2 ); | | |||
646 | QLabel * tmplabel2 = new QLabel( i18n( "&Size:" ), gb2 ); | | |||
647 | gridlay2->addWidget( tmplabel2, 0, 0, Qt::AlignRight ); | | |||
648 | m_spinSize = new QDoubleSpinBox( gb2 ); | | |||
649 | gridlay2->addWidget( m_spinSize, 0, 1 ); | | |||
650 | tmplabel2->setBuddy( m_spinSize ); | | |||
651 | 598 | | |||
652 | m_spinSize->setRange( 1, 100 ); | 599 | m_spinSize->setRange( 1, 100 ); | ||
653 | m_spinSize->setValue( m_inkAnn->style().width() ); | 600 | m_spinSize->setValue( m_inkAnn->style().width() ); | ||
654 | 601 | | |||
655 | connect( m_spinSize, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | 602 | connect( m_spinSize, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | ||
656 | | ||||
657 | return widget; | | |||
658 | } | 603 | } | ||
659 | 604 | | |||
660 | void InkAnnotationWidget::applyChanges() | 605 | void InkAnnotationWidget::applyChanges() | ||
661 | { | 606 | { | ||
662 | AnnotationWidget::applyChanges(); | 607 | AnnotationWidget::applyChanges(); | ||
663 | m_inkAnn->style().setWidth( m_spinSize->value() ); | 608 | m_inkAnn->style().setWidth( m_spinSize->value() ); | ||
664 | } | 609 | } | ||
665 | 610 | | |||
666 | 611 | | |||
667 | 612 | | |||
668 | HighlightAnnotationWidget::HighlightAnnotationWidget( Okular::Annotation * ann ) | 613 | HighlightAnnotationWidget::HighlightAnnotationWidget( Okular::Annotation * ann ) | ||
669 | : AnnotationWidget( ann ) | 614 | : AnnotationWidget( ann ) | ||
670 | { | 615 | { | ||
671 | m_hlAnn = static_cast< Okular::HighlightAnnotation * >( ann ); | 616 | m_hlAnn = static_cast< Okular::HighlightAnnotation * >( ann ); | ||
672 | } | 617 | } | ||
673 | 618 | | |||
674 | QWidget * HighlightAnnotationWidget::createStyleWidget() | 619 | void HighlightAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
675 | { | 620 | { | ||
676 | QWidget * widget = new QWidget(); | 621 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | ||
677 | QVBoxLayout * lay = new QVBoxLayout( widget ); | | |||
678 | lay->setMargin( 0 ); | | |||
679 | QHBoxLayout * typelay = new QHBoxLayout(); | | |||
680 | lay->addLayout( typelay ); | | |||
681 | QLabel * tmplabel = new QLabel( i18n( "Type:" ), widget ); | | |||
682 | typelay->addWidget( tmplabel, 0, Qt::AlignRight ); | | |||
683 | m_typeCombo = new KComboBox( widget ); | | |||
684 | tmplabel->setBuddy( m_typeCombo ); | | |||
685 | typelay->addWidget( m_typeCombo ); | | |||
686 | 622 | | |||
623 | m_typeCombo = new KComboBox( widget ); | ||||
624 | formlayout->addRow( i18n( "Type:" ), m_typeCombo ); | ||||
687 | m_typeCombo->addItem( i18n( "Highlight" ) ); | 625 | m_typeCombo->addItem( i18n( "Highlight" ) ); | ||
688 | m_typeCombo->addItem( i18n( "Squiggle" ) ); | 626 | m_typeCombo->addItem( i18n( "Squiggle" ) ); | ||
689 | m_typeCombo->addItem( i18n( "Underline" ) ); | 627 | m_typeCombo->addItem( i18n( "Underline" ) ); | ||
690 | m_typeCombo->addItem( i18n( "Strike out" ) ); | 628 | m_typeCombo->addItem( i18n( "Strike out" ) ); | ||
691 | m_typeCombo->setCurrentIndex( m_hlAnn->highlightType() ); | 629 | m_typeCombo->setCurrentIndex( m_hlAnn->highlightType() ); | ||
692 | 630 | | |||
693 | connect( m_typeCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dataChanged()) ); | 631 | addVerticalSpacer( formlayout ); | ||
632 | addColorButton( widget, formlayout ); | ||||
633 | addOpacitySpinBox( widget, formlayout ); | ||||
694 | 634 | | |||
695 | return widget; | 635 | connect( m_typeCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dataChanged()) ); | ||
696 | } | 636 | } | ||
697 | 637 | | |||
698 | void HighlightAnnotationWidget::applyChanges() | 638 | void HighlightAnnotationWidget::applyChanges() | ||
699 | { | 639 | { | ||
700 | AnnotationWidget::applyChanges(); | 640 | AnnotationWidget::applyChanges(); | ||
701 | m_hlAnn->setHighlightType( (Okular::HighlightAnnotation::HighlightType)m_typeCombo->currentIndex() ); | 641 | m_hlAnn->setHighlightType( (Okular::HighlightAnnotation::HighlightType)m_typeCombo->currentIndex() ); | ||
702 | } | 642 | } | ||
703 | 643 | | |||
704 | 644 | | |||
705 | 645 | | |||
706 | GeomAnnotationWidget::GeomAnnotationWidget( Okular::Annotation * ann ) | 646 | GeomAnnotationWidget::GeomAnnotationWidget( Okular::Annotation * ann ) | ||
707 | : AnnotationWidget( ann ) | 647 | : AnnotationWidget( ann ) | ||
708 | { | 648 | { | ||
709 | m_geomAnn = static_cast< Okular::GeomAnnotation * >( ann ); | 649 | m_geomAnn = static_cast< Okular::GeomAnnotation * >( ann ); | ||
710 | } | 650 | } | ||
711 | 651 | | |||
712 | QWidget * GeomAnnotationWidget::createStyleWidget() | 652 | void GeomAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
713 | { | 653 | { | ||
714 | QWidget * widget = new QWidget(); | 654 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | ||
715 | QGridLayout * lay = new QGridLayout( widget ); | 655 | | ||
716 | lay->setMargin( 0 ); | | |||
717 | QLabel * tmplabel = new QLabel( i18n( "Type:" ), widget ); | | |||
718 | lay->addWidget( tmplabel, 0, 0, Qt::AlignRight ); | | |||
719 | m_typeCombo = new KComboBox( widget ); | 656 | m_typeCombo = new KComboBox( widget ); | ||
720 | tmplabel->setBuddy( m_typeCombo ); | 657 | formlayout->addRow( i18n( "Type:" ), m_typeCombo ); | ||
721 | lay->addWidget( m_typeCombo, 0, 1 ); | 658 | addVerticalSpacer( formlayout ); | ||
722 | m_useColor = new QCheckBox( i18n( "Inner color:" ), widget ); | 659 | addColorButton( widget, formlayout ); | ||
723 | lay->addWidget( m_useColor, 1, 0 ); | 660 | addOpacitySpinBox( widget, formlayout ); | ||
661 | QHBoxLayout * colorlay = new QHBoxLayout(); | ||||
662 | m_useColor = new QCheckBox( i18n( "Enabled" ), widget ); | ||||
663 | colorlay->addWidget(m_useColor); | ||||
724 | m_innerColor = new KColorButton( widget ); | 664 | m_innerColor = new KColorButton( widget ); | ||
725 | lay->addWidget( m_innerColor, 1, 1 ); | 665 | colorlay->addWidget( m_innerColor); | ||
726 | tmplabel = new QLabel( i18n( "&Size:" ), widget ); | 666 | formlayout->addRow( i18n( "Shape fill:" ), colorlay ); | ||
727 | lay->addWidget( tmplabel, 2, 0, Qt::AlignRight ); | 667 | addVerticalSpacer( formlayout ); | ||
728 | m_spinSize = new QDoubleSpinBox( widget ); | 668 | m_spinSize = new QDoubleSpinBox( widget ); | ||
729 | lay->addWidget( m_spinSize, 2, 1 ); | 669 | formlayout->addRow( i18n( "&Width:" ), m_spinSize ); | ||
730 | tmplabel->setBuddy( m_spinSize ); | | |||
731 | 670 | | |||
732 | m_typeCombo->addItem( i18n( "Rectangle" ) ); | 671 | m_typeCombo->addItem( i18n( "Rectangle" ) ); | ||
733 | m_typeCombo->addItem( i18n( "Ellipse" ) ); | 672 | m_typeCombo->addItem( i18n( "Ellipse" ) ); | ||
734 | m_typeCombo->setCurrentIndex( m_geomAnn->geometricalType() ); | 673 | m_typeCombo->setCurrentIndex( m_geomAnn->geometricalType() ); | ||
735 | m_innerColor->setColor( m_geomAnn->geometricalInnerColor() ); | 674 | m_innerColor->setColor( m_geomAnn->geometricalInnerColor() ); | ||
736 | if ( m_geomAnn->geometricalInnerColor().isValid() ) | 675 | if ( m_geomAnn->geometricalInnerColor().isValid() ) | ||
737 | { | 676 | { | ||
738 | m_useColor->setChecked( true ); | 677 | m_useColor->setChecked( true ); | ||
739 | } | 678 | } | ||
740 | else | 679 | else | ||
741 | { | 680 | { | ||
742 | m_innerColor->setEnabled( false ); | 681 | m_innerColor->setEnabled( false ); | ||
743 | } | 682 | } | ||
744 | m_spinSize->setRange( 0, 100 ); | 683 | m_spinSize->setRange( 0, 100 ); | ||
745 | m_spinSize->setValue( m_geomAnn->style().width() ); | 684 | m_spinSize->setValue( m_geomAnn->style().width() ); | ||
746 | 685 | | |||
747 | connect( m_typeCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dataChanged()) ); | 686 | connect( m_typeCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dataChanged()) ); | ||
748 | connect( m_innerColor, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | 687 | connect( m_innerColor, &KColorButton::changed, this, &AnnotationWidget::dataChanged ); | ||
749 | connect( m_useColor, &QAbstractButton::toggled, this, &AnnotationWidget::dataChanged ); | 688 | connect( m_useColor, &QAbstractButton::toggled, this, &AnnotationWidget::dataChanged ); | ||
750 | connect(m_useColor, &QCheckBox::toggled, m_innerColor, &KColorButton::setEnabled); | 689 | connect(m_useColor, &QCheckBox::toggled, m_innerColor, &KColorButton::setEnabled); | ||
751 | connect( m_spinSize, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | 690 | connect( m_spinSize, SIGNAL(valueChanged(double)), this, SIGNAL(dataChanged()) ); | ||
752 | | ||||
753 | return widget; | | |||
754 | } | 691 | } | ||
755 | 692 | | |||
756 | void GeomAnnotationWidget::applyChanges() | 693 | void GeomAnnotationWidget::applyChanges() | ||
757 | { | 694 | { | ||
758 | AnnotationWidget::applyChanges(); | 695 | AnnotationWidget::applyChanges(); | ||
759 | m_geomAnn->setGeometricalType( (Okular::GeomAnnotation::GeomType)m_typeCombo->currentIndex() ); | 696 | m_geomAnn->setGeometricalType( (Okular::GeomAnnotation::GeomType)m_typeCombo->currentIndex() ); | ||
760 | if ( !m_useColor->isChecked() ) | 697 | if ( !m_useColor->isChecked() ) | ||
761 | { | 698 | { | ||
Show All 9 Lines | |||||
771 | 708 | | |||
772 | 709 | | |||
773 | FileAttachmentAnnotationWidget::FileAttachmentAnnotationWidget( Okular::Annotation * ann ) | 710 | FileAttachmentAnnotationWidget::FileAttachmentAnnotationWidget( Okular::Annotation * ann ) | ||
774 | : AnnotationWidget( ann ), m_pixmapSelector( nullptr ) | 711 | : AnnotationWidget( ann ), m_pixmapSelector( nullptr ) | ||
775 | { | 712 | { | ||
776 | m_attachAnn = static_cast< Okular::FileAttachmentAnnotation * >( ann ); | 713 | m_attachAnn = static_cast< Okular::FileAttachmentAnnotation * >( ann ); | ||
777 | } | 714 | } | ||
778 | 715 | | |||
779 | QWidget * FileAttachmentAnnotationWidget::createStyleWidget() | 716 | void FileAttachmentAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
780 | { | 717 | { | ||
781 | QWidget * widget = new QWidget(); | 718 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | ||
782 | QVBoxLayout * lay = new QVBoxLayout( widget ); | 719 | | ||
783 | lay->setMargin( 0 ); | 720 | addOpacitySpinBox( widget, formlayout ); | ||
784 | QGroupBox * gb = new QGroupBox( widget ); | 721 | | ||
785 | lay->addWidget( gb ); | 722 | m_pixmapSelector = new PixmapPreviewSelector( widget ); | ||
786 | gb->setTitle( i18n( "File Attachment Symbol" ) ); | 723 | formlayout->addRow( i18n( "File attachment symbol:" ), m_pixmapSelector ); | ||
787 | QHBoxLayout * gblay = new QHBoxLayout( gb ); | | |||
788 | m_pixmapSelector = new PixmapPreviewSelector( gb ); | | |||
789 | gblay->addWidget( m_pixmapSelector ); | | |||
790 | m_pixmapSelector->setEditable( true ); | 724 | m_pixmapSelector->setEditable( true ); | ||
791 | 725 | | |||
792 | m_pixmapSelector->addItem( i18nc( "Symbol for file attachment annotations", "Graph" ), QStringLiteral("graph") ); | 726 | m_pixmapSelector->addItem( i18nc( "Symbol for file attachment annotations", "Graph" ), QStringLiteral("graph") ); | ||
793 | m_pixmapSelector->addItem( i18nc( "Symbol for file attachment annotations", "Push Pin" ), QStringLiteral("pushpin") ); | 727 | m_pixmapSelector->addItem( i18nc( "Symbol for file attachment annotations", "Push Pin" ), QStringLiteral("pushpin") ); | ||
794 | m_pixmapSelector->addItem( i18nc( "Symbol for file attachment annotations", "Paperclip" ), QStringLiteral("paperclip") ); | 728 | m_pixmapSelector->addItem( i18nc( "Symbol for file attachment annotations", "Paperclip" ), QStringLiteral("paperclip") ); | ||
795 | m_pixmapSelector->addItem( i18nc( "Symbol for file attachment annotations", "Tag" ), QStringLiteral("tag") ); | 729 | m_pixmapSelector->addItem( i18nc( "Symbol for file attachment annotations", "Tag" ), QStringLiteral("tag") ); | ||
796 | m_pixmapSelector->setIcon( m_attachAnn->fileIconName() ); | 730 | m_pixmapSelector->setIcon( m_attachAnn->fileIconName() ); | ||
797 | 731 | | |||
798 | connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); | 732 | connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); | ||
799 | | ||||
800 | return widget; | | |||
801 | } | 733 | } | ||
802 | 734 | | |||
803 | QWidget * FileAttachmentAnnotationWidget::createExtraWidget() | 735 | QWidget * FileAttachmentAnnotationWidget::createExtraWidget() | ||
804 | { | 736 | { | ||
805 | QWidget * widget = new QWidget(); | 737 | QWidget * widget = new QWidget(); | ||
806 | widget->setWindowTitle( i18nc( "'File' as normal file, that can be opened, saved, etc..", "File" ) ); | 738 | widget->setWindowTitle( i18nc( "'File' as normal file, that can be opened, saved, etc..", "File" ) ); | ||
807 | 739 | | |||
808 | Okular::EmbeddedFile *ef = m_attachAnn->embeddedFile(); | 740 | Okular::EmbeddedFile *ef = m_attachAnn->embeddedFile(); | ||
809 | const int size = ef->size(); | 741 | const int size = ef->size(); | ||
810 | const QString sizeString = size <= 0 ? i18nc( "Not available size", "N/A" ) : KFormat().formatByteSize( size ); | 742 | const QString sizeString = size <= 0 ? i18nc( "Not available size", "N/A" ) : KFormat().formatByteSize( size ); | ||
811 | const QString descString = ef->description().isEmpty() ? i18n( "No description available." ) : ef->description(); | 743 | const QString descString = ef->description().isEmpty() ? i18n( "No description available." ) : ef->description(); | ||
812 | 744 | | |||
813 | QGridLayout * lay = new QGridLayout( widget ); | 745 | QHBoxLayout * mainLay = new QHBoxLayout( widget ); | ||
814 | lay->setMargin( 0 ); | 746 | QFormLayout * lay = new QFormLayout(); | ||
815 | QLabel * tmplabel = new QLabel( i18n( "Name: %1", ef->name() ), widget ); | 747 | mainLay->addLayout( lay ); | ||
748 | | ||||
749 | QLabel * tmplabel = new QLabel( ef->name() , widget ); | ||||
816 | tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse ); | 750 | tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse ); | ||
817 | lay->addWidget( tmplabel, 0, 0 ); | 751 | lay->addRow( i18n( "Name:" ), tmplabel ); | ||
818 | 752 | | |||
819 | tmplabel = new QLabel( i18n( "Size: %1", sizeString ), widget ); | 753 | tmplabel = new QLabel( sizeString, widget ); | ||
820 | tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse ); | 754 | tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse ); | ||
821 | lay->addWidget( tmplabel, 1, 0 ); | 755 | lay->addRow( i18n( "&Width:" ), tmplabel ); | ||
822 | 756 | | |||
823 | tmplabel = new QLabel( i18n( "Description:" ), widget ); | | |||
824 | lay->addWidget( tmplabel, 2, 0 ); | | |||
825 | tmplabel = new QLabel( widget ); | 757 | tmplabel = new QLabel( widget ); | ||
826 | tmplabel->setTextFormat( Qt::PlainText ); | 758 | tmplabel->setTextFormat( Qt::PlainText ); | ||
827 | tmplabel->setWordWrap( true ); | 759 | tmplabel->setWordWrap( true ); | ||
828 | tmplabel->setText( descString ); | 760 | tmplabel->setText( descString ); | ||
829 | tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse ); | 761 | tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse ); | ||
830 | lay->addWidget( tmplabel, 3, 0, 1, 2 ); | 762 | lay->addRow( i18n( "Description:" ), tmplabel ); | ||
831 | 763 | | |||
832 | QMimeDatabase db; | 764 | QMimeDatabase db; | ||
833 | QMimeType mime = db.mimeTypeForFile( ef->name(), QMimeDatabase::MatchExtension); | 765 | QMimeType mime = db.mimeTypeForFile( ef->name(), QMimeDatabase::MatchExtension); | ||
834 | if ( mime.isValid() ) | 766 | if ( mime.isValid() ) | ||
835 | { | 767 | { | ||
836 | tmplabel = new QLabel( widget ); | 768 | tmplabel = new QLabel( widget ); | ||
837 | tmplabel->setPixmap( QIcon::fromTheme( mime.iconName() ).pixmap( FILEATTACH_ICONSIZE, FILEATTACH_ICONSIZE ) ); | 769 | tmplabel->setPixmap( QIcon::fromTheme( mime.iconName() ).pixmap( FILEATTACH_ICONSIZE, FILEATTACH_ICONSIZE ) ); | ||
838 | tmplabel->setFixedSize( FILEATTACH_ICONSIZE, FILEATTACH_ICONSIZE ); | 770 | tmplabel->setFixedSize( FILEATTACH_ICONSIZE, FILEATTACH_ICONSIZE ); | ||
839 | lay->addWidget( tmplabel, 0, 1, 3, 1, Qt::AlignTop ); | 771 | QVBoxLayout * tmpLayout = new QVBoxLayout( widget ); | ||
772 | tmpLayout->setAlignment( Qt::AlignTop ); | ||||
773 | mainLay->addLayout( tmpLayout ); | ||||
774 | tmpLayout->addWidget( tmplabel ); | ||||
840 | } | 775 | } | ||
841 | 776 | | |||
842 | lay->addItem( new QSpacerItem( 5, 5, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ), 4, 0 ); | | |||
843 | | ||||
844 | return widget; | 777 | return widget; | ||
845 | } | 778 | } | ||
846 | 779 | | |||
847 | void FileAttachmentAnnotationWidget::applyChanges() | 780 | void FileAttachmentAnnotationWidget::applyChanges() | ||
848 | { | 781 | { | ||
849 | AnnotationWidget::applyChanges(); | 782 | AnnotationWidget::applyChanges(); | ||
850 | m_attachAnn->setFileIconName( m_pixmapSelector->icon() ); | 783 | m_attachAnn->setFileIconName( m_pixmapSelector->icon() ); | ||
851 | } | 784 | } | ||
Show All 22 Lines | |||||
874 | } | 807 | } | ||
875 | 808 | | |||
876 | CaretAnnotationWidget::CaretAnnotationWidget( Okular::Annotation * ann ) | 809 | CaretAnnotationWidget::CaretAnnotationWidget( Okular::Annotation * ann ) | ||
877 | : AnnotationWidget( ann ), m_pixmapSelector( nullptr ) | 810 | : AnnotationWidget( ann ), m_pixmapSelector( nullptr ) | ||
878 | { | 811 | { | ||
879 | m_caretAnn = static_cast< Okular::CaretAnnotation * >( ann ); | 812 | m_caretAnn = static_cast< Okular::CaretAnnotation * >( ann ); | ||
880 | } | 813 | } | ||
881 | 814 | | |||
882 | QWidget * CaretAnnotationWidget::createStyleWidget() | 815 | void CaretAnnotationWidget::createStyleWidget( QFormLayout * formlayout ) | ||
883 | { | 816 | { | ||
884 | QWidget * widget = new QWidget(); | 817 | QWidget * widget = qobject_cast<QWidget *>( formlayout->parent() ); | ||
885 | QVBoxLayout * lay = new QVBoxLayout( widget ); | 818 | | ||
shubham: Why not qobject_cast? | |||||
886 | lay->setMargin( 0 ); | 819 | addColorButton( widget, formlayout ); | ||
887 | QGroupBox * gb = new QGroupBox( widget ); | 820 | addOpacitySpinBox( widget, formlayout ); | ||
888 | lay->addWidget( gb ); | 821 | | ||
889 | gb->setTitle( i18n( "Caret Symbol" ) ); | 822 | m_pixmapSelector = new PixmapPreviewSelector( widget ); | ||
890 | QHBoxLayout * gblay = new QHBoxLayout( gb ); | 823 | formlayout->addRow( i18n( "Caret symbol:" ), m_pixmapSelector ); | ||
891 | m_pixmapSelector = new PixmapPreviewSelector( gb ); | | |||
892 | gblay->addWidget( m_pixmapSelector ); | | |||
893 | 824 | | |||
894 | m_pixmapSelector->addItem( i18nc( "Symbol for caret annotations", "None" ), QStringLiteral("caret-none") ); | 825 | m_pixmapSelector->addItem( i18nc( "Symbol for caret annotations", "None" ), QStringLiteral("caret-none") ); | ||
895 | m_pixmapSelector->addItem( i18nc( "Symbol for caret annotations", "P" ), QStringLiteral("caret-p") ); | 826 | m_pixmapSelector->addItem( i18nc( "Symbol for caret annotations", "P" ), QStringLiteral("caret-p") ); | ||
896 | m_pixmapSelector->setIcon( caretSymbolToIcon( m_caretAnn->caretSymbol() ) ); | 827 | m_pixmapSelector->setIcon( caretSymbolToIcon( m_caretAnn->caretSymbol() ) ); | ||
897 | 828 | | |||
898 | connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); | 829 | connect( m_pixmapSelector, &PixmapPreviewSelector::iconChanged, this, &AnnotationWidget::dataChanged ); | ||
899 | | ||||
900 | return widget; | | |||
901 | } | 830 | } | ||
aacid: return at the end of a function screams really bad at me, please fix :) | |||||
902 | 831 | | |||
903 | void CaretAnnotationWidget::applyChanges() | 832 | void CaretAnnotationWidget::applyChanges() | ||
904 | { | 833 | { | ||
905 | AnnotationWidget::applyChanges(); | 834 | AnnotationWidget::applyChanges(); | ||
906 | m_caretAnn->setCaretSymbol( caretSymbolFromIcon( m_pixmapSelector->icon() ) ); | 835 | m_caretAnn->setCaretSymbol( caretSymbolFromIcon( m_pixmapSelector->icon() ) ); | ||
907 | } | 836 | } | ||
908 | 837 | | |||
909 | 838 | | |||
910 | 839 | | |||
911 | #include "moc_annotationwidgets.cpp" | 840 | #include "moc_annotationwidgets.cpp" |
Is it correct to set this growth policy? I have not found any guideline on the HIG. Compared to the grid layout where label and widget take the same amount of horizontal space, now the widgets take way more space making it a little ugly for some annotation tools. Any idea?