diff ui/certificateitemwidget.cpp @ 1288:265583011f24

(issue123) Add possibility to open native certificate dialog This is currently only implemented for windows.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 29 Sep 2014 13:12:58 +0200
parents ad4fc3649ffb
children d2b32c75efcf
line wrap: on
line diff
--- a/ui/certificateitemwidget.cpp	Mon Sep 29 13:02:41 2014 +0200
+++ b/ui/certificateitemwidget.cpp	Mon Sep 29 13:12:58 2014 +0200
@@ -63,16 +63,25 @@
             QLocale::system().toString(mCertificate.validFrom().date(), QLocale::ShortFormat)).arg(
             QLocale::system().toString(mCertificate.validTo().date(), QLocale::ShortFormat));
     const QString fpstring = tr("Fingerprint (SHA1): <code>%1</code>").arg(mCertificate.fingerprint());
+#ifdef Q_OS_WIN
+    mLabel->setText(QString::fromLatin1("<big><b><a href=showUi>%1</a></b></big><br/>%2<br/>%3<br/>%4").arg
+        (mCertificate.subjectCN()).arg(mCertificate.subjectO()).arg(validity).arg
+        (fpstring));
+#else
     mLabel->setText(QString::fromLatin1("<big><b>%1</b></big><br/>%2<br/>%3<br/>%4").arg
         (mCertificate.subjectCN()).arg(mCertificate.subjectO()).arg(validity).arg
         (fpstring));
+#endif
     mLabel->setTextFormat(Qt::RichText);
 
     mLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
 
     mLabel->setTextInteractionFlags(
+        Qt::LinksAccessibleByMouse |
+        Qt::LinksAccessibleByKeyboard |
         Qt::TextSelectableByMouse |
         Qt::TextSelectableByKeyboard);
+    connect(mLabel, SIGNAL(linkActivated(const QString&)), this, SLOT(showCertDlg()));
     mButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
     connect(mButton, SIGNAL(toggled (bool)),
         this, SLOT(currentStateChanged(bool)));
@@ -85,6 +94,14 @@
     this->setLayout(layout);
 }
 
+void CertificateItemWidget::showCertDlg()
+{
+    /* This is a totally evil cast but legitimate on Windows
+     * HANDLES are only 32 bit even on Windows 64 bit */
+    qDebug() << "Showing native ui: " <<  mCertificate.showNativeUI((void*)effectiveWinId());
+    return;
+}
+
 bool CertificateItemWidget::state()
 {
     if (!mButton->isEnabled()) {

http://wald.intevation.org/projects/trustbridge/