26 #include <kpimidentities/identitymanager.h>
30 #include <KLocalizedString>
33 #include <QButtonGroup>
34 #include <QHBoxLayout>
36 #include <QRadioButton>
37 #include <QVBoxLayout>
41 using namespace KMail;
45 mIdentityManager( manager )
47 setCaption( i18n(
"New Identity") );
48 setButtons( Ok|Cancel|Help );
49 setHelp( QString::fromLatin1(
"configure-identity-newidentitydialog") );
51 setMainWidget( page );
52 QVBoxLayout * vlay =
new QVBoxLayout( page );
53 vlay->setSpacing( spacingHint() );
57 QHBoxLayout * hlay =
new QHBoxLayout();
58 vlay->addLayout( hlay );
60 mLineEdit->setFocus();
61 mLineEdit->setClearButtonShown(
true );
63 l->setBuddy( mLineEdit );
65 hlay->addWidget( mLineEdit, 1 );
66 connect( mLineEdit, SIGNAL(textChanged(QString)),
69 mButtonGroup =
new QButtonGroup( page );
72 QRadioButton *radio =
new QRadioButton( i18n(
"&With empty fields"), page );
73 radio->setChecked(
true );
74 vlay->addWidget( radio );
75 mButtonGroup->addButton( radio, (
int)
Empty );
78 radio =
new QRadioButton( i18n(
"&Use System Settings values"), page );
79 vlay->addWidget( radio );
83 radio =
new QRadioButton( i18n(
"&Duplicate existing identity"), page );
84 vlay->addWidget( radio );
88 hlay =
new QHBoxLayout();
89 vlay->addLayout( hlay );
91 mComboBox->setEditable(
false );
92 mComboBox->addItems( manager->shadowIdentities() );
93 mComboBox->setEnabled(
false );
94 QLabel *label =
new QLabel( i18n(
"&Existing identities:"), page );
95 label->setBuddy( mComboBox );
96 label->setEnabled(
false );
97 hlay->addWidget( label );
98 hlay->addWidget( mComboBox, 1 );
100 vlay->addWidget(
new KSeparator);
101 vlay->addStretch( 1 );
105 connect( radio, SIGNAL(toggled(
bool)),
106 label, SLOT(setEnabled(
bool)) );
107 connect( radio, SIGNAL(toggled(
bool)),
108 mComboBox, SLOT(setEnabled(
bool)) );
110 enableButtonOk(
false );
116 const int id = mButtonGroup->checkedId();
117 assert(
id == (
int)
Empty
126 const QString name = proposedIdentityName.trimmed();
128 if ( name.isEmpty() ) {
129 enableButtonOk(
false );
133 if ( !mIdentityManager->isUnique( name ) ) {
134 enableButtonOk(
false );
137 enableButtonOk(
true );
142 return mLineEdit->text();
147 return mComboBox->currentText();
150 #include "newidentitydialog.moc"
QString identityName() const
QString duplicateIdentity() const
NewIdentityDialog(KPIMIdentities::IdentityManager *manager, QWidget *parent=0)
void slotEnableOK(const QString &)
DuplicateMode duplicateMode() const