12 #include <QHBoxLayout>
17 #include <KApplication>
18 #include <KMessageBox>
28 setCaption(i18n(
"MD5 Checksum"));
29 setButtons(Apply | Close);
30 setDefaultButton(Close);
31 setButtonText(Apply, i18n(
"Compare MD5 with Clipboard"));
36 if (f.open(QIODevice::ReadOnly)) {
41 m_md5sum = QLatin1String( checkfile.hexDigest().constData() );
45 QLabel *firstlabel =
new QLabel(page);
46 firstlabel->setText(i18n(
"MD5 sum for <b>%1</b> is:", url.fileName()));
48 KLineEdit *md5lineedit =
new KLineEdit(m_md5sum, page);
49 md5lineedit->setReadOnly(
true);
51 m_led =
new KLed(QColor(80, 80, 80), KLed::Off, KLed::Sunken, KLed::Circular, page);
52 QSizePolicy policy(QSizePolicy::Fixed, QSizePolicy::Fixed);
53 policy.setVerticalStretch(0);
54 policy.setHorizontalStretch(0);
55 policy.setHeightForWidth(m_led->sizePolicy().hasHeightForWidth());
56 m_led->setSizePolicy(policy);
58 m_label =
new QLabel(page);
59 m_label->setText(i18n(
"<b>Unknown status</b>"));
61 QHBoxLayout *ledlayout =
new QHBoxLayout();
62 ledlayout->addWidget(m_led);
63 ledlayout->addWidget(m_label);
65 QVBoxLayout *dialoglayout =
new QVBoxLayout(page);
66 dialoglayout->setMargin(marginHint());
67 dialoglayout->setSpacing(spacingHint());
68 dialoglayout->addWidget(firstlabel);
69 dialoglayout->addWidget(md5lineedit);
70 dialoglayout->addLayout(ledlayout);
71 dialoglayout->addStretch();
75 connect(
this, SIGNAL(applyClicked()),
this, SLOT(
slotApply()));
80 QString text = KApplication::clipboard()->text().remove(QLatin1Char(
' ' ));
83 if (text.length() != m_md5sum.length())
84 KMessageBox::sorry(
this, i18n(
"Clipboard content is not a MD5 sum."));
88 m_label->setText(i18n(
"<b>Correct checksum</b>, file is ok."));
89 m_led->setColor(QColor(Qt::green));
94 m_label->setText(i18n(
"<b>Wrong checksum, <em>file corrupted</em></b>"));
95 m_led->setColor(QColor(Qt::red));
101 #include "kgpgmd5widget.moc"