Mercurial > trustbridge
changeset 1234:ad4fc3649ffb
(issue146) Always draw certificate item buttons as unchecked
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 24 Sep 2014 16:25:27 +0200 |
parents | 7da9ec20eae4 |
children | 7e63b344ac06 |
files | ui/certificateitemwidget.cpp ui/certificateitemwidget.h ui/mainwindow.cpp |
diffstat | 3 files changed, 35 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/ui/certificateitemwidget.cpp Wed Sep 24 15:49:27 2014 +0200 +++ b/ui/certificateitemwidget.cpp Wed Sep 24 16:25:27 2014 +0200 @@ -11,6 +11,27 @@ #include <QDebug> #include <QStyleFactory> #include <QToolButton> +#include <QSignalBlocker> + +void CheckLessToolBtn::paintEvent(QPaintEvent * pe) { + + /* Hack to always paint the button as if it were + * not checked. */ + bool oldchecked = isChecked(); + QIcon oldIcon = icon(); + QIcon tmpIcon; + if (isEnabled()) + tmpIcon = QIcon(oldIcon.pixmap(QSize(48, 48), QIcon::Normal, oldchecked ? QIcon::On : QIcon::Off)); + else { + tmpIcon = QIcon(oldIcon.pixmap(QSize(48, 48), QIcon::Disabled, oldchecked ? QIcon::On : QIcon::Off)); + } + QSignalBlocker blk(this); + setChecked(false); + setIcon(tmpIcon); + QToolButton::paintEvent(pe); + setIcon(oldIcon); + setChecked(oldchecked); +} CertificateItemWidget::CertificateItemWidget(QWidget *parent, const Certificate &cert, @@ -22,12 +43,12 @@ mCertificate = cert; mOriginalState = state; btn->setCheckable(true); - btn->setStyleSheet("QToolButton:Checked{" +/* btn->setStyleSheet("QToolButton:Checked{" "border: 1px solid #8f8f91;" "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1," "stop: 0 #f6f7fa, stop: 1 #dadbde);" "}" - ); + );*/ setState(state); setupGUI(); }
--- a/ui/certificateitemwidget.h Wed Sep 24 15:49:27 2014 +0200 +++ b/ui/certificateitemwidget.h Wed Sep 24 16:25:27 2014 +0200 @@ -14,10 +14,14 @@ */ #include <QWidget> #include <QLabel> +#include <QToolButton> #include "certificate.h" -class QToolButton; +class CheckLessToolBtn : public QToolButton +{ + void paintEvent(QPaintEvent * pe); +}; class CertificateItemWidget : public QWidget {
--- a/ui/mainwindow.cpp Wed Sep 24 15:49:27 2014 +0200 +++ b/ui/mainwindow.cpp Wed Sep 24 16:25:27 2014 +0200 @@ -33,6 +33,7 @@ #include <QDesktopServices> #include "certificatelist.h" +#include "certificateitemwidget.h" #include "downloader.h" #include "helpdialog.h" #include "aboutdialog.h" @@ -1256,7 +1257,7 @@ bool state = !mPreviouslyUnselected.contains(cert.base64Line()); if (cert.isInstallCert()) { oldInstallCerts.append(cert); - QToolButton* actionBtn = new QToolButton(); + CheckLessToolBtn* actionBtn = new CheckLessToolBtn(); QIcon btnIcon; if (!state) { btnIcon.addFile(":/img/cert-to-be-installed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); @@ -1274,7 +1275,7 @@ } else { oldRemoveCerts.append(cert); - QToolButton* actionBtn = new QToolButton(); + CheckLessToolBtn* actionBtn = new CheckLessToolBtn(); QIcon btnIcon; actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed.")); actionBtn->setProperty("ToolTip_On", tr("Certificate has not been removed.")); @@ -1299,7 +1300,7 @@ if (mInstalledList.getCertificates().contains(cert)) { // Was in the old list. oldInstallCerts.append(cert); - QToolButton* actionBtn = new QToolButton(); + CheckLessToolBtn* actionBtn = new CheckLessToolBtn(); QIcon btnIcon; actionBtn->setProperty("ToolTip_Off", tr("Certificate is installed.")); actionBtn->setProperty("ToolTip_On", tr("Certifcate is not installed.")); @@ -1311,7 +1312,7 @@ else { // Is a brand new certificate newInstallCerts.append(cert); - QToolButton* actionBtn = new QToolButton(); + CheckLessToolBtn* actionBtn = new CheckLessToolBtn(); QIcon btnIcon; actionBtn->setProperty("ToolTip_Off", tr("Certificate will be installed.")); actionBtn->setProperty("ToolTip_On", tr("Certificate will not be installed.")); @@ -1327,7 +1328,7 @@ // Was in the old list. oldRemoveCerts.append(cert); // Is removed, so set editable to false. - QToolButton* actionBtn = new QToolButton(); + CheckLessToolBtn* actionBtn = new CheckLessToolBtn(); QIcon btnIcon; actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed.")); actionBtn->setProperty("ToolTip_On", tr("Certificate has not been removed.")); @@ -1345,7 +1346,7 @@ // Was in the old list with status "install" and now has the // status "remove". newRemoveCerts.append(cert); - QToolButton* actionBtn = new QToolButton(); + CheckLessToolBtn* actionBtn = new CheckLessToolBtn(); QIcon btnIcon; actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed.")); actionBtn->setProperty("ToolTip_On", tr("Certificate will not be removed."));