comparison ui/certificateitemwidget.cpp @ 1297:c2fd36cd4093

(issue123) Use gcr-viewer to view certificate details on Linux
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 29 Sep 2014 16:24:05 +0200
parents d2b32c75efcf
children 9017c524e762
comparison
equal deleted inserted replaced
1296:13b56e9c7e7b 1297:c2fd36cd4093
11 #include <QDebug> 11 #include <QDebug>
12 #include <QStyleFactory> 12 #include <QStyleFactory>
13 #include <QToolButton> 13 #include <QToolButton>
14 #include <QSignalBlocker> 14 #include <QSignalBlocker>
15 #include <QPushButton> 15 #include <QPushButton>
16 #include <QMessageBox>
16 17
17 void CheckLessToolBtn::paintEvent(QPaintEvent * pe) { 18 void CheckLessToolBtn::paintEvent(QPaintEvent * pe) {
18 19
19 /* Hack to always paint the button as if it were 20 /* Hack to always paint the button as if it were
20 * not checked. */ 21 * not checked. */
65 66
66 QVBoxLayout *labelLayout = new QVBoxLayout; 67 QVBoxLayout *labelLayout = new QVBoxLayout;
67 QLabel *firstLabel = new QLabel(QString::fromLatin1("<big><b>%1</b></big> ").arg 68 QLabel *firstLabel = new QLabel(QString::fromLatin1("<big><b>%1</b></big> ").arg
68 (mCertificate.subjectCN())); 69 (mCertificate.subjectCN()));
69 70
70 #ifdef Q_OS_WIN
71 QHBoxLayout *firstLabelButtonLayout = new QHBoxLayout; 71 QHBoxLayout *firstLabelButtonLayout = new QHBoxLayout;
72 firstLabelButtonLayout->addWidget(firstLabel); 72 firstLabelButtonLayout->addWidget(firstLabel);
73 QPushButton *detailsBtn = new QPushButton; 73 QPushButton *detailsBtn = new QPushButton;
74 detailsBtn->setIcon(QIcon(":/img/preferences-network_16.png")); // TODO 74 detailsBtn->setIcon(QIcon(":/img/preferences-network_16.png")); // TODO
75 detailsBtn->setToolTip(tr("Open the Windows certificate information dialog.")); 75 detailsBtn->setToolTip(tr("Open the Windows certificate information dialog."));
76 76
77 firstLabelButtonLayout->addWidget(detailsBtn); 77 firstLabelButtonLayout->addWidget(detailsBtn);
78 firstLabelButtonLayout->addStretch(-1); 78 firstLabelButtonLayout->addStretch(-1);
79 connect(detailsBtn, SIGNAL(clicked()), this, SLOT(showCertDlg())); 79 connect(detailsBtn, SIGNAL(clicked()), this, SLOT(showCertDlg()));
80 labelLayout->addLayout(firstLabelButtonLayout); 80 labelLayout->addLayout(firstLabelButtonLayout);
81 #else
82 labelLayout->addWidget(firstLabel);
83 #endif
84 QLabel *secondLabel = new QLabel(QString::fromLatin1("%2<br/>%3<br/>%4").arg 81 QLabel *secondLabel = new QLabel(QString::fromLatin1("%2<br/>%3<br/>%4").arg
85 (mCertificate.subjectO()).arg(validity).arg 82 (mCertificate.subjectO()).arg(validity).arg
86 (fpstring)); 83 (fpstring));
87 84
88 labelLayout->addWidget(secondLabel); 85 labelLayout->addWidget(secondLabel);
112 109
113 void CertificateItemWidget::showCertDlg() 110 void CertificateItemWidget::showCertDlg()
114 { 111 {
115 /* This is a totally evil cast but legitimate on Windows 112 /* This is a totally evil cast but legitimate on Windows
116 * HANDLES are only 32 bit even on Windows 64 bit */ 113 * HANDLES are only 32 bit even on Windows 64 bit */
117 qDebug() << "Showing native ui: " << mCertificate.showNativeUI((void*)effectiveWinId()); 114 if (!mCertificate.showNativeUI((void*)effectiveWinId())) {
115 qDebug() << "Failed to show native dialog";
116 #ifdef WIN32
117 // maybe old windows version
118 QMessageBox::warning(this, tr("TrustBridge error"), tr("Failed to open native viewer."));
119 #else
120 QMessageBox::warning(this, tr("TrustBridge error"), tr("Failed to open 'gcr-viewer'.") + "\n" +
121 tr("TrustBridge uses 'gcr-viewer' to show certificate details. Please ensure that 'gcr-viewer' is installed."));
122 #endif
123 }
118 return; 124 return;
119 } 125 }
120 126
121 bool CertificateItemWidget::state() 127 bool CertificateItemWidget::state()
122 { 128 {

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