Changeset View
Changeset View
Standalone View
Standalone View
conf/editannottooldialog.cpp
Show All 28 Lines | |||||
29 | #include <KConfigGroup> | 29 | #include <KConfigGroup> | ||
30 | #include <QDialogButtonBox> | 30 | #include <QDialogButtonBox> | ||
31 | 31 | | |||
32 | #include "core/annotations.h" | 32 | #include "core/annotations.h" | ||
33 | #include "ui/annotationwidgets.h" | 33 | #include "ui/annotationwidgets.h" | ||
34 | #include "ui/pageviewannotator.h" | 34 | #include "ui/pageviewannotator.h" | ||
35 | 35 | | |||
36 | 36 | | |||
37 | EditAnnotToolDialog::EditAnnotToolDialog( QWidget *parent, const QDomElement &initialState ) | 37 | EditAnnotToolDialog::EditAnnotToolDialog( QWidget *parent, const QDomElement &initialState, bool builtinTool ) | ||
38 | : QDialog( parent ), m_stubann( nullptr ), m_annotationWidget( nullptr ) | 38 | : QDialog( parent ), m_stubann( nullptr ), m_annotationWidget( nullptr ), m_builtinTool( false ) | ||
39 | { | 39 | { | ||
40 | m_builtinTool = builtinTool; | ||||
davidhurka: Why initialize m_builtinTool to false in the initializer list? There aren’t superclass… | |||||
41 | | ||||
40 | QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); | 42 | QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); | ||
41 | QVBoxLayout *mainLayout = new QVBoxLayout; | 43 | QVBoxLayout *mainLayout = new QVBoxLayout; | ||
42 | setLayout(mainLayout); | 44 | setLayout(mainLayout); | ||
43 | QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); | 45 | QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); | ||
44 | okButton->setDefault(true); | 46 | okButton->setDefault(true); | ||
45 | okButton->setShortcut(Qt::CTRL | Qt::Key_Return); | 47 | okButton->setShortcut(Qt::CTRL | Qt::Key_Return); | ||
46 | connect(buttonBox, &QDialogButtonBox::accepted, this, &EditAnnotToolDialog::accept); | 48 | connect(buttonBox, &QDialogButtonBox::accepted, this, &EditAnnotToolDialog::accept); | ||
47 | connect(buttonBox, &QDialogButtonBox::rejected, this, &EditAnnotToolDialog::reject); | 49 | connect(buttonBox, &QDialogButtonBox::rejected, this, &EditAnnotToolDialog::reject); | ||
48 | okButton->setDefault(true); | 50 | okButton->setDefault(true); | ||
49 | 51 | | |||
50 | QLabel * tmplabel; | 52 | QLabel * tmplabel; | ||
51 | QWidget *widget = new QWidget( this ); | 53 | QWidget *widget = new QWidget( this ); | ||
52 | QGridLayout * widgetLayout = new QGridLayout( widget ); | 54 | QGridLayout * widgetLayout = new QGridLayout( widget ); | ||
53 | 55 | | |||
54 | mainLayout->addWidget(widget); | 56 | mainLayout->addWidget(widget); | ||
55 | mainLayout->addWidget(buttonBox); | 57 | mainLayout->addWidget(buttonBox); | ||
56 | 58 | | |||
57 | | ||||
58 | m_name = new KLineEdit( widget ); | 59 | m_name = new KLineEdit( widget ); | ||
60 | m_name->setReadOnly( m_builtinTool ); | ||||
59 | mainLayout->addWidget(m_name); | 61 | mainLayout->addWidget(m_name); | ||
60 | tmplabel = new QLabel( i18n( "&Name:" ), widget ); | 62 | tmplabel = new QLabel( i18n( "&Name:" ), widget ); | ||
61 | mainLayout->addWidget(tmplabel); | 63 | mainLayout->addWidget(tmplabel); | ||
62 | tmplabel->setBuddy( m_name ); | 64 | tmplabel->setBuddy( m_name ); | ||
63 | widgetLayout->addWidget( tmplabel, 0, 0, Qt::AlignRight ); | 65 | widgetLayout->addWidget( tmplabel, 0, 0, Qt::AlignRight ); | ||
64 | widgetLayout->addWidget( m_name, 0, 1 ); | 66 | widgetLayout->addWidget( m_name, 0, 1 ); | ||
65 | 67 | | |||
66 | m_type = new KComboBox( false, widget ); | 68 | m_type = new KComboBox( false, widget ); | ||
69 | m_type->setVisible( !m_builtinTool ); | ||||
67 | mainLayout->addWidget(m_type); | 70 | mainLayout->addWidget(m_type); | ||
68 | connect(m_type, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &EditAnnotToolDialog::slotTypeChanged); | 71 | connect(m_type, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &EditAnnotToolDialog::slotTypeChanged); | ||
69 | tmplabel = new QLabel( i18n( "&Type:" ), widget ); | 72 | tmplabel = new QLabel( i18n( "&Type:" ), widget ); | ||
70 | mainLayout->addWidget(tmplabel); | 73 | mainLayout->addWidget(tmplabel); | ||
71 | tmplabel->setBuddy( m_type ); | 74 | tmplabel->setBuddy( m_type ); | ||
75 | tmplabel->setVisible( !m_builtinTool ); | ||||
72 | widgetLayout->addWidget( tmplabel, 1, 0, Qt::AlignRight ); | 76 | widgetLayout->addWidget( tmplabel, 1, 0, Qt::AlignRight ); | ||
73 | widgetLayout->addWidget( m_type, 1, 1 ); | 77 | widgetLayout->addWidget( m_type, 1, 1 ); | ||
74 | 78 | | |||
75 | m_toolIcon = new QLabel( widget ); | 79 | m_toolIcon = new QLabel( widget ); | ||
76 | mainLayout->addWidget(m_toolIcon); | 80 | mainLayout->addWidget(m_toolIcon); | ||
77 | m_toolIcon->setAlignment( Qt::AlignRight | Qt::AlignTop ); | 81 | m_toolIcon->setAlignment( Qt::AlignRight | Qt::AlignTop ); | ||
78 | m_toolIcon->setMinimumSize( 40, 32 ); | 82 | m_toolIcon->setMinimumSize( 40, 32 ); | ||
79 | widgetLayout->addWidget( m_toolIcon, 0, 2, 2, 1 ); | 83 | widgetLayout->addWidget( m_toolIcon, 0, 2, 2, 1 ); | ||
▲ Show 20 Lines • Show All 296 Lines • ▼ Show 20 Line(s) | 379 | { | |||
376 | // Remove previous widget (if any) | 380 | // Remove previous widget (if any) | ||
377 | if ( m_annotationWidget ) | 381 | if ( m_annotationWidget ) | ||
378 | { | 382 | { | ||
379 | delete m_annotationWidget->appearanceWidget(); | 383 | delete m_annotationWidget->appearanceWidget(); | ||
380 | delete m_annotationWidget; | 384 | delete m_annotationWidget; | ||
381 | } | 385 | } | ||
382 | 386 | | |||
383 | m_annotationWidget = AnnotationWidgetFactory::widgetFor( m_stubann ); | 387 | m_annotationWidget = AnnotationWidgetFactory::widgetFor( m_stubann ); | ||
388 | m_annotationWidget->setAnnotTypeEditable( !m_builtinTool ); | ||||
384 | m_appearanceBox->layout()->addWidget( m_annotationWidget->appearanceWidget() ); | 389 | m_appearanceBox->layout()->addWidget( m_annotationWidget->appearanceWidget() ); | ||
385 | 390 | | |||
386 | connect(m_annotationWidget, &AnnotationWidget::dataChanged, this, &EditAnnotToolDialog::slotDataChanged); | 391 | connect(m_annotationWidget, &AnnotationWidget::dataChanged, this, &EditAnnotToolDialog::slotDataChanged); | ||
387 | } | 392 | } | ||
388 | 393 | | |||
389 | void EditAnnotToolDialog::updateDefaultNameAndIcon() | 394 | void EditAnnotToolDialog::updateDefaultNameAndIcon() | ||
390 | { | 395 | { | ||
391 | QDomDocument doc = toolXml(); | 396 | QDomDocument doc = toolXml(); | ||
▲ Show 20 Lines • Show All 154 Lines • Show Last 20 Lines |
Why initialize m_builtinTool to false in the initializer list? There aren’t superclass constructors or so which need it, or do I miss something?