comparison 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
comparison
equal deleted inserted replaced
1108:9bb9932bb819 1109:6594e8e63a25
91 #define HELP_PATH "/doc/index.html" 91 #define HELP_PATH "/doc/index.html"
92 #else 92 #else
93 #define HELP_PATH "/../share/doc/trustbridge/index.html" 93 #define HELP_PATH "/../share/doc/trustbridge/index.html"
94 #endif 94 #endif
95 95
96 #define NEW_INSTALL_TT "Certificate will be installed."
97 #define NOT_INSTALL_TT "Certificate will not be installed."
98 #define NEW_REMOVE_TT "Certificate will be removed."
99 #define NOT_REMOVE_TT "Certificate will not be removed."
100 #define IS_INSTALLED_TT "Certificate is installed."
101 #define IS_NOT_INSTALLED_TT "Certifcate is not installed."
102 #define IS_REMOVED_TT "Certificate has been removed."
103 #define IS_NOT_REMOVED_TT "Certificate has not been removed."
104
105 static void activateDetailsButton(QPushButton *);
106 static void deactivateDetailsButton(QPushButton *);
107
96 MainWindow::MainWindow(bool trayMode): 108 MainWindow::MainWindow(bool trayMode):
97 mTrayMode(trayMode) 109 mTrayMode(trayMode),
110 mManualDetailsShown(false)
98 { 111 {
99 createActions(); 112 createActions();
100 createTrayIcon(); 113 createTrayIcon();
101 setupGUI(); 114 setupGUI();
102 resize(900, 600); 115 resize(900, 600);
1037 mInstallButton->setText(" " + tr("Apply changes")); 1050 mInstallButton->setText(" " + tr("Apply changes"));
1038 } 1051 }
1039 1052
1040 if (mUpdatesManual->certificates().size()) { 1053 if (mUpdatesManual->certificates().size()) {
1041 mUpdatesDetailsManual->show(); 1054 mUpdatesDetailsManual->show();
1042 mUpdatesDetailsManual->setIcon(QIcon(":/img/dialog-information_16px.png")); 1055 if (mManualDetailsShown) {
1043 mUpdatesDetailsManual->setToolTip(tr("Show details")); 1056 mUpdatesManual->show();
1057 deactivateDetailsButton(mUpdatesDetailsManual);
1058 } else {
1059 activateDetailsButton(mUpdatesDetailsManual);
1060 }
1044 } else { 1061 } else {
1045 mUpdatesDetailsManual->hide(); 1062 mUpdatesDetailsManual->hide();
1046 mUpdatesManual->hide(); 1063 mUpdatesManual->hide();
1047 } 1064 }
1048 mUpdatesManualCertificates->setText("<h2>" + 1065 mUpdatesManualCertificates->setText("<h2>" +
1049 tr("Manual changes (%1)").arg(mUpdatesManual->activeCertificates()) + 1066 tr("Manual changes (%1)").arg(mUpdatesManual->certificates().size()) +
1050 "</h2>"); 1067 "</h2>");
1051 1068
1052 if (mUpdatesNew->certificates().size()) { 1069 if (mUpdatesNew->certificates().size()) {
1053 mUpdatesNewCertificates->setText("<h3>" + 1070 mUpdatesNewCertificates->setText("<h3>" +
1054 tr("Install new trusted certificates (%1/%2)") 1071 tr("Install new trusted certificates (%1/%2)")
1134 QToolButton* actionBtn = new QToolButton(); 1151 QToolButton* actionBtn = new QToolButton();
1135 QIcon btnIcon; 1152 QIcon btnIcon;
1136 if (!state) { 1153 if (!state) {
1137 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1154 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1138 btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1155 btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1156 actionBtn->setProperty("ToolTip_Off", tr(NEW_INSTALL_TT));
1157 actionBtn->setProperty("ToolTip_On", tr(IS_NOT_INSTALLED_TT));
1139 } else { 1158 } else {
1159 actionBtn->setProperty("ToolTip_Off", tr(IS_INSTALLED_TT));
1160 actionBtn->setProperty("ToolTip_On", tr(NEW_REMOVE_TT));
1140 btnIcon.addFile(":/img/security-high.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1161 btnIcon.addFile(":/img/security-high.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1141 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1162 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1142 } 1163 }
1143 actionBtn->setIcon(btnIcon); 1164 actionBtn->setIcon(btnIcon);
1144 mInstallList->addCertificate(cert, state, actionBtn); 1165 mInstallList->addCertificate(cert, state, actionBtn);
1145 } 1166 }
1146 else { 1167 else {
1147 oldRemoveCerts.append(cert); 1168 oldRemoveCerts.append(cert);
1148 QToolButton* actionBtn = new QToolButton(); 1169 QToolButton* actionBtn = new QToolButton();
1149 QIcon btnIcon; 1170 QIcon btnIcon;
1171 actionBtn->setProperty("ToolTip_Off", tr(NEW_REMOVE_TT));
1172 actionBtn->setProperty("ToolTip_On", tr(IS_NOT_REMOVED_TT));
1150 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1173 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1151 btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1174 btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1152 btnIcon.addFile(":/img/trash-empty.png", QSize(48, 48), QIcon::Disabled, QIcon::Off); 1175 btnIcon.addFile(":/img/trash-empty.png", QSize(48, 48), QIcon::Disabled, QIcon::Off);
1153 actionBtn->setIcon(btnIcon); 1176 actionBtn->setIcon(btnIcon);
1154 if (state) { 1177 if (state) {
1155 actionBtn->setEnabled(false); 1178 actionBtn->setEnabled(false);
1179 actionBtn->setToolTip(tr(IS_REMOVED_TT));
1156 } 1180 }
1157 mRemoveList->addCertificate(cert, state, actionBtn); 1181 mRemoveList->addCertificate(cert, state, actionBtn);
1158 } 1182 }
1159 } 1183 }
1160 } 1184 }
1167 if (mInstalledList.getCertificates().contains(cert)) { 1191 if (mInstalledList.getCertificates().contains(cert)) {
1168 // Was in the old list. 1192 // Was in the old list.
1169 oldInstallCerts.append(cert); 1193 oldInstallCerts.append(cert);
1170 QToolButton* actionBtn = new QToolButton(); 1194 QToolButton* actionBtn = new QToolButton();
1171 QIcon btnIcon; 1195 QIcon btnIcon;
1196 actionBtn->setProperty("ToolTip_Off", tr(IS_INSTALLED_TT));
1197 actionBtn->setProperty("ToolTip_On", tr(IS_NOT_INSTALLED_TT));
1172 btnIcon.addFile(":/img/security-high.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1198 btnIcon.addFile(":/img/security-high.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1173 btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1199 btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1174 actionBtn->setIcon(btnIcon); 1200 actionBtn->setIcon(btnIcon);
1175 mInstallList->addCertificate(cert, state, actionBtn); 1201 mInstallList->addCertificate(cert, state, actionBtn);
1176 } 1202 }
1177 else { 1203 else {
1178 // Is a brand new certificate 1204 // Is a brand new certificate
1179 newInstallCerts.append(cert); 1205 newInstallCerts.append(cert);
1180 QToolButton* actionBtn = new QToolButton(); 1206 QToolButton* actionBtn = new QToolButton();
1181 QIcon btnIcon; 1207 QIcon btnIcon;
1208 actionBtn->setProperty("ToolTip_Off", tr(NEW_INSTALL_TT));
1209 actionBtn->setProperty("ToolTip_On", tr(NOT_INSTALL_TT));
1182 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1210 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1183 btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1211 btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1184 actionBtn->setIcon(btnIcon); 1212 actionBtn->setIcon(btnIcon);
1185 mUpdatesNew->addCertificate(cert, state, actionBtn); 1213 mUpdatesNew->addCertificate(cert, state, actionBtn);
1186 } 1214 }
1191 // Was in the old list. 1219 // Was in the old list.
1192 oldRemoveCerts.append(cert); 1220 oldRemoveCerts.append(cert);
1193 // Is removed, so set editable to false. 1221 // Is removed, so set editable to false.
1194 QToolButton* actionBtn = new QToolButton(); 1222 QToolButton* actionBtn = new QToolButton();
1195 QIcon btnIcon; 1223 QIcon btnIcon;
1224 actionBtn->setProperty("ToolTip_Off", tr(NEW_REMOVE_TT));
1225 actionBtn->setProperty("ToolTip_On", tr(IS_NOT_REMOVED_TT));
1196 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1226 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1197 btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1227 btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1198 btnIcon.addFile(":/img/trash-empty.png", QSize(48, 48), QIcon::Disabled, QIcon::Off); 1228 btnIcon.addFile(":/img/trash-empty.png", QSize(48, 48), QIcon::Disabled, QIcon::Off);
1199 actionBtn->setIcon(btnIcon); 1229 actionBtn->setIcon(btnIcon);
1200 if (state) { 1230 if (state) {
1201 actionBtn->setEnabled(false); 1231 actionBtn->setEnabled(false);
1232 actionBtn->setToolTip(tr(IS_REMOVED_TT));
1202 } 1233 }
1203 mRemoveList->addCertificate(cert, state, actionBtn); 1234 mRemoveList->addCertificate(cert, state, actionBtn);
1204 } 1235 }
1205 else { 1236 else {
1206 // Was in the old list with status "install" and now has the 1237 // Was in the old list with status "install" and now has the
1207 // status "remove". 1238 // status "remove".
1208 newRemoveCerts.append(cert); 1239 newRemoveCerts.append(cert);
1209 QToolButton* actionBtn = new QToolButton(); 1240 QToolButton* actionBtn = new QToolButton();
1210 QIcon btnIcon; 1241 QIcon btnIcon;
1242 actionBtn->setProperty("ToolTip_Off", tr(NEW_REMOVE_TT));
1243 actionBtn->setProperty("ToolTip_On", tr(NOT_REMOVE_TT));
1211 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1244 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1212 btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1245 btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1213 actionBtn->setIcon(btnIcon); 1246 actionBtn->setIcon(btnIcon);
1214 mUpdatesRemove->addCertificate(cert, state, actionBtn); 1247 mUpdatesRemove->addCertificate(cert, state, actionBtn);
1215 } 1248 }
1380 void MainWindow::toggleInManual(bool state, const Certificate &cert) 1413 void MainWindow::toggleInManual(bool state, const Certificate &cert)
1381 { 1414 {
1382 if (!mUpdatesManual->contains(cert)) { 1415 if (!mUpdatesManual->contains(cert)) {
1383 QToolButton* actionBtn = new QToolButton(); 1416 QToolButton* actionBtn = new QToolButton();
1384 QIcon btnIcon; 1417 QIcon btnIcon;
1385 if (cert.isInstallCert()) { 1418 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1386 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1419 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1387 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1420 actionBtn->setProperty("ToolTip_On", tr(NEW_INSTALL_TT));
1388 } else { 1421 actionBtn->setProperty("ToolTip_Off", tr(NEW_REMOVE_TT));
1389 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1390 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1391 }
1392 actionBtn->setIcon(btnIcon); 1422 actionBtn->setIcon(btnIcon);
1393 mUpdatesManual->addCertificate(cert, state, actionBtn); 1423 mUpdatesManual->addCertificate(cert, state, actionBtn);
1394 } 1424 }
1395 else { 1425 else {
1396 mUpdatesManual->removeCertificate(cert); 1426 mUpdatesManual->removeCertificate(cert);
1489 } 1519 }
1490 1520
1491 void MainWindow::toggleUpdatesManual() { 1521 void MainWindow::toggleUpdatesManual() {
1492 if (!mUpdatesManual->isVisible()) { 1522 if (!mUpdatesManual->isVisible()) {
1493 mUpdatesManual->show(); 1523 mUpdatesManual->show();
1524 mManualDetailsShown = true;
1494 deactivateDetailsButton(mUpdatesDetailsManual); 1525 deactivateDetailsButton(mUpdatesDetailsManual);
1495 } 1526 }
1496 else { 1527 else {
1497 mUpdatesManual->hide(); 1528 mUpdatesManual->hide();
1529 mManualDetailsShown = false;
1498 activateDetailsButton(mUpdatesDetailsManual); 1530 activateDetailsButton(mUpdatesDetailsManual);
1499 } 1531 }
1500 } 1532 }
1501 1533
1502 void MainWindow::closeEvent(QCloseEvent *event) 1534 void MainWindow::closeEvent(QCloseEvent *event)

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