30 #include <KDatePicker>
32 #include <KMessageBox>
33 #include <KPushButton>
34 #include <KToolInvocation>
36 #include <QApplication>
38 #include <QFormLayout>
39 #include <QGridLayout>
41 #include <QHBoxLayout>
44 #include <QVBoxLayout>
46 using namespace KgpgCore;
50 m_text_w(new QLabel(this)),
51 m_color_w(new QLabel(this)),
55 m_text_w->setTextInteractionFlags(Qt::TextSelectableByMouse);
57 m_color_w->setLineWidth(1);
58 m_color_w->setFrameShape(QFrame::Box);
59 m_color_w->setAutoFillBackground(
true);
60 m_color_w->setMinimumWidth(64);
62 QHBoxLayout *layout =
new QHBoxLayout(
this);
63 layout->setSpacing(10);
65 layout->addWidget(m_text_w);
66 layout->addWidget(m_color_w);
93 void KgpgTrustLabel::change()
95 m_text_w->setText(m_text);
97 QPalette palette = m_color_w->palette();
98 palette.setColor(m_color_w->backgroundRole(), m_color);
99 m_color_w->setPalette(palette);
107 m_keywaschanged(false),
108 m_closewhendone(false)
110 Q_ASSERT(m_model != NULL);
111 Q_ASSERT(m_node != NULL);
115 setButtons(Ok | Apply | Cancel);
116 setDefaultButton(Ok);
118 enableButtonApply(
false);
120 m_email->setUnderline(
false);
123 formLayout_keyproperties->getWidgetPosition(tl_trust, &trustRow, NULL);
124 formLayout_keyproperties->setWidget(trustRow, QFormLayout::FieldRole, m_trust);
128 m_expirationbtn->hide();
134 connect(m_owtrust, SIGNAL(activated(
int)),
this, SLOT(slotChangeTrust(
int)));
135 connect(m_photoid, SIGNAL(activated(QString)),
this, SLOT(slotLoadPhoto(QString)));
136 connect(m_email, SIGNAL(leftClickedUrl(QString)),
this, SLOT(slotOpenUrl(QString)));
137 connect(
keychange, SIGNAL(done(
int)), SLOT(slotApplied(
int)));
138 connect(m_disable, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableKey(
bool)));
139 connect(m_expirationbtn, SIGNAL(clicked()),
this, SLOT(slotChangeDate()));
140 connect(m_password, SIGNAL(clicked()),
this, SLOT(slotChangePass()));
144 gr_fingerprint->setMinimumHeight(gr_fingerprint->height());
153 void KgpgKeyInfo::reloadNode()
155 const QString kid(m_node->
getId());
161 if (m_node != NULL) {
164 KMessageBox::error(
this, i18n(
"<qt>The requested key is not present in the keyring anymore.<br />Perhaps it was deleted by another application</qt>"), i18n(
"Key not found"));
165 m_keywaschanged =
false;
170 void KgpgKeyInfo::displayKey()
172 const QString name = m_node->
getName();
174 m_name->setText(QLatin1String(
"<qt><b>" ) + name + QLatin1String(
"</b></qt>" ));
176 const QString email = m_node->
getEmail();
177 if (email.isEmpty()) {
178 m_email->setText(i18nc(
"no email address",
"none"));
179 m_email->setUrl(QString());
180 m_email->setEnabled(
false);
182 m_email->setText(QLatin1String(
"<qt><b><" ) + email + QLatin1String(
"></b></qt>" ));
183 m_email->setUrl(QLatin1String(
"mailto:" ) + name + QLatin1Char(
'<' ) + email + QLatin1Char(
'>' ));
194 trust = m_model->
data(idx, Qt::AccessibleTextRole).toString();
195 trustcolor = m_model->
data(idx, Qt::BackgroundColorRole).value<QColor>();
201 m_id->setText(m_node->
getId().right(16));
203 m_algorithm->setWhatsThis(i18n(
"<qt>The left part is the algorithm used by the <b>signature</b> key. The right part is the algorithm used by the <b>encryption</b> key.</qt>"));
206 m_expiration->setText(i18nc(
"Unlimited key lifetime",
"Unlimited"));
211 m_length->setText(m_node->
getSize());
212 m_length->setWhatsThis(i18n(
"<qt>The left part is the size of the <b>signature</b> key. The right part is the size of the <b>encryption</b> key.</qt>"));
216 if (comment.isEmpty()) {
217 m_comment->setText(i18nc(
"no key comment",
"<em>none</em>"));
218 m_comment->setTextFormat(Qt::RichText);
220 m_comment->setText(comment);
221 m_comment->setTextFormat(Qt::PlainText);
227 m_owtrust->setCurrentIndex(1);
231 m_owtrust->setCurrentIndex(2);
235 m_owtrust->setCurrentIndex(3);
239 m_owtrust->setCurrentIndex(4);
244 m_owtrust->setCurrentIndex(0);
249 m_disable->setChecked(
true);
251 connect(m_node, SIGNAL(expanded()), SLOT(slotKeyExpanded()));
256 void KgpgKeyInfo::slotOpenUrl(
const QString &url)
const
258 KToolInvocation::invokeBrowser(url);
261 void KgpgKeyInfo::slotLoadPhoto(
const QString &uid)
265 QImage img = pixmap.toImage();
266 pixmap = QPixmap::fromImage(img.scaled(m_photo->width(), m_photo->height(), Qt::KeepAspectRatio));
267 m_photo->setPixmap(pixmap);
270 void KgpgKeyInfo::slotChangeDate()
273 if (dialog->exec() == QDialog::Accepted) {
280 void KgpgKeyInfo::slotDisableKey(
const bool &ison)
286 void KgpgKeyInfo::slotChangePass()
290 connect(cp, SIGNAL(done(
int)), SLOT(slotInfoPasswordChanged(
int)));
293 QApplication::setOverrideCursor(QCursor(Qt::BusyCursor));
296 void KgpgKeyInfo::slotInfoPasswordChanged(
int result)
298 sender()->deleteLater();
300 QApplication::restoreOverrideCursor();
304 KMessageBox::information(
this, i18n(
"Passphrase for the key was changed"));
307 KMessageBox::error(
this, i18n(
"Bad old passphrase, the passphrase for the key was not changed"), i18n(
"Could not change passphrase"));
312 KMessageBox::error(
this, i18n(
"KGpg was unable to change the passphrase."));
316 void KgpgKeyInfo::slotChangeTrust(
const int &newtrust)
322 void KgpgKeyInfo::setControlEnable(
const bool &b)
324 m_owtrust->setEnabled(b);
325 m_disable->setEnabled(b);
329 m_expirationbtn->setEnabled(b);
331 m_password->setEnabled(b);
334 QApplication::restoreOverrideCursor();
336 QApplication::setOverrideCursor(QCursor(Qt::BusyCursor));
343 m_closewhendone =
true;
346 setControlEnable(
false);
350 if (m_keywaschanged && m_node)
355 KDialog::slotButtonClicked(button);
359 void KgpgKeyInfo::slotApplied(
int result)
362 KMessageBox::error(
this, i18n(
"Changing key properties failed."), i18n(
"Key properties"));
364 m_keywaschanged =
true;
369 setControlEnable(
true);
375 void KgpgKeyInfo::slotKeyExpanded()
381 while ((uat = m_node->
getUid(i++)) != NULL) {
385 m_photoid->addItem(uat->
getId());
388 bool hasphoto = (m_photoid->count() > 0);
390 m_photoid->setVisible(hasphoto);
391 m_photoid->setEnabled(hasphoto);
393 slotLoadPhoto(m_photoid->currentText());
396 #include "keyinfodialog.moc"
bool wasChanged()
Checks if the cached values differ from those of the key.
You do not trust the key owner, keys signed by him are untrusted.
virtual QString getName() const
There is no doubt in this key owner. This level is used for your own secret keys. ...
const KGpgSignableNode * getUid(const unsigned int index) const
get the user id or user attribute with the given number
const KgpgCore::KgpgKey * getKey() const
Returns a reference to the key used in this object.
KgpgKeyOwnerTrust ownerTrust() const
You have a minimum level of trust in the key owner.
virtual QString getId() const
void refreshKey(const QString &id)
void setDisable(const bool &disable)
Cache new disable flag.
KgpgKeyAlgo algorithm() const
KgpgSubKeyType keytype() const
You believe the key owner does good checking. Keys signed by him are trusted by you, too.
set a new passphrase for a key pair
void start()
Start the operation.
void setText(const QString &text)
virtual QString getComment() const
A public key with or without corresponding secret key.
virtual KgpgCore::KgpgItemType getType() const =0
Returns the item type of this object.
void slotButtonClicked(int button)
void selfdestruct(const bool &applyChanges)
Tell the object to remove itself once all work is done.
key is disabled by user (not owner)
void setOwTrust(const KgpgCore::KgpgKeyOwnerTrust &trust)
Cache new owner trust.
void setExpiration(const QDateTime &date)
Cache new expiration date.
shows a dialog to choose expiry date
const QPixmap & getPixmap() const
QString toString(const KgpgKeyAlgo algorithm)
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
A class for changing several properties of a key at once.
Trust value undefined (e.g. not trust level set).
void keyNeedsRefresh(KGpgKeyNode *node)
KGpgRootNode * getRootNode() const
the user aborted the transaction
KGpgKeyNode * findKey(const QString &keyId)
Find a key node with the given id.
virtual QDateTime getExpiration() const
virtual QString getSize() const
Returns a string describing the size of this object.
bool isSecret() const
Return if this key has a private key.
KGpgUatNode * toUatNode()
virtual QString getId() const
KgpgTrustLabel(QWidget *parent=0, const QString &text=QString(), const QColor &color=QColor())
virtual QString getEmail() const
user attribute to a key (i.e. photo id)
bool apply()
Apply all cached changes to the key.
the passphrase was not correct
void setColor(const QColor &color)
QModelIndex nodeIndex(KGpgNode *node, const int column=0)
void expand()
read all subitems
virtual QDateTime getCreation() const
QString getBeautifiedFingerprint() const
Print the full key fingerprint with spaces inserted.
KgpgKeyAlgo encryptionAlgorithm() const
KGpgChangeKey * keychange
An object that may have KGpgSignNode children.
static QColor colorBad()
Get Color used for untrusted keys.