25 #include <KMessageBox>
27 #include <QIntValidator>
29 #include <QVBoxLayout>
33 using namespace KgpgCore;
41 setButtons(User1 | Ok | Cancel);
43 setButtonText(User1, i18n(
"&Expert Mode"));
44 setButtonToolTip(User1, i18n(
"Go to Expert Mode"));
45 setButtonWhatsThis(User1, i18n(
"If you go to expert mode, you will use the command line to create your key." ));
47 connect(m_kname, SIGNAL(textChanged(
QString)),
this, SLOT(slotEnableOk()));
49 KHBox *hgroup =
new KHBox(vgroup);
50 hgroup->setFrameShape(QFrame::StyledPanel);
51 hgroup->setMargin(marginHint());
52 hgroup->setSpacing(spacingHint());
53 m_days->setParent(hgroup);
56 m_days->setValidator(validator);
57 m_days->setMaxLength(4);
58 m_days->setDisabled(
true);
60 m_keyexp =
new KComboBox(hgroup);
61 m_keyexp->addItem(i18nc(
"Key will not expire",
"Never"), 0);
62 m_keyexp->addItem(i18n(
"Days"), 1);
63 m_keyexp->addItem(i18n(
"Weeks"), 2);
64 m_keyexp->addItem(i18n(
"Months"), 3);
65 m_keyexp->addItem(i18n(
"Years"), 4);
66 m_keyexp->setMinimumSize(m_keyexp->sizeHint());
67 connect(m_keyexp, SIGNAL(activated(
int)),
this, SLOT(slotEnableDays(
int)));
69 qobject_cast<
QVBoxLayout *>(vgroup->layout())->insertWidget(7, hgroup);
71 m_keysize->addItem(i18n(
"1024"));
72 m_keysize->addItem(i18n(
"2048"));
73 m_keysize->addItem(i18n(
"4096"));
74 m_keysize->setCurrentIndex(1);
75 m_keysize->setMinimumSize(m_keysize->sizeHint());
80 m_keykind->setCurrentIndex(1);
81 slotEnableCaps(m_keykind->currentIndex());
82 m_keykind->setMinimumSize(m_keykind->sizeHint());
84 setMainWidget(vgroup);
90 connect(
this, SIGNAL(okClicked()),
this, SLOT(slotOk()));
91 connect(
this, SIGNAL(user1Clicked()),
this, SLOT(slotUser1()));
92 connect(m_keykind, SIGNAL(activated(
int)), SLOT(slotEnableCaps(
int)));
95 void KgpgKeyGenerate::slotButtonClicked(
int button)
103 if (button == Cancel)
107 void KgpgKeyGenerate::slotOk()
109 if (m_kname->text().simplified().isEmpty())
111 KMessageBox::sorry(
this, i18n(
"You must give a name."));
115 if (m_kname->text().simplified().length() < 5)
117 KMessageBox::sorry(
this, i18n(
"The name must have at least 5 characters"));
121 if (m_kname->text().simplified().at(0).isDigit())
123 KMessageBox::sorry(
this, i18n(
"The name must not start with a digit"));
127 QString vmail = m_mail->text();
130 int result = KMessageBox::warningContinueCancel(
this, i18n(
"You are about to create a key with no email address"));
131 if (result != KMessageBox::Continue)
137 KMessageBox::sorry(
this, i18n(
"Email address not valid"));
145 void KgpgKeyGenerate::slotUser1()
151 void KgpgKeyGenerate::slotEnableDays(
const int state)
153 m_days->setDisabled(state == 0);
156 void KgpgKeyGenerate::slotEnableCaps(
const int state)
159 capabilities->setDisabled(state != 2);
162 void KgpgKeyGenerate::slotEnableOk()
164 enableButtonOk((m_kname->text().simplified().length() >= 5) &&
165 !m_kname->text().simplified().at(0).isDigit());
185 KgpgCore::KgpgSubKeyType ret;
187 if (!capabilities->isEnabled())
190 if (capAuth->isChecked())
192 if (capCert->isChecked())
194 if (capEncrypt->isChecked())
196 if (capSign->isChecked())
204 return m_keysize->currentText().toUInt();
209 switch (m_keyexp->currentIndex()) {
224 if (m_days->text().isEmpty())
226 return m_days->text().toUInt();
231 if (m_kname->text().isEmpty())
233 return m_kname->text();
238 if (m_mail->text().isEmpty())
240 return m_mail->text();
245 if (m_comment->text().isEmpty())
247 return m_comment->text();
250 #include "kgpgkeygenerate.moc"
KgpgKeyGenerate(QWidget *parent=0)
KgpgCore::KgpgSubKeyType caps() const
return the selected capabilities for the new key
KgpgCore::KgpgKeyAlgo algo() const
bool isExpertMode() const
QString toString(const KgpgKeyAlgo algorithm)