8#include "tableformatdialog.h"
9#include "inserttablewidget.h"
11#include <KColorButton>
12#include <KLocalizedString>
17#include <QDialogButtonBox>
23using namespace KPIMTextEdit;
25class TableFormatDialog::TableFormatDialogPrivate
28 explicit TableFormatDialogPrivate(TableFormatDialog *qq)
31 q->setWindowTitle(
i18nc(
"@title:window",
"Table Format"));
32 auto mainLayout =
new QVBoxLayout(q);
35 auto lay =
new QVBoxLayout(page);
36 lay->setContentsMargins({});
37 tableWidget =
new InsertTableWidget;
38 lay->addWidget(tableWidget);
40 auto sep =
new KSeparator;
43 auto hbox =
new QHBoxLayout;
44 auto lab =
new QLabel(
i18nc(
"@label:textbox",
"Spacing:"));
46 spacing =
new QSpinBox;
47 spacing->setMinimum(0);
48 hbox->addWidget(spacing);
49 lab =
new QLabel(
i18nc(
"@label:textbox",
"pixels between cells"));
53 hbox =
new QHBoxLayout;
54 lab =
new QLabel(
i18nc(
"@label:textbox",
"Padding:"));
56 padding =
new QSpinBox;
57 padding->setMinimum(0);
58 hbox->addWidget(padding);
59 lab =
new QLabel(
i18nc(
"@label:textbox",
"pixels between cell border and content"));
66 alignment =
new QComboBox;
72 hbox =
new QHBoxLayout;
73 lab =
new QLabel(
i18nc(
"@label:textbox",
"Table Alignment:"));
75 hbox->addWidget(alignment);
82 hbox =
new QHBoxLayout;
83 useBackgroundColor =
new QCheckBox(
i18nc(
"@option:check",
"Background Color:"));
85 hbox->addWidget(useBackgroundColor);
86 backgroundColor =
new KColorButton;
87 backgroundColor->setDefaultColor(
Qt::white);
88 hbox->addWidget(backgroundColor);
93 backgroundColor->setEnabled(
false);
99 mainLayout->addWidget(page);
100 mainLayout->addWidget(buttonBox);
103 QCheckBox *useBackgroundColor =
nullptr;
104 KColorButton *backgroundColor =
nullptr;
105 QComboBox *alignment =
nullptr;
106 QSpinBox *spacing =
nullptr;
107 QSpinBox *padding =
nullptr;
108 KPIMTextEdit::InsertTableWidget *tableWidget =
nullptr;
109 TableFormatDialog *
const q;
112TableFormatDialog::TableFormatDialog(
QWidget *parent)
114 , d(new TableFormatDialogPrivate(this))
118TableFormatDialog::~TableFormatDialog() =
default;
120int TableFormatDialog::columns()
const
122 return d->tableWidget->columns();
125int TableFormatDialog::rows()
const
127 return d->tableWidget->rows();
130int TableFormatDialog::border()
const
132 return d->tableWidget->border();
135void TableFormatDialog::setColumns(
int col)
137 d->tableWidget->setColumns(col);
140void TableFormatDialog::setRows(
int row)
142 d->tableWidget->setRows(row);
145void TableFormatDialog::setBorder(
int border)
147 d->tableWidget->setBorder(border);
150int TableFormatDialog::padding()
const
152 return d->padding->value();
155void TableFormatDialog::setPadding(
int value)
157 d->padding->setValue(value);
160int TableFormatDialog::spacing()
const
162 return d->spacing->value();
165void TableFormatDialog::setSpacing(
int value)
167 d->spacing->setValue(value);
172 d->alignment->setCurrentIndex(d->alignment->findData(QVariant(alignment)));
177 return static_cast<Qt::Alignment>(d->alignment->itemData(d->alignment->currentIndex()).toInt());
182 return d->tableWidget->typeOfLength();
185int TableFormatDialog::length()
const
187 return d->tableWidget->length();
190void TableFormatDialog::setLength(
int val)
192 d->tableWidget->setLength(val);
197 d->tableWidget->setTypeOfLength(type);
200QColor TableFormatDialog::tableBackgroundColor()
const
202 return d->backgroundColor->color();
205void TableFormatDialog::setTableBackgroundColor(
const QColor &col)
207 d->backgroundColor->setColor(col);
208 d->useBackgroundColor->setChecked(
true);
211bool TableFormatDialog::useBackgroundColor()
const
213 return d->useBackgroundColor->isChecked();
216#include "moc_tableformatdialog.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)