Mercurial > trustbridge
diff ui/mainwindow.cpp @ 1109:6594e8e63a25
(issue115) Add tooltips and fix manual changes handling
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 15 Sep 2014 19:02:17 +0200 |
parents | 51d3b361f17a |
children | b6cb4fd7ee20 |
line wrap: on
line diff
--- a/ui/mainwindow.cpp Mon Sep 15 17:47:12 2014 +0200 +++ b/ui/mainwindow.cpp Mon Sep 15 19:02:17 2014 +0200 @@ -93,8 +93,21 @@ #define HELP_PATH "/../share/doc/trustbridge/index.html" #endif +#define NEW_INSTALL_TT "Certificate will be installed." +#define NOT_INSTALL_TT "Certificate will not be installed." +#define NEW_REMOVE_TT "Certificate will be removed." +#define NOT_REMOVE_TT "Certificate will not be removed." +#define IS_INSTALLED_TT "Certificate is installed." +#define IS_NOT_INSTALLED_TT "Certifcate is not installed." +#define IS_REMOVED_TT "Certificate has been removed." +#define IS_NOT_REMOVED_TT "Certificate has not been removed." + +static void activateDetailsButton(QPushButton *); +static void deactivateDetailsButton(QPushButton *); + MainWindow::MainWindow(bool trayMode): - mTrayMode(trayMode) + mTrayMode(trayMode), + mManualDetailsShown(false) { createActions(); createTrayIcon(); @@ -1039,14 +1052,18 @@ if (mUpdatesManual->certificates().size()) { mUpdatesDetailsManual->show(); - mUpdatesDetailsManual->setIcon(QIcon(":/img/dialog-information_16px.png")); - mUpdatesDetailsManual->setToolTip(tr("Show details")); + if (mManualDetailsShown) { + mUpdatesManual->show(); + deactivateDetailsButton(mUpdatesDetailsManual); + } else { + activateDetailsButton(mUpdatesDetailsManual); + } } else { mUpdatesDetailsManual->hide(); mUpdatesManual->hide(); } mUpdatesManualCertificates->setText("<h2>" + - tr("Manual changes (%1)").arg(mUpdatesManual->activeCertificates()) + + tr("Manual changes (%1)").arg(mUpdatesManual->certificates().size()) + "</h2>"); if (mUpdatesNew->certificates().size()) { @@ -1136,7 +1153,11 @@ 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); + actionBtn->setProperty("ToolTip_Off", tr(NEW_INSTALL_TT)); + actionBtn->setProperty("ToolTip_On", tr(IS_NOT_INSTALLED_TT)); } else { + actionBtn->setProperty("ToolTip_Off", tr(IS_INSTALLED_TT)); + actionBtn->setProperty("ToolTip_On", tr(NEW_REMOVE_TT)); 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); } @@ -1147,12 +1168,15 @@ oldRemoveCerts.append(cert); QToolButton* actionBtn = new QToolButton(); QIcon btnIcon; + actionBtn->setProperty("ToolTip_Off", tr(NEW_REMOVE_TT)); + actionBtn->setProperty("ToolTip_On", tr(IS_NOT_REMOVED_TT)); 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); + actionBtn->setToolTip(tr(IS_REMOVED_TT)); } mRemoveList->addCertificate(cert, state, actionBtn); } @@ -1169,6 +1193,8 @@ oldInstallCerts.append(cert); QToolButton* actionBtn = new QToolButton(); QIcon btnIcon; + actionBtn->setProperty("ToolTip_Off", tr(IS_INSTALLED_TT)); + actionBtn->setProperty("ToolTip_On", tr(IS_NOT_INSTALLED_TT)); 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); @@ -1179,6 +1205,8 @@ newInstallCerts.append(cert); QToolButton* actionBtn = new QToolButton(); QIcon btnIcon; + actionBtn->setProperty("ToolTip_Off", tr(NEW_INSTALL_TT)); + actionBtn->setProperty("ToolTip_On", tr(NOT_INSTALL_TT)); 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); @@ -1193,12 +1221,15 @@ // Is removed, so set editable to false. QToolButton* actionBtn = new QToolButton(); QIcon btnIcon; + actionBtn->setProperty("ToolTip_Off", tr(NEW_REMOVE_TT)); + actionBtn->setProperty("ToolTip_On", tr(IS_NOT_REMOVED_TT)); 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); + actionBtn->setToolTip(tr(IS_REMOVED_TT)); } mRemoveList->addCertificate(cert, state, actionBtn); } @@ -1208,6 +1239,8 @@ newRemoveCerts.append(cert); QToolButton* actionBtn = new QToolButton(); QIcon btnIcon; + actionBtn->setProperty("ToolTip_Off", tr(NEW_REMOVE_TT)); + actionBtn->setProperty("ToolTip_On", tr(NOT_REMOVE_TT)); 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); @@ -1382,13 +1415,10 @@ if (!mUpdatesManual->contains(cert)) { 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); - } + 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->setProperty("ToolTip_On", tr(NEW_INSTALL_TT)); + actionBtn->setProperty("ToolTip_Off", tr(NEW_REMOVE_TT)); actionBtn->setIcon(btnIcon); mUpdatesManual->addCertificate(cert, state, actionBtn); } @@ -1491,10 +1521,12 @@ void MainWindow::toggleUpdatesManual() { if (!mUpdatesManual->isVisible()) { mUpdatesManual->show(); + mManualDetailsShown = true; deactivateDetailsButton(mUpdatesDetailsManual); } else { mUpdatesManual->hide(); + mManualDetailsShown = false; activateDetailsButton(mUpdatesDetailsManual); } }