diff ui/mainwindow.cpp @ 1106:6f7b7d88f048

(issue115) Rework CertificateListWidgets to have a ToolButton instead of a combobox
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 15 Sep 2014 17:43:56 +0200
parents a7a72353d6d2
children 51d3b361f17a
line wrap: on
line diff
--- a/ui/mainwindow.cpp	Mon Sep 15 17:43:02 2014 +0200
+++ b/ui/mainwindow.cpp	Mon Sep 15 17:43:56 2014 +0200
@@ -1131,11 +1131,30 @@
             bool state = !mPreviouslyUnselected.contains(cert.base64Line());
             if (cert.isInstallCert()) {
                 oldInstallCerts.append(cert);
-                mInstallList->addCertificate(cert, state);
+                QToolButton* actionBtn = new QToolButton();
+                QIcon btnIcon;
+                if (!state) {
+                    btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
+                    btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On);
+                } else {
+                    btnIcon.addFile(":/img/security-high.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
+                    btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
+                }
+                actionBtn->setIcon(btnIcon);
+                mInstallList->addCertificate(cert, state, actionBtn);
             }
             else {
                 oldRemoveCerts.append(cert);
-                mRemoveList->addCertificate(cert, state, !state);
+                QToolButton* actionBtn = new QToolButton();
+                QIcon btnIcon;
+                btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
+                btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On);
+                btnIcon.addFile(":/img/trash-empty.png", QSize(48, 48), QIcon::Disabled, QIcon::Off);
+                actionBtn->setIcon(btnIcon);
+                if (state) {
+                    actionBtn->setEnabled(false);
+                }
+                mRemoveList->addCertificate(cert, state, actionBtn);
             }
         }
     }
@@ -1148,13 +1167,22 @@
                 if (mInstalledList.getCertificates().contains(cert)) {
                     // Was in the old list.
                     oldInstallCerts.append(cert);
-                    mInstallList->addCertificate(cert, state);
+                    QToolButton* actionBtn = new QToolButton();
+                    QIcon btnIcon;
+                    btnIcon.addFile(":/img/security-high.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
+                    btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On);
+                    actionBtn->setIcon(btnIcon);
+                    mInstallList->addCertificate(cert, state, actionBtn);
                 }
                 else {
                     // Is a brand new certificate
                     newInstallCerts.append(cert);
-                    mUpdatesNew->addCertificate(cert, state, true,
-                            tr("install"), tr("ignore"));
+                    QToolButton* actionBtn = new QToolButton();
+                    QIcon btnIcon;
+                    btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
+                    btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On);
+                    actionBtn->setIcon(btnIcon);
+                    mUpdatesNew->addCertificate(cert, state, actionBtn);
                 }
             }
             else {
@@ -1163,13 +1191,27 @@
                     // Was in the old list.
                     oldRemoveCerts.append(cert);
                     // Is removed, so set editable to false.
-                    mRemoveList->addCertificate(cert, state, !state);
+                    QToolButton* actionBtn = new QToolButton();
+                    QIcon btnIcon;
+                    btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
+                    btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On);
+                    btnIcon.addFile(":/img/trash-empty.png", QSize(48, 48), QIcon::Disabled, QIcon::Off);
+                    actionBtn->setIcon(btnIcon);
+                    if (state) {
+                        actionBtn->setEnabled(false);
+                    }
+                    mRemoveList->addCertificate(cert, state, actionBtn);
                 }
                 else {
                     // Was in the old list with status "install" and now has the
                     // status "remove".
                     newRemoveCerts.append(cert);
-                    mUpdatesRemove->addCertificate(cert, state);
+                    QToolButton* actionBtn = new QToolButton();
+                    QIcon btnIcon;
+                    btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
+                    btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On);
+                    actionBtn->setIcon(btnIcon);
+                    mUpdatesRemove->addCertificate(cert, state, actionBtn);
                 }
             }
         }
@@ -1338,7 +1380,17 @@
 void MainWindow::toggleInManual(bool state, const Certificate &cert)
 {
     if (!mUpdatesManual->contains(cert)) {
-        mUpdatesManual->addCertificate(cert, state);
+        QToolButton* actionBtn = new QToolButton();
+        QIcon btnIcon;
+        if (cert.isInstallCert()) {
+            btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
+            btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
+        } else {
+            btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
+            btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
+        }
+        actionBtn->setIcon(btnIcon);
+        mUpdatesManual->addCertificate(cert, state, actionBtn);
     }
     else {
         if (cert.isActive()) {

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