9#include <KLineEditEventHandler>
11#include <KActionCollection>
14#include <KKeySequenceWidget>
15#include <KLocalizedString>
23class MailCommon::TagWidgetPrivate
26 TagWidgetPrivate() =
default;
31 QCheckBox *mBackgroundColorCheck =
nullptr;
51 settings->setContentsMargins({});
55 settings->addLayout(spacer, 0, 0, 1, 2);
58 d->mTagNameLineEdit =
new QLineEdit(
this);
59 d->mTagNameLineEdit->setClearButtonEnabled(
true);
61 settings->addWidget(d->mTagNameLineEdit, 1, 1);
63 auto namelabel =
new QLabel(
i18nc(
"@label:listbox Name of the tag",
"Name:"),
this);
64 namelabel->setBuddy(d->mTagNameLineEdit);
65 settings->addWidget(namelabel, 1, 0);
70 d->mTextColorCheck =
new QCheckBox(
i18nc(
"@option:check",
"Change te&xt color:"),
this);
71 settings->addWidget(d->mTextColorCheck, 2, 0);
74 settings->addWidget(d->mTextColorCombo, 2, 1);
75 d->mTextColorCombo->setEnabled(
false);
78 connect(d->mTextColorCheck, &QCheckBox::checkStateChanged,
this, &TagWidget::slotEmitChangeCheck);
82 d->mBackgroundColorCheck =
new QCheckBox(
i18nc(
"@option:check",
"Change &background color:"),
this);
83 settings->addWidget(d->mBackgroundColorCheck, 3, 0);
86 settings->addWidget(d->mBackgroundColorCombo, 3, 1);
87 d->mBackgroundColorCombo->setEnabled(
false);
90 connect(d->mBackgroundColorCheck, &QCheckBox::checkStateChanged,
this, &TagWidget::slotEmitChangeCheck);
94 d->mTextFontCheck =
new QCheckBox(
i18nc(
"@option:check",
"Change fo&nt:"),
this);
95 settings->addWidget(d->mTextFontCheck, 4, 0);
100 d->mBoldCheckBox =
new QCheckBox(
i18nc(
"@option:check",
"&Bold"));
101 d->mBoldCheckBox->setEnabled(
false);
102 fontLayout->addWidget(d->mBoldCheckBox);
104 d->mItalicCheckBox =
new QCheckBox(
i18nc(
"@option:check",
"&Italics"));
105 d->mItalicCheckBox->setEnabled(
false);
106 fontLayout->addWidget(d->mItalicCheckBox);
110 connect(d->mTextFontCheck, &QCheckBox::checkStateChanged,
this, &TagWidget::slotEmitChangeCheck);
116 d->mIconButton->setIconSize(16);
119 settings->addWidget(d->mIconButton, 5, 1);
122 auto iconlabel =
new QLabel(
i18nc(
"@label:textbox",
"Message tag &icon:"),
this);
123 iconlabel->setBuddy(d->mIconButton);
124 settings->addWidget(iconlabel, 5, 0);
132 settings->addWidget(d->mKeySequenceWidget, 6, 1);
133 auto sclabel =
new QLabel(
i18nc(
"@label:textbox",
"Shortc&ut:"),
this);
134 sclabel->setBuddy(d->mKeySequenceWidget);
135 settings->addWidget(sclabel, 6, 0);
136 if (!actionCollections.
isEmpty()) {
137 d->mKeySequenceWidget->setCheckActionCollections(actionCollections);
140 d->mKeySequenceWidget->setEnabled(
false);
144 d->mInToolbarCheck =
new QCheckBox(
i18nc(
"@option:check",
"Enable &toolbar button"),
this);
145 settings->addWidget(d->mInToolbarCheck, 7, 0);
146 connect(d->mInToolbarCheck, &QCheckBox::checkStateChanged,
this, &TagWidget::slotEmitChangeCheck);
149TagWidget::~TagWidget() =
default;
151void TagWidget::slotEmitChangeCheck()
156void TagWidget::setTagTextColor(
const QColor &color)
158 d->mTextColorCheck->setEnabled(
true);
160 d->mTextColorCheck->setChecked(
true);
161 d->mTextColorCombo->setColor(color);
163 d->mTextColorCheck->setChecked(
false);
166 d->mTextColorCombo->setEnabled(d->mTextColorCheck->isChecked());
169void TagWidget::setTagBackgroundColor(
const QColor &color)
171 d->mBackgroundColorCheck->setEnabled(
true);
173 d->mBackgroundColorCheck->setChecked(
true);
174 d->mBackgroundColorCombo->setColor(color);
176 d->mBackgroundColorCheck->setChecked(
false);
177 d->mBackgroundColorCombo->setColor(
Qt::white);
179 d->mBackgroundColorCombo->setEnabled(d->mBackgroundColorCheck->isChecked());
182void TagWidget::setTagTextFormat(
bool isBold,
bool isItalic)
184 d->mTextFontCheck->setEnabled(
true);
185 d->mTextFontCheck->setChecked(isBold || isItalic);
186 d->mBoldCheckBox->setChecked(isBold);
187 d->mItalicCheckBox->setChecked(isItalic);
192 tag->textColor = d->mTextColorCheck->isChecked() ? d->mTextColorCombo->color() :
QColor();
194 tag->backgroundColor = d->mBackgroundColorCheck->isChecked() ? d->mBackgroundColorCombo->color() :
QColor();
196 tag->isBold = d->mTextFontCheck->isChecked() ? d->mBoldCheckBox->isChecked() :
false;
197 tag->isItalic = d->mTextFontCheck->isChecked() ? d->mItalicCheckBox->isChecked() :
false;
199 tag->iconName = iconButton()->
icon();
200 if (d->mKeySequenceWidget->isEnabled()) {
201 d->mKeySequenceWidget->applyStealShortcut();
202 tag->shortcut =
QKeySequence(d->mKeySequenceWidget->keySequence());
205 tag->inToolbar = d->mInToolbarCheck->isChecked();
208QLineEdit *TagWidget::tagNameLineEdit()
const
210 return d->mTagNameLineEdit;
213QCheckBox *TagWidget::textColorCheck()
const
215 return d->mTextColorCheck;
218QCheckBox *TagWidget::textFontCheck()
const
220 return d->mTextFontCheck;
223QCheckBox *TagWidget::backgroundColorCheck()
const
225 return d->mBackgroundColorCheck;
228QCheckBox *TagWidget::inToolBarCheck()
const
230 return d->mInToolbarCheck;
235 return d->mTextColorCombo;
238KColorCombo *TagWidget::backgroundColorCombo()
const
240 return d->mBackgroundColorCombo;
243QCheckBox *TagWidget::textBoldCheck()
const
245 return d->mBoldCheckBox;
248QCheckBox *TagWidget::textItalicCheck()
const
250 return d->mItalicCheckBox;
255 return d->mIconButton;
260 return d->mKeySequenceWidget;
263#include "moc_tagwidget.cpp"
void activated(const QColor &col)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void catchReturnKey(QObject *lineEdit)
void addLayout(QLayout *layout, int stretch)
bool isValid() const const
QIcon fromTheme(const QString &name)
void textChanged(const QString &text)
bool isEmpty() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)