comparison ui/mainwindow.cpp @ 210:9c51c472e596

Some mainwindow layout improvements and new icons for certificate list.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 27 Mar 2014 09:04:16 +0100
parents a3f542bf38f7
children f7176140d20d
comparison
equal deleted inserted replaced
209:f84d9ad9bfa9 210:9c51c472e596
236 QHBoxLayout *bottomLayout = new QHBoxLayout; 236 QHBoxLayout *bottomLayout = new QHBoxLayout;
237 237
238 QImage *logoImage = new QImage(":/img/logo.png"); 238 QImage *logoImage = new QImage(":/img/logo.png");
239 QLabel *logo = new QLabel; 239 QLabel *logo = new QLabel;
240 logo->setBackgroundRole(QPalette::Base); 240 logo->setBackgroundRole(QPalette::Base);
241 logo->setScaledContents(true);
242 logo->setPixmap(QPixmap::fromImage(*logoImage)); 241 logo->setPixmap(QPixmap::fromImage(*logoImage));
243 QLabel *title = new QLabel("<h3>" + tr("Certificate Installer") + "</h3>"); 242 QLabel *title = new QLabel("<h2>" + tr("Certificate Installer") + "</h2>");
244 QLabel *subTitle = new QLabel("This Software installs and removes Certificates"); 243 QLabel *subTitle = new QLabel("This Software installs and removes Certificates");
245 headerTextLayout->addWidget(title); 244 headerTextLayout->addWidget(title);
246 headerTextLayout->addWidget(subTitle); 245 headerTextLayout->addWidget(subTitle);
247 headerLayout->addWidget(logo); 246 headerLayout->addWidget(logo);
248 headerLayout->addLayout(headerTextLayout); 247 headerLayout->addLayout(headerTextLayout);
248 headerLayout->setStretch(0, 0);
249 headerLayout->setStretch(1, 10);
249 250
250 QGroupBox *certBox = new QGroupBox(tr("Managed Certificates")); 251 QGroupBox *certBox = new QGroupBox(tr("Managed Certificates"));
251 certificateList = new QListWidget; 252 certificateList = new QListWidget;
252 connect(certificateList, SIGNAL(itemClicked(QListWidgetItem*)), 253 connect(certificateList, SIGNAL(itemClicked(QListWidgetItem*)),
253 this, SLOT(showDetails(QListWidgetItem*))); 254 this, SLOT(showDetails(QListWidgetItem*)));
264 bottomLayout->insertStretch(0, 10); 265 bottomLayout->insertStretch(0, 10);
265 bottomLayout->addWidget(update); 266 bottomLayout->addWidget(update);
266 mainLayout->addLayout(headerLayout); 267 mainLayout->addLayout(headerLayout);
267 mainLayout->addWidget(certBox); 268 mainLayout->addWidget(certBox);
268 mainLayout->addLayout(bottomLayout); 269 mainLayout->addLayout(bottomLayout);
270 mainLayout->setStretch(0, 0);
271 mainLayout->setStretch(1, 10);
269 272
270 // QMainWindow allready has a layout. All child layouts and widgets are 273 // QMainWindow allready has a layout. All child layouts and widgets are
271 // managed in the central widget. 274 // managed in the central widget.
272 base->setLayout(mainLayout); 275 base->setLayout(mainLayout);
273 setCentralWidget(base); 276 setCentralWidget(base);
282 qWarning() << "Invalid certificate in list"; 285 qWarning() << "Invalid certificate in list";
283 continue; 286 continue;
284 } 287 }
285 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); 288 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
286 item->setData(Qt::UserRole, cert.details()); 289 item->setData(Qt::UserRole, cert.details());
287 QIcon *certIcon = new QIcon(":/img/tray_22.png"); 290 QIcon *certIcon = new QIcon(":/img/list-add.png");
288 item->setIcon(*certIcon); 291 item->setIcon(*certIcon);
289 certificateList->addItem(item); 292 certificateList->addItem(item);
290 } 293 }
291 foreach (const Certificate& cert, mListToInstall.getRemoveCertificates()) { 294 foreach (const Certificate& cert, mListToInstall.getRemoveCertificates()) {
292 if (!cert.isValid()) { 295 if (!cert.isValid()) {
293 qWarning() << "Invalid certificate in list"; 296 qWarning() << "Invalid certificate in list";
294 continue; 297 continue;
295 } 298 }
296 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); 299 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
297 item->setData(Qt::UserRole, cert.details()); 300 item->setData(Qt::UserRole, cert.details());
298 QIcon *certIcon = new QIcon(":/img/tray_22.png"); 301 QIcon *certIcon = new QIcon(":/img/list-remove.png");
299 item->setIcon(*certIcon); 302 item->setIcon(*certIcon);
300 certificateList->addItem(item); 303 certificateList->addItem(item);
301 } 304 }
302 } 305 }
303 306
322 325
323 void MainWindow::showDetails(QListWidgetItem *item) 326 void MainWindow::showDetails(QListWidgetItem *item)
324 { 327 {
325 qDebug() << "show details"; 328 qDebug() << "show details";
326 QString details = item->data(Qt::UserRole).toString(); 329 QString details = item->data(Qt::UserRole).toString();
330 details.append("\rInstalled: 1.1.1971\rRemoved: 1.1.1971");
327 certificateDetails->setPlainText(details); 331 certificateDetails->setPlainText(details);
328 } 332 }

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