20 #include <QVBoxLayout>
21 #include <QGridLayout>
25 #include <KColorCombo>
26 #include <KFontRequester>
27 #include <KIconButton>
28 #include <KKeySequenceWidget>
29 #include <KActionCollection>
32 using namespace MailCommon;
37 QGridLayout *settings =
new QGridLayout;
38 settings->setMargin( KDialog::marginHint() );
39 settings->setSpacing( KDialog::spacingHint() );
43 QVBoxLayout *spacer =
new QVBoxLayout();
44 settings->addLayout( spacer, 0, 0, 1, 2 );
45 spacer->addSpacing( 2 * KDialog::spacingHint() );
48 mTagNameLineEdit =
new KLineEdit(
this );
49 mTagNameLineEdit->setClearButtonShown(
true);
50 mTagNameLineEdit->setTrapReturnKey(
true );
51 settings->addWidget( mTagNameLineEdit, 1, 1 );
53 QLabel *namelabel =
new QLabel( i18nc(
"@label:listbox Name of the tag",
"Name:")
55 namelabel->setBuddy( mTagNameLineEdit );
56 settings->addWidget( namelabel, 1, 0 );
58 connect( mTagNameLineEdit, SIGNAL(textChanged(QString)),
59 this, SLOT(slotEmitChangeCheck()) );
62 mTextColorCheck =
new QCheckBox( i18n(
"Change te&xt color:"),
64 settings->addWidget( mTextColorCheck, 2, 0 );
66 mTextColorCombo =
new KColorCombo(
this );
67 settings->addWidget( mTextColorCombo, 2, 1 );
68 mTextColorCombo->setEnabled(
false);
70 connect( mTextColorCheck, SIGNAL(toggled(
bool)),
71 mTextColorCombo, SLOT(setEnabled(
bool)) );
72 connect( mTextColorCheck, SIGNAL(stateChanged(
int)),
73 this, SLOT(slotEmitChangeCheck()) );
74 connect( mTextColorCombo, SIGNAL(activated(
int)),
75 this, SLOT(slotEmitChangeCheck()) );
78 mBackgroundColorCheck =
new QCheckBox( i18n(
"Change &background color:"),
80 settings->addWidget( mBackgroundColorCheck, 3, 0 );
82 mBackgroundColorCombo =
new KColorCombo(
this );
83 settings->addWidget( mBackgroundColorCombo, 3, 1 );
84 mBackgroundColorCombo->setEnabled(
false);
86 connect( mBackgroundColorCheck, SIGNAL(toggled(
bool)),
87 mBackgroundColorCombo, SLOT(setEnabled(
bool)) );
88 connect( mBackgroundColorCheck, SIGNAL(stateChanged(
int)),
89 this, SLOT(slotEmitChangeCheck()) );
90 connect( mBackgroundColorCombo, SIGNAL(activated(
int)),
91 this, SLOT(slotEmitChangeCheck()) );
94 mTextFontCheck =
new QCheckBox( i18n(
"Change fo&nt:"),
this );
95 settings->addWidget( mTextFontCheck, 4, 0 );
97 mFontRequester =
new KFontRequester(
this );
98 settings->addWidget( mFontRequester, 4, 1 );
99 mFontRequester->setEnabled(
false);
101 connect( mTextFontCheck, SIGNAL(toggled(
bool)),
102 mFontRequester, SLOT(setEnabled(
bool)) );
103 connect( mTextFontCheck, SIGNAL(stateChanged(
int)),
104 this, SLOT(slotEmitChangeCheck()) );
105 connect( mFontRequester, SIGNAL(fontSelected(QFont)),
106 this, SLOT(slotEmitChangeCheck()) );
109 mIconButton =
new KIconButton(
this );
110 mIconButton->setIconSize( 16 );
111 mIconButton->setIconType( KIconLoader::NoGroup, KIconLoader::Action );
112 mIconButton->setIcon(KIcon(QLatin1String(
"mail-tagged")));
113 settings->addWidget( mIconButton, 5, 1 );
114 connect( mIconButton, SIGNAL(iconChanged(QString)),
117 QLabel *iconlabel =
new QLabel( i18n(
"Message tag &icon:"),
119 iconlabel->setBuddy( mIconButton );
120 settings->addWidget( iconlabel, 5, 0 );
124 connect( mIconButton, SIGNAL(iconChanged(QString)),
125 this, SLOT(slotEmitChangeCheck()) );
128 mKeySequenceWidget =
new KKeySequenceWidget(
this );
129 settings->addWidget( mKeySequenceWidget, 6, 1 );
130 QLabel *sclabel =
new QLabel( i18n(
"Shortc&ut:") ,
this );
131 sclabel->setBuddy( mKeySequenceWidget );
132 settings->addWidget( sclabel, 6, 0 );
133 if ( !actionCollections.isEmpty() ) {
134 mKeySequenceWidget->setCheckActionCollections( actionCollections );
135 connect( mKeySequenceWidget, SIGNAL(keySequenceChanged(QKeySequence)),
136 this, SLOT(slotEmitChangeCheck()) );
139 mKeySequenceWidget->setEnabled(
false);
143 mInToolbarCheck =
new QCheckBox( i18n(
"Enable &toolbar button"),
145 settings->addWidget( mInToolbarCheck, 7, 0 );
146 connect( mInToolbarCheck, SIGNAL(stateChanged(
int)),
147 this, SLOT(slotEmitChangeCheck()) );
156 void TagWidget::slotEmitChangeCheck()
163 mTextColorCheck->setEnabled(
true );
164 if ( color.isValid() ) {
165 mTextColorCheck->setChecked(
true );
166 mTextColorCombo->setColor( color );
168 mTextColorCheck->setChecked(
false );
169 mTextColorCombo->setColor( Qt::white );
171 mTextColorCombo->setEnabled(mTextColorCheck->isChecked());
176 mBackgroundColorCheck->setEnabled(
true );
177 if ( color.isValid() ) {
178 mBackgroundColorCheck->setChecked(
true );
179 mBackgroundColorCombo->setColor( color );
181 mBackgroundColorCheck->setChecked(
false );
182 mBackgroundColorCombo->setColor( Qt::white );
184 mBackgroundColorCombo->setEnabled( mBackgroundColorCheck->isChecked() );
189 mTextFontCheck->setEnabled(
true );
190 mTextFontCheck->setChecked( ( font != QFont() ) );
191 mFontRequester->setFont( font );
192 mFontRequester->setEnabled( mTextFontCheck->isChecked() );
198 if ( mTextColorCheck->isChecked() )
200 if ( mBackgroundColorCheck->isChecked() )
202 if ( mTextFontCheck->isChecked() )
210 tag->textColor = mTextColorCheck->isChecked() ? mTextColorCombo->color() : QColor();
212 tag->backgroundColor = mBackgroundColorCheck->isChecked() ? mBackgroundColorCombo->color() : QColor();
214 tag->textFont = mTextFontCheck->isChecked() ? mFontRequester->font() : QFont();
217 if (mKeySequenceWidget->isEnabled()) {
218 mKeySequenceWidget->applyStealShortcut();
219 tag->shortcut = KShortcut( mKeySequenceWidget->keySequence() );
222 tag->inToolbar = mInToolbarCheck->isChecked();
225 #include "tagwidget.moc"
QFlags< SaveFlag > SaveFlags