[PATCH 3 of 3] (issue123) Change layout from link to a button
Wald Commits
scm-commit at wald.intevation.org
Mon Sep 29 15:21:01 CEST 2014
# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1411996819 -7200
# Node ID d2b32c75efcf57fe5cbc791705dad8f599ac744a
# Parent 87b3886aca699d5d5af5f42fd61e83e3684eff47
(issue123) Change layout from link to a button
diff -r 87b3886aca69 -r d2b32c75efcf ui/certificateitemwidget.cpp
--- 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
+ 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
+ labelLayout->addWidget(firstLabel);
+#endif
+ QLabel *secondLabel = new QLabel(QString::fromLatin1("%2<br/>%3<br/>%4").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);
+ 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);
}
diff -r 87b3886aca69 -r d2b32c75efcf ui/certificateitemwidget.h
--- a/ui/certificateitemwidget.h Mon Sep 29 14:22:23 2014 +0200
+++ b/ui/certificateitemwidget.h Mon Sep 29 15:20:19 2014 +0200
@@ -62,7 +62,6 @@
Certificate mCertificate;
bool mOriginalState;
- QLabel *mLabel;
QToolButton *mButton;
private slots:
More information about the Trustbridge-commits
mailing list