comparison 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
comparison
equal deleted inserted replaced
1292:87b3886aca69 1293:d2b32c75efcf
10 #include <QHBoxLayout> 10 #include <QHBoxLayout>
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 16
16 void CheckLessToolBtn::paintEvent(QPaintEvent * pe) { 17 void CheckLessToolBtn::paintEvent(QPaintEvent * pe) {
17 18
18 /* Hack to always paint the button as if it were 19 /* Hack to always paint the button as if it were
19 * not checked. */ 20 * not checked. */
53 setupGUI(); 54 setupGUI();
54 } 55 }
55 56
56 void CertificateItemWidget::setupGUI() 57 void CertificateItemWidget::setupGUI()
57 { 58 {
58 mLabel = new QLabel;
59
60 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); 59 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
61 60
62 const QString validity = tr("Validity: %1 until %2").arg( 61 const QString validity = tr("Validity: %1 until %2").arg(
63 QLocale::system().toString(mCertificate.validFrom().date(), QLocale::ShortFormat)).arg( 62 QLocale::system().toString(mCertificate.validFrom().date(), QLocale::ShortFormat)).arg(
64 QLocale::system().toString(mCertificate.validTo().date(), QLocale::ShortFormat)); 63 QLocale::system().toString(mCertificate.validTo().date(), QLocale::ShortFormat));
65 const QString fpstring = tr("Fingerprint (SHA1): <code>%1</code>").arg(mCertificate.fingerprint()); 64 const QString fpstring = tr("Fingerprint (SHA1): <code>%1</code>").arg(mCertificate.fingerprint());
65
66 QVBoxLayout *labelLayout = new QVBoxLayout;
67 QLabel *firstLabel = new QLabel(QString::fromLatin1("<big><b>%1</b></big> ").arg
68 (mCertificate.subjectCN()));
69
66 #ifdef Q_OS_WIN 70 #ifdef Q_OS_WIN
67 mLabel->setText(QString::fromLatin1("<big><b><a href=showUi>%1</a></b></big><br/>%2<br/>%3<br/>%4").arg 71 QHBoxLayout *firstLabelButtonLayout = new QHBoxLayout;
68 (mCertificate.subjectCN()).arg(mCertificate.subjectO()).arg(validity).arg 72 firstLabelButtonLayout->addWidget(firstLabel);
73 QPushButton *detailsBtn = new QPushButton;
74 detailsBtn->setIcon(QIcon(":/img/preferences-network_16.png")); // TODO
75 detailsBtn->setToolTip(tr("Open the Windows certificate information dialog."));
76
77 firstLabelButtonLayout->addWidget(detailsBtn);
78 firstLabelButtonLayout->addStretch(-1);
79 connect(detailsBtn, SIGNAL(clicked()), this, SLOT(showCertDlg()));
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
85 (mCertificate.subjectO()).arg(validity).arg
69 (fpstring)); 86 (fpstring));
70 #else
71 mLabel->setText(QString::fromLatin1("<big><b>%1</b></big><br/>%2<br/>%3<br/>%4").arg
72 (mCertificate.subjectCN()).arg(mCertificate.subjectO()).arg(validity).arg
73 (fpstring));
74 #endif
75 mLabel->setTextFormat(Qt::RichText);
76 87
77 mLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); 88 labelLayout->addWidget(secondLabel);
89 secondLabel->setTextFormat(Qt::RichText);
90 secondLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
78 91
79 mLabel->setTextInteractionFlags( 92 secondLabel->setTextInteractionFlags(
80 Qt::LinksAccessibleByMouse |
81 Qt::LinksAccessibleByKeyboard |
82 Qt::TextSelectableByMouse | 93 Qt::TextSelectableByMouse |
83 Qt::TextSelectableByKeyboard); 94 Qt::TextSelectableByKeyboard);
84 connect(mLabel, SIGNAL(linkActivated(const QString&)), this, SLOT(showCertDlg())); 95 firstLabel->setTextFormat(Qt::RichText);
96 firstLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
97
98 firstLabel->setTextInteractionFlags(
99 Qt::TextSelectableByMouse |
100 Qt::TextSelectableByKeyboard);
85 mButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); 101 mButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
86 connect(mButton, SIGNAL(toggled (bool)), 102 connect(mButton, SIGNAL(toggled (bool)),
87 this, SLOT(currentStateChanged(bool))); 103 this, SLOT(currentStateChanged(bool)));
88 104
89 QHBoxLayout *layout = new QHBoxLayout; 105 QHBoxLayout *layout = new QHBoxLayout;
90 layout->addWidget(mButton); 106 layout->addWidget(mButton);
91 mButton->setFixedSize(64, 64); 107 mButton->setFixedSize(64, 64);
92 mButton->setIconSize(QSize(48, 48)); 108 mButton->setIconSize(QSize(48, 48));
93 layout->addWidget(mLabel); 109 layout->addLayout(labelLayout);
94 this->setLayout(layout); 110 this->setLayout(layout);
95 } 111 }
96 112
97 void CertificateItemWidget::showCertDlg() 113 void CertificateItemWidget::showCertDlg()
98 { 114 {

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