• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kmail

  • sources
  • kde-4.12
  • kdepim
  • kmail
  • identity
newidentitydialog.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2  * kmail: KDE mail client
3  * Copyright (C) 2000 Espen Sand, espen@kde.org
4  * Copyright (C) 2001-2003 Marc Mutz, mutz@kde.org
5  * Contains code segments and ideas from earlier kmail dialog code.
6  * Copyright (C) 2010 Volker Krause <vkrause@kde.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  */
23 
24 #include "newidentitydialog.h"
25 
26 #include <kpimidentities/identitymanager.h>
27 
28 #include <KComboBox>
29 #include <KLineEdit>
30 #include <KLocalizedString>
31 #include <KSeparator>
32 
33 #include <QButtonGroup>
34 #include <QHBoxLayout>
35 #include <QLabel>
36 #include <QRadioButton>
37 #include <QVBoxLayout>
38 
39 #include <assert.h>
40 
41 using namespace KMail;
42 
43 NewIdentityDialog::NewIdentityDialog( KPIMIdentities::IdentityManager* manager, QWidget *parent )
44  : KDialog( parent ),
45  mIdentityManager( manager )
46 {
47  setCaption( i18n("New Identity") );
48  setButtons( Ok|Cancel|Help );
49  setHelp( QString::fromLatin1("configure-identity-newidentitydialog") );
50  QWidget *page = new QWidget( this );
51  setMainWidget( page );
52  QVBoxLayout * vlay = new QVBoxLayout( page );
53  vlay->setSpacing( spacingHint() );
54  vlay->setMargin( 0 );
55 
56  // row 0: line edit with label
57  QHBoxLayout * hlay = new QHBoxLayout(); // inherits spacing
58  vlay->addLayout( hlay );
59  mLineEdit = new KLineEdit( page );
60  mLineEdit->setFocus();
61  mLineEdit->setClearButtonShown( true );
62  QLabel *l = new QLabel( i18n("&New identity:"), page );
63  l->setBuddy( mLineEdit );
64  hlay->addWidget( l );
65  hlay->addWidget( mLineEdit, 1 );
66  connect( mLineEdit, SIGNAL(textChanged(QString)),
67  this, SLOT(slotEnableOK(QString)) );
68 
69  mButtonGroup = new QButtonGroup( page );
70 
71  // row 1: radio button
72  QRadioButton *radio = new QRadioButton( i18n("&With empty fields"), page );
73  radio->setChecked( true );
74  vlay->addWidget( radio );
75  mButtonGroup->addButton( radio, (int)Empty );
76 
77  // row 2: radio button
78  radio = new QRadioButton( i18n("&Use System Settings values"), page );
79  vlay->addWidget( radio );
80  mButtonGroup->addButton( radio, (int)ControlCenter );
81 
82  // row 3: radio button
83  radio = new QRadioButton( i18n("&Duplicate existing identity"), page );
84  vlay->addWidget( radio );
85  mButtonGroup->addButton( radio, (int)ExistingEntry );
86 
87  // row 4: combobox with existing identities and label
88  hlay = new QHBoxLayout(); // inherits spacing
89  vlay->addLayout( hlay );
90  mComboBox = new KComboBox( page );
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 );
99 
100  vlay->addWidget(new KSeparator);
101  vlay->addStretch( 1 ); // spacer
102 
103  // enable/disable combobox and label depending on the third radio
104  // button's state:
105  connect( radio, SIGNAL(toggled(bool)),
106  label, SLOT(setEnabled(bool)) );
107  connect( radio, SIGNAL(toggled(bool)),
108  mComboBox, SLOT(setEnabled(bool)) );
109 
110  enableButtonOk( false ); // since line edit is empty
111  resize(400,180);
112 }
113 
114 NewIdentityDialog::DuplicateMode NewIdentityDialog::duplicateMode() const
115 {
116  const int id = mButtonGroup->checkedId();
117  assert( id == (int)Empty
118  || id == (int)ControlCenter
119  || id == (int)ExistingEntry );
120  return static_cast<DuplicateMode>( id );
121 }
122 
123 void NewIdentityDialog::slotEnableOK( const QString & proposedIdentityName )
124 {
125  // OK button is disabled if
126  const QString name = proposedIdentityName.trimmed();
127  // name isn't empty
128  if ( name.isEmpty() ) {
129  enableButtonOk( false );
130  return;
131  }
132  // or name doesn't yet exist.
133  if ( !mIdentityManager->isUnique( name ) ) {
134  enableButtonOk( false );
135  return;
136  }
137  enableButtonOk( true );
138 }
139 
140 QString NewIdentityDialog::identityName() const
141 {
142  return mLineEdit->text();
143 }
144 
145 QString NewIdentityDialog::duplicateIdentity() const
146 {
147  return mComboBox->currentText();
148 }
149 
150 #include "newidentitydialog.moc"
KMail::NewIdentityDialog::identityName
QString identityName() const
Definition: newidentitydialog.cpp:140
newidentitydialog.h
KMail::NewIdentityDialog::Empty
Definition: newidentitydialog.h:44
QWidget
KDialog
KMail::NewIdentityDialog::ExistingEntry
Definition: newidentitydialog.h:44
KMail::NewIdentityDialog::ControlCenter
Definition: newidentitydialog.h:44
KLineEdit
KMail::NewIdentityDialog::duplicateIdentity
QString duplicateIdentity() const
Definition: newidentitydialog.cpp:145
QLabel
KComboBox
KMail::NewIdentityDialog::NewIdentityDialog
NewIdentityDialog(KPIMIdentities::IdentityManager *manager, QWidget *parent=0)
Definition: newidentitydialog.cpp:43
KMail::NewIdentityDialog::slotEnableOK
void slotEnableOK(const QString &)
Definition: newidentitydialog.cpp:123
KMail::NewIdentityDialog::duplicateMode
DuplicateMode duplicateMode() const
Definition: newidentitydialog.cpp:114
KMail::NewIdentityDialog::DuplicateMode
DuplicateMode
Definition: newidentitydialog.h:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:52 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal