diff ui/certificateitemwidget.cpp @ 1293:d2b32c75efcf

(issue123) Change layout from link to a button
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 29 Sep 2014 15:20:19 +0200
parents 265583011f24
children c2fd36cd4093
line wrap: on
line diff
--- a/ui/certificateitemwidget.cpp	Mon Sep 29 14:22:23 2014 +0200
+++ b/ui/certificateitemwidget.cpp	Mon Sep 29 15:20:19 2014 +0200
@@ -12,6 +12,7 @@
 #include <QStyleFactory>
 #include <QToolButton>
 #include <QSignalBlocker>
+#include <QPushButton>
 
 void CheckLessToolBtn::paintEvent(QPaintEvent * pe) {
 
@@ -55,33 +56,48 @@
 
 void CertificateItemWidget::setupGUI()
 {
-    mLabel = new QLabel;
-
     setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
 
     const QString validity = tr("Validity: %1 until %2").arg(
             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());
+
+    QVBoxLayout *labelLayout = new QVBoxLayout;
+    QLabel *firstLabel = new QLabel(QString::fromLatin1("<big><b>%1</b></big> ").arg
+        (mCertificate.subjectCN()));
+
 #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));
+    QHBoxLayout *firstLabelButtonLayout = new QHBoxLayout;
+    firstLabelButtonLayout->addWidget(firstLabel);
+    QPushButton *detailsBtn = new QPushButton;
+    detailsBtn->setIcon(QIcon(":/img/preferences-network_16.png")); // TODO
+    detailsBtn->setToolTip(tr("Open the Windows certificate information dialog."));
+
+    firstLabelButtonLayout->addWidget(detailsBtn);
+    firstLabelButtonLayout->addStretch(-1);
+    connect(detailsBtn, SIGNAL(clicked()), this, SLOT(showCertDlg()));
+    labelLayout->addLayout(firstLabelButtonLayout);
 #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
+    labelLayout->addWidget(firstLabel);
+#endif
+    QLabel *secondLabel = new QLabel(QString::fromLatin1("%2<br/>%3<br/>%4").arg
+        (mCertificate.subjectO()).arg(validity).arg
         (fpstring));
-#endif
-    mLabel->setTextFormat(Qt::RichText);
 
-    mLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+    labelLayout->addWidget(secondLabel);
+    secondLabel->setTextFormat(Qt::RichText);
+    secondLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
 
-    mLabel->setTextInteractionFlags(
-        Qt::LinksAccessibleByMouse |
-        Qt::LinksAccessibleByKeyboard |
+    secondLabel->setTextInteractionFlags(
         Qt::TextSelectableByMouse |
         Qt::TextSelectableByKeyboard);
-    connect(mLabel, SIGNAL(linkActivated(const QString&)), this, SLOT(showCertDlg()));
+    firstLabel->setTextFormat(Qt::RichText);
+    firstLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+
+    firstLabel->setTextInteractionFlags(
+        Qt::TextSelectableByMouse |
+        Qt::TextSelectableByKeyboard);
     mButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
     connect(mButton, SIGNAL(toggled (bool)),
         this, SLOT(currentStateChanged(bool)));
@@ -90,7 +106,7 @@
     layout->addWidget(mButton);
     mButton->setFixedSize(64, 64);
     mButton->setIconSize(QSize(48, 48));
-    layout->addWidget(mLabel);
+    layout->addLayout(labelLayout);
     this->setLayout(layout);
 }
 

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