comparison ui/mainwindow.cpp @ 282:d13d51f7a0e2

Merged
author Sascha Wilde <wilde@intevation.de>
date Wed, 02 Apr 2014 15:22:33 +0200
parents 90432cb1f374
children 75f7288ad67b
comparison
equal deleted inserted replaced
281:0f73fe4230c1 282:d13d51f7a0e2
10 #include <QFile> 10 #include <QFile>
11 #include <QTimer> 11 #include <QTimer>
12 #include <QHBoxLayout> 12 #include <QHBoxLayout>
13 #include <QVBoxLayout> 13 #include <QVBoxLayout>
14 #include <QGroupBox> 14 #include <QGroupBox>
15 #include <QPushButton>
16 #include <QSplitter> 15 #include <QSplitter>
17 #include <QLabel> 16 #include <QLabel>
18 #include <QImage> 17 #include <QImage>
19 #include <QCheckBox> 18 #include <QCheckBox>
20 19
31 #include "listupdatedialog.h" 30 #include "listupdatedialog.h"
32 #include "helpdialog.h" 31 #include "helpdialog.h"
33 #include "aboutdialog.h" 32 #include "aboutdialog.h"
34 #include "statusdialog.h" 33 #include "statusdialog.h"
35 #include "certificateitemdelegate.h" 34 #include "certificateitemdelegate.h"
35 #include "separatoritemdelegate.h"
36 36
37 MainWindow::MainWindow() { 37 MainWindow::MainWindow() {
38 createActions(); 38 createActions();
39 createTrayIcon(); 39 createTrayIcon();
40 createMenuBar(); 40 createMenuBar();
237 237
238 // Layouts and Container 238 // Layouts and Container
239 QHBoxLayout *mainLayout = new QHBoxLayout; 239 QHBoxLayout *mainLayout = new QHBoxLayout;
240 QVBoxLayout *infoLayout = new QVBoxLayout; 240 QVBoxLayout *infoLayout = new QVBoxLayout;
241 QVBoxLayout *certLayout = new QVBoxLayout; 241 QVBoxLayout *certLayout = new QVBoxLayout;
242 QVBoxLayout *detailLayout = new QVBoxLayout;
242 QHBoxLayout *headerLayout = new QHBoxLayout; 243 QHBoxLayout *headerLayout = new QHBoxLayout;
243 QVBoxLayout *headerTextLayout = new QVBoxLayout; 244 QVBoxLayout *headerTextLayout = new QVBoxLayout;
244 QVBoxLayout *toolLayout = new QVBoxLayout; 245 QVBoxLayout *toolLayout = new QVBoxLayout;
245 QHBoxLayout *toolButtonLayout = new QHBoxLayout; 246 QHBoxLayout *bottomLayout = new QHBoxLayout;
246 247
247 // The certificate list 248 // The certificate list
248 QGroupBox *certBox = new QGroupBox(tr("Managed Certificates")); 249 QGroupBox *certBox = new QGroupBox(tr("Managed Certificates"));
249 certificateList = new QListWidget; 250 certificateList = new QListWidget;
250 certificateList->setItemDelegate(new CertificateItemDelegate); 251 certificateList->setItemDelegate(new CertificateItemDelegate);
265 headerLayout->addWidget(logo); 266 headerLayout->addWidget(logo);
266 headerLayout->addLayout(headerTextLayout); 267 headerLayout->addLayout(headerTextLayout);
267 headerLayout->setStretch(0, 0); 268 headerLayout->setStretch(0, 0);
268 headerLayout->setStretch(1, 10); 269 headerLayout->setStretch(1, 10);
269 270
270 // The tools to update the certificate list/software and install 271 // The settings.
271 // certificates.
272 QCheckBox *autoUpdateOption = new QCheckBox(tr("autoupdate")); 272 QCheckBox *autoUpdateOption = new QCheckBox(tr("autoupdate"));
273 toolLayout->addWidget(autoUpdateOption); 273 toolLayout->addWidget(autoUpdateOption);
274 // connect(autoUpdateOption, SIGNAL(stateChanged()), this, SLOT(setAutoUpdate())); 274 // connect(autoUpdateOption, SIGNAL(stateChanged()), this, SLOT(setAutoUpdate()));
275 QPushButton *update = new QPushButton(tr("Search for Updates")); 275
276 connect(update, SIGNAL(clicked()), this, SLOT(checkUpdates())); 276 // The buttons.
277 QPushButton *install = new QPushButton(tr("Install selected")); 277 bottomLayout->setAlignment(Qt::AlignBottom);
278 // connect(update, SIGNAL(clicked()), this, SLOT(installCertificates())); 278 installButton = new QPushButton(tr("Install selected"));
279 toolButtonLayout->addWidget(update); 279 installButton->setFixedHeight(80);
280 toolButtonLayout->addWidget(install); 280 connect(installButton, SIGNAL(clicked()), this, SLOT(resizeButtons()));
281 toolButtonLayout->insertStretch(2, 10); 281 quitButton = new QPushButton(tr("Quit"));
282 toolLayout->addLayout(toolButtonLayout); 282 quitButton->setFixedHeight(20);
283 connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
284 bottomLayout->insertStretch(0, 10);
285 bottomLayout->addWidget(installButton);
286 bottomLayout->setAlignment(installButton, Qt::AlignBottom);
287 bottomLayout->addWidget(quitButton);
288 bottomLayout->setAlignment(quitButton, Qt::AlignBottom);
283 289
284 // The certificate details 290 // The certificate details
291 QGroupBox *detailBox = new QGroupBox(tr("Details"));
285 certificateDetails = new QTextEdit; 292 certificateDetails = new QTextEdit;
286 certificateDetails->setReadOnly(true); 293 certificateDetails->setReadOnly(true);
294 detailLayout->addWidget(certificateDetails);
295 detailBox->setLayout(detailLayout);
287 296
288 infoLayout->addSpacing(20); 297 infoLayout->addSpacing(20);
289 infoLayout->addLayout(headerLayout); 298 infoLayout->addLayout(headerLayout);
290 infoLayout->addLayout(toolLayout); 299 infoLayout->addLayout(toolLayout);
291 infoLayout->addWidget(certificateDetails); 300 infoLayout->addWidget(detailBox);
301 infoLayout->addLayout(bottomLayout);
292 302
293 mainLayout->addWidget(certBox); 303 mainLayout->addWidget(certBox);
294 mainLayout->addLayout(infoLayout); 304 mainLayout->addLayout(infoLayout);
295 305
296 306
309 if (!cert.isValid()) { 319 if (!cert.isValid()) {
310 qWarning() << "Invalid certificate in list"; 320 qWarning() << "Invalid certificate in list";
311 continue; 321 continue;
312 } 322 }
313 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); 323 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
324 SeparatorItemDelegate *separator = new SeparatorItemDelegate();
314 item->setData(Qt::UserRole, cert.details()); 325 item->setData(Qt::UserRole, cert.details());
315 if (cert.isInstallCert()) { 326 if (cert.isInstallCert()) {
316 // This if statements is for testing! @TODO Remove this! 327 // This if statements is for testing! @TODO Remove this!
317 if (i <= 2) { 328 if (i <= 2) {
318 item->setData(Qt::UserRole + 1, Certificate::InstallOld); 329 item->setData(Qt::UserRole + 1, Certificate::InstallOld);
321 } 332 }
322 else { 333 else {
323 item->setData(Qt::UserRole + 1, Certificate::InstallNew); 334 item->setData(Qt::UserRole + 1, Certificate::InstallNew);
324 item->setFlags(item->flags() | Qt::ItemIsUserCheckable); 335 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
325 item->setCheckState(Qt::Checked); 336 item->setCheckState(Qt::Checked);
337 }
338 if (i == 3) {
339 QListWidgetItem *sep = new QListWidgetItem("New certificates");
340 certificateList->setItemDelegateForRow(i, separator);
341 certificateList->addItem(sep);
342 i++;
326 } 343 }
327 } 344 }
328 else { 345 else {
329 // This if statements is for testing! @TODO Remove this! 346 // This if statements is for testing! @TODO Remove this!
330 if (i > 35) { 347 if (i > 35) {
373 qDebug() << "show details"; 390 qDebug() << "show details";
374 QString details = item->data(Qt::UserRole).toString(); 391 QString details = item->data(Qt::UserRole).toString();
375 details.append("\rInstalled: 1.1.1971\rRemoved: 1.1.1971"); 392 details.append("\rInstalled: 1.1.1971\rRemoved: 1.1.1971");
376 certificateDetails->setPlainText(details); 393 certificateDetails->setPlainText(details);
377 } 394 }
395
396 void MainWindow::resizeButtons()
397 {
398 installButton->setFixedHeight(20);
399 quitButton->setFixedHeight(80);
400 }

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