Mercurial > trustbridge
comparison ui/mainwindow.cpp @ 584:ebfe1128ee97 trustbridge-refactor
Started trustbridge mainwindow refactoring.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 27 May 2014 16:25:33 +0200 |
parents | aee3eb10bbba |
children | 3a9c0f38bbad |
comparison
equal
deleted
inserted
replaced
583:7d6026424f37 | 584:ebfe1128ee97 |
---|---|
24 #include <QGroupBox> | 24 #include <QGroupBox> |
25 #include <QSplitter> | 25 #include <QSplitter> |
26 #include <QLabel> | 26 #include <QLabel> |
27 #include <QImage> | 27 #include <QImage> |
28 #include <QCheckBox> | 28 #include <QCheckBox> |
29 #include <QButtonGroup> | |
30 #include <QToolButton> | |
29 | 31 |
30 // The amount of time in minutes stay silent if we have | 32 // The amount of time in minutes stay silent if we have |
31 // something to say | 33 // something to say |
32 #define NAG_INTERVAL_MINUTES 70 | 34 #define NAG_INTERVAL_MINUTES 70 |
33 | 35 |
57 MainWindow::MainWindow(bool trayMode): | 59 MainWindow::MainWindow(bool trayMode): |
58 mTrayMode(trayMode) | 60 mTrayMode(trayMode) |
59 { | 61 { |
60 createActions(); | 62 createActions(); |
61 createTrayIcon(); | 63 createTrayIcon(); |
62 createMenuBar(); | |
63 createContent(); | 64 createContent(); |
64 resize(950, 540); | 65 resize(950, 540); |
65 qRegisterMetaType<SSLConnection::ErrorCode>("SSLConnection::ErrorCode"); | 66 qRegisterMetaType<SSLConnection::ErrorCode>("SSLConnection::ErrorCode"); |
66 qRegisterMetaType<Certificate::Status>("Certificate::Status"); | 67 qRegisterMetaType<Certificate::Status>("Certificate::Status"); |
67 | 68 |
355 mTrayIcon->setToolTip(tr("TrustBridge")); | 356 mTrayIcon->setToolTip(tr("TrustBridge")); |
356 | 357 |
357 connect(mTrayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked())); | 358 connect(mTrayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked())); |
358 } | 359 } |
359 | 360 |
360 void MainWindow::createMenuBar() | |
361 { | |
362 mMenuBar = new QMenuBar(this); | |
363 QMenu *mMenu = new QMenu(tr("Menu"), mMenuBar); | |
364 mMenuBar->addMenu(mMenu); | |
365 QAction *update = mMenu->addAction(tr("Force Update")); | |
366 mMenu->addSeparator(); | |
367 QAction *help = mMenu->addAction(tr("Help")); | |
368 QAction *about = mMenu->addAction(tr("About")); | |
369 mMenu->addSeparator(); | |
370 QAction *quit = mMenu->addAction(tr("Quit")); | |
371 connect(update, SIGNAL(triggered()), this, SLOT(checkUpdates())); | |
372 connect(help, SIGNAL(triggered()), this, SLOT(showHelp())); | |
373 connect(about, SIGNAL(triggered()), this, SLOT(showAbout())); | |
374 connect(quit, SIGNAL(triggered()), this, SLOT(closeApp())); | |
375 setMenuBar(mMenuBar); | |
376 } | |
377 | |
378 void MainWindow::createContent() | 361 void MainWindow::createContent() |
379 { | 362 { |
380 // Create a central widget containing the main layout. | 363 // Create a central widget containing the main layout. |
381 QWidget *base = new QWidget; | 364 QWidget *base = new QWidget; |
382 | 365 |
383 // Layouts and Container | 366 // Layouts and Container |
384 QHBoxLayout *mainLayout = new QHBoxLayout; | 367 QVBoxLayout *mainLayout = new QVBoxLayout; |
385 QVBoxLayout *infoLayout = new QVBoxLayout; | |
386 QVBoxLayout *certLayout = new QVBoxLayout; | |
387 QHBoxLayout *detailLayout = new QHBoxLayout; | |
388 QVBoxLayout *detailLabelLayout = new QVBoxLayout; | |
389 QVBoxLayout *detailContentLayout = new QVBoxLayout; | |
390 QHBoxLayout *headerLayout = new QHBoxLayout; | 368 QHBoxLayout *headerLayout = new QHBoxLayout; |
391 QVBoxLayout *headerTextLayout = new QVBoxLayout; | 369 QVBoxLayout *headerTextLayout = new QVBoxLayout; |
370 QHBoxLayout *centerLayout = new QHBoxLayout; | |
371 QVBoxLayout *buttonBarLayout = new QVBoxLayout; | |
392 QHBoxLayout *bottomLayout = new QHBoxLayout; | 372 QHBoxLayout *bottomLayout = new QHBoxLayout; |
393 QVBoxLayout *settingsLayout = new QVBoxLayout; | 373 QHBoxLayout *containerLayout = new QHBoxLayout; |
394 QVBoxLayout *listInfoLayout = new QVBoxLayout; | 374 QVBoxLayout *updatesPanelLayout = new QVBoxLayout; |
395 | |
396 // The certificate list | |
397 QGroupBox *certBox = new QGroupBox(tr("Managed Certificates")); | |
398 mCertListWidget = new QListWidget; | |
399 connect(mCertListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), | |
400 this, SLOT(showDetails(QListWidgetItem*))); | |
401 certLayout->addWidget(mCertListWidget); | |
402 | |
403 mCurrentListDate = new QLabel(tr("Current List Date: %1").arg("")); | |
404 mNewListDate = new QLabel(""); | |
405 listInfoLayout->addWidget(mCurrentListDate); | |
406 listInfoLayout->addWidget(mNewListDate); | |
407 certLayout->addLayout(listInfoLayout); | |
408 | |
409 certBox->setLayout(certLayout); | |
410 | 375 |
411 // The header (icon, about text) | 376 // The header (icon, about text) |
412 QImage *logoImage = new QImage(":/img/logo.png"); | 377 QImage *logoImage = new QImage(":/img/logo.png"); |
413 QLabel *logo = new QLabel; | 378 QLabel *logo = new QLabel; |
414 logo->setBackgroundRole(QPalette::Base); | 379 logo->setBackgroundRole(QPalette::Base); |
415 logo->setPixmap(QPixmap::fromImage(*logoImage)); | 380 logo->setPixmap(QPixmap::fromImage(*logoImage)); |
416 QLabel *title = new QLabel("<h2>" + QString::fromLatin1(APPNAME) + "</h2>"); | 381 QLabel *title = new QLabel("<h1>" + QString::fromLatin1(APPNAME) + "</h1>"); |
417 QLabel *subTitle = new QLabel("This Software installs and removes Certificates"); | 382 QLabel *subTitle = new QLabel("This Software installs and removes Certificates"); |
418 headerTextLayout->addWidget(title); | 383 headerTextLayout->addWidget(title); |
419 headerTextLayout->addWidget(subTitle); | 384 headerTextLayout->addWidget(subTitle); |
420 headerLayout->addWidget(logo); | 385 headerLayout->addWidget(logo); |
421 headerLayout->addLayout(headerTextLayout); | 386 headerLayout->addLayout(headerTextLayout); |
422 headerLayout->setStretch(0, 0); | 387 headerLayout->setStretch(0, 0); |
423 headerLayout->setStretch(1, 10); | 388 headerLayout->setStretch(1, 10); |
389 | |
390 // Buttonbar | |
391 mButtonGroup = new QButtonGroup; | |
392 | |
393 QToolButton *updatesButton = new QToolButton; | |
394 updatesButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); | |
395 updatesButton->setIcon(QIcon(":/img/view-refresh.png")); | |
396 updatesButton->setIconSize(QSize(32, 32)); | |
397 updatesButton->setText(tr("Updates")); | |
398 updatesButton->setFixedWidth(90); | |
399 updatesButton->setFixedHeight(70); | |
400 updatesButton->setCheckable(true); | |
401 updatesButton->setChecked(true); | |
402 | |
403 QToolButton *allInstallButton = new QToolButton; | |
404 allInstallButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); | |
405 allInstallButton->setIcon(QIcon(":/img/document-encrypt.png")); | |
406 allInstallButton->setIconSize(QSize(32, 32)); | |
407 allInstallButton->setText(tr("Trusted\nCertificates")); | |
408 allInstallButton->setFixedWidth(90); | |
409 allInstallButton->setFixedHeight(70); | |
410 allInstallButton->setCheckable(true); | |
411 | |
412 QToolButton *allRemoveButton = new QToolButton; | |
413 allRemoveButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); | |
414 allRemoveButton->setIcon(QIcon(":/img/task-attempt.png")); | |
415 allRemoveButton->setIconSize(QSize(32, 32)); | |
416 allRemoveButton->setText(tr("Insecure\nCertificates")); | |
417 allRemoveButton->setFixedWidth(90); | |
418 allRemoveButton->setFixedHeight(70); | |
419 allRemoveButton->setCheckable(true); | |
420 | |
421 QToolButton *infoButton = new QToolButton; | |
422 infoButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); | |
423 infoButton->setIcon(QIcon(":/img/dialog-information.png")); | |
424 infoButton->setIconSize(QSize(32, 32)); | |
425 infoButton->setText(tr("Information")); | |
426 infoButton->setFixedWidth(90); | |
427 infoButton->setFixedHeight(70); | |
428 infoButton->setCheckable(true); | |
429 | |
430 mButtonGroup->addButton(updatesButton); | |
431 mButtonGroup->addButton(allInstallButton); | |
432 mButtonGroup->addButton(allRemoveButton); | |
433 mButtonGroup->addButton(infoButton); | |
434 mButtonGroup->setId(updatesButton, 0); | |
435 mButtonGroup->setId(allInstallButton, 1); | |
436 mButtonGroup->setId(allRemoveButton, 2); | |
437 mButtonGroup->setId(infoButton, 3); | |
438 | |
439 connect(mButtonGroup, SIGNAL(buttonClicked(int)), | |
440 this, SLOT(togglePages(int))); | |
441 buttonBarLayout->addWidget(updatesButton); | |
442 buttonBarLayout->addWidget(allInstallButton); | |
443 buttonBarLayout->addWidget(allRemoveButton); | |
444 buttonBarLayout->insertStretch(3, 10); | |
445 buttonBarLayout->addWidget(infoButton); | |
446 | |
447 //The main panels. | |
448 //The updates page. | |
449 mUpdatesPanel = new QScrollArea; | |
450 mUpdatesWidget = new QWidget; | |
451 QHBoxLayout *updatesHeaderLayout = new QHBoxLayout; | |
452 QVBoxLayout *updatesHeaderTextLayout = new QVBoxLayout; | |
453 QVBoxLayout *updatesHeaderSettLayout = new QVBoxLayout; | |
454 | |
455 QLabel *updatesHeader = | |
456 new QLabel("<h2>" + tr("Updates (%1/%2)").arg(2).arg(4)+ "</h2>"); | |
457 QLabel *lastCertUpdate = | |
458 new QLabel(tr("Last certificate update: %1").arg("today")); | |
459 QLabel *lastSWupdate = | |
460 new QLabel(tr("Last Software update: %1").arg("today")); | |
461 updatesHeaderTextLayout->addWidget(updatesHeader); | |
462 updatesHeaderTextLayout->addWidget(lastCertUpdate); | |
463 updatesHeaderTextLayout->addWidget(lastSWupdate); | |
464 | |
465 QPushButton *searchUpdates = new QPushButton(tr("Search for Updates")); | |
466 updatesHeaderSettLayout->insertStretch(0, 10); | |
467 updatesHeaderSettLayout->addWidget(searchUpdates); | |
468 updatesHeaderLayout->addLayout(updatesHeaderTextLayout); | |
469 updatesHeaderLayout->insertStretch(1, 10); | |
470 updatesHeaderLayout->addLayout(updatesHeaderSettLayout); | |
471 | |
472 QVBoxLayout *updatesCenterLayout = new QVBoxLayout; | |
473 QHBoxLayout *updatesNewLayout = new QHBoxLayout; | |
474 QHBoxLayout *updatesRemoveLayout = new QHBoxLayout; | |
475 QHBoxLayout *updatesManualLayout = new QHBoxLayout; | |
476 QLabel *updatesTip = | |
477 new QLabel(tr("The following certificate changes are recommended.")); | |
478 QLabel *updatesNewCertificates = | |
479 new QLabel("<h3>" + | |
480 tr("Install new Certificates (%1/%2)").arg(2).arg(2) + | |
481 "</h3>"); | |
482 QPushButton *updatesDetailsNew = new QPushButton(tr("Details")); | |
483 connect(updatesDetailsNew, | |
484 SIGNAL(clicked()), | |
485 this, | |
486 SLOT(toggleUpdatesNew())); | |
487 updatesNewLayout->addWidget(updatesNewCertificates); | |
488 updatesNewLayout->addWidget(updatesDetailsNew); | |
489 updatesNewLayout->insertStretch(2, 10); | |
490 mUpdatesNew = new CertificateListWidget(this); | |
491 mUpdatesNew->hide(); | |
492 | |
493 QLabel *updatesRemoveCertificates = | |
494 new QLabel("<h3>" + | |
495 tr("Remove insecure Certificates (%1/%2)").arg(2).arg(2) + | |
496 "</h3>"); | |
497 QPushButton *updatesDetailsRemove = new QPushButton(tr("Details")); | |
498 connect(updatesDetailsRemove, | |
499 SIGNAL(clicked()), | |
500 this, | |
501 SLOT(toggleUpdatesRemove())); | |
502 updatesRemoveLayout->addWidget(updatesRemoveCertificates); | |
503 updatesRemoveLayout->addWidget(updatesDetailsRemove); | |
504 updatesRemoveLayout->insertStretch(2, 10); | |
505 mUpdatesRemove = new CertificateListWidget(this); | |
506 mUpdatesRemove->hide(); | |
507 | |
508 QLabel *updatesManualCertificates = | |
509 new QLabel("<h3>" + | |
510 tr("Manualy changed Certificates (%1)").arg(2) + | |
511 "</h3>"); | |
512 QPushButton *updatesDetailsManual = new QPushButton(tr("Details")); | |
513 connect(updatesDetailsManual, | |
514 SIGNAL(clicked()), | |
515 this, | |
516 SLOT(toggleUpdatesManual())); | |
517 updatesManualLayout->addWidget(updatesManualCertificates); | |
518 updatesManualLayout->addWidget(updatesDetailsManual); | |
519 updatesManualLayout->insertStretch(2, 10); | |
520 mUpdatesManual = new CertificateListWidget(this); | |
521 mUpdatesManual->hide(); | |
522 | |
523 updatesCenterLayout->addWidget(updatesTip); | |
524 updatesCenterLayout->addLayout(updatesNewLayout); | |
525 updatesCenterLayout->addWidget(mUpdatesNew); | |
526 updatesCenterLayout->addLayout(updatesRemoveLayout); | |
527 updatesCenterLayout->addWidget(mUpdatesRemove); | |
528 updatesCenterLayout->addLayout(updatesManualLayout); | |
529 updatesCenterLayout->addWidget(mUpdatesManual); | |
530 | |
531 QHBoxLayout *updatesBottomLayout = new QHBoxLayout; | |
532 quitButton = new QPushButton(tr("Quit without saving")); | |
533 QPushButton *saveButton = new QPushButton(tr("Update")); | |
534 connect(quitButton, SIGNAL(clicked()), this, SLOT(closeApp())); | |
535 updatesBottomLayout->insertStretch(0, 10); | |
536 updatesBottomLayout->addWidget(saveButton); | |
537 updatesBottomLayout->addWidget(quitButton); | |
538 | |
539 QFrame *updatesPanelSeparator = new QFrame(); | |
540 updatesPanelSeparator->setFrameShape(QFrame::HLine); | |
541 updatesPanelSeparator->setFrameShadow(QFrame::Sunken); | |
542 updatesPanelLayout->addLayout(updatesHeaderLayout); | |
543 updatesPanelLayout->addWidget(updatesPanelSeparator); | |
544 updatesPanelLayout->addLayout(updatesCenterLayout); | |
545 updatesPanelLayout->insertStretch(3, 10); | |
546 updatesPanelLayout->addLayout(updatesBottomLayout); | |
547 mUpdatesWidget->setLayout(updatesPanelLayout); | |
548 mUpdatesWidget->setMinimumSize(QSize(820, 440)); | |
549 mUpdatesPanel->setWidget(mUpdatesWidget); | |
550 | |
551 // Panel for trusted certificates. | |
552 mInstallPanel = new QScrollArea; | |
553 | |
554 QVBoxLayout *installPanelLayout = new QVBoxLayout; | |
555 QVBoxLayout *installHeaderLayout = new QVBoxLayout; | |
556 QVBoxLayout *installCenterLayout = new QVBoxLayout; | |
557 | |
558 QLabel *installHeaderLabel = | |
559 new QLabel("<h2>" + tr("Trusted Certificates") + "</h2>"); | |
560 QLabel *installHeaderText = new QLabel(tr("The following list of root" | |
561 " certificates was created by the BSI. The BSI vaidates authenticity," | |
562 " security and actuality of these certificates")); | |
563 installHeaderLayout->addWidget(installHeaderLabel); | |
564 installHeaderLayout->addWidget(installHeaderText); | |
565 | |
566 QLabel *installCenterText = new QLabel(tr("Please choose the certificates" | |
567 " you want to trust. TrustBridge will install these certificates for" | |
568 " secure communication via email or the internet (e.g. IE, Firefox," | |
569 " Thunderbird)")); | |
570 installCenterLayout->addWidget(installCenterText); | |
571 mInstallList = new CertificateListWidget(this); | |
572 | |
573 installPanelLayout->addLayout(installHeaderLayout); | |
574 installPanelLayout->addLayout(installCenterLayout); | |
575 installPanelLayout->addWidget(mInstallList); | |
576 mInstallPanel->setLayout(installPanelLayout); | |
577 | |
578 // Panel for insecure certificates. | |
579 mRemovePanel = new QScrollArea; | |
580 QVBoxLayout *removePanelLayout = new QVBoxLayout; | |
581 QVBoxLayout *removeHeaderLayout = new QVBoxLayout; | |
582 QVBoxLayout *removeCenterLayout = new QVBoxLayout; | |
583 | |
584 QLabel *removeHeaderLabel = | |
585 new QLabel("<h2>" + tr("Insecure Certificates") + "</h2>"); | |
586 QLabel *removeHeaderText = new QLabel(tr("The following list of root" | |
587 " certificates was created by the BSI. The BSI validates authenticity," | |
588 " security and actuality of these certificates")); | |
589 removeHeaderLayout->addWidget(removeHeaderLabel); | |
590 removeHeaderLayout->addWidget(removeHeaderText); | |
591 | |
592 QLabel *removeCenterText = new QLabel(tr("Please choose the certificates" | |
593 " you want to remove. TrustBridge will remove these certificates.")); | |
594 removeCenterLayout->addWidget(removeCenterText); | |
595 | |
596 removePanelLayout->addLayout(removeHeaderLayout); | |
597 removePanelLayout->addLayout(removeCenterLayout); | |
598 mRemovePanel->setLayout(removePanelLayout); | |
599 | |
600 // Info panel. | |
601 mInfoPanel = new QScrollArea; | |
602 | |
603 QVBoxLayout *infoPanelLayout = new QVBoxLayout(this); | |
604 QHBoxLayout *infoHeaderLayout = new QHBoxLayout; | |
605 QVBoxLayout *infoHeaderTextLayout = new QVBoxLayout; | |
606 QVBoxLayout *infoCenterLayout = new QVBoxLayout; | |
607 | |
608 QImage *infoLogoImage = new QImage(":/img/logo.png"); | |
609 QLabel *infoLogo = new QLabel; | |
610 infoLogo->setBackgroundRole(QPalette::Base); | |
611 infoLogo->setPixmap(QPixmap::fromImage(*infoLogoImage)); | |
612 QLabel *infoTitle = new QLabel("<h1>" + tr("TrustBridge") + "</h1>"); | |
613 QString infoVersion = tr("Version: "); | |
614 infoVersion.append(QApplication::applicationVersion()); | |
615 QLabel *appVersion = new QLabel(infoVersion); | |
616 appVersion->setTextInteractionFlags( | |
617 Qt::TextSelectableByMouse | | |
618 Qt::TextSelectableByKeyboard); | |
619 | |
620 QFrame *infoHeaderSeparator = new QFrame(); | |
621 infoHeaderSeparator->setFrameShape(QFrame::HLine); | |
622 infoHeaderSeparator->setFrameShadow(QFrame::Sunken); | |
623 | |
624 infoHeaderTextLayout->addWidget(infoTitle); | |
625 infoHeaderTextLayout->addWidget(appVersion); | |
626 infoHeaderLayout->addWidget(infoLogo); | |
627 infoHeaderLayout->addLayout(infoHeaderTextLayout); | |
628 infoHeaderLayout->insertStretch(2, 10); | |
629 | |
630 QLabel *textDesc = new QLabel(tr("TrustBridge is a root certificate" | |
631 " installer for Windows and Linux.")); | |
632 textDesc->setTextInteractionFlags( | |
633 Qt::TextSelectableByMouse | | |
634 Qt::TextSelectableByKeyboard); | |
635 QLabel *textManage = new QLabel(tr("The root certificate lists are managed" | |
636 " by the German <a href=\"https://www.bsi.bund.de\">" | |
637 "Federal Office for Information Security (BSI)</a>.\n\n")); | |
638 textManage->setTextInteractionFlags( | |
639 Qt::TextBrowserInteraction | | |
640 Qt::TextSelectableByKeyboard); | |
641 QLabel *textDevel = new QLabel(tr("The software was developed by the companies" | |
642 " <a href=\"http://www.intevation.de\">Intevation GmbH</a> and " | |
643 " <a href=\"http://www.dn-systems.de\">DN-Systems GmbH</a>, <br>" | |
644 " contracted by the German Federal Office for Information Security (BSI).\n\n")); | |
645 textDevel->setTextInteractionFlags( | |
646 Qt::TextBrowserInteraction | | |
647 Qt::TextSelectableByKeyboard); | |
648 QLabel *textLicense = new QLabel(tr("TrustBridge is Free Software licensed" | |
649 " under GNU GPL v2+.\n\nCopyright (C) 2014 by Bundesamt für Sicherheit" | |
650 " in der Informationstechnik")); | |
651 textLicense->setTextInteractionFlags( | |
652 Qt::TextSelectableByMouse | | |
653 Qt::TextSelectableByKeyboard); | |
654 | |
655 infoCenterLayout->addWidget(infoHeaderSeparator); | |
656 infoCenterLayout->addWidget(textDesc); | |
657 infoCenterLayout->addWidget(textManage); | |
658 infoCenterLayout->addWidget(textDevel); | |
659 infoCenterLayout->addWidget(textLicense); | |
660 infoCenterLayout->insertSpacing(2, 10); | |
661 infoCenterLayout->insertSpacing(4, 10); | |
662 infoCenterLayout->insertSpacing(6, 10); | |
663 infoCenterLayout->insertStretch(8, 10); | |
664 | |
665 infoPanelLayout->addLayout(infoHeaderLayout); | |
666 infoPanelLayout->addLayout(infoCenterLayout); | |
667 mInfoPanel->setLayout(infoPanelLayout); | |
668 | |
669 // The main layout for pages. | |
670 mInstallPanel->hide(); | |
671 mRemovePanel->hide(); | |
672 mInfoPanel->hide(); | |
673 containerLayout->addWidget(mUpdatesPanel); | |
674 containerLayout->addWidget(mInstallPanel); | |
675 containerLayout->addWidget(mRemovePanel); | |
676 containerLayout->addWidget(mInfoPanel); | |
677 | |
678 centerLayout->addLayout(buttonBarLayout); | |
679 centerLayout->addLayout(containerLayout); | |
680 | |
681 | |
682 /* | |
683 // The certificate list | |
684 QGroupBox *certBox = new QGroupBox(tr("Managed Certificates")); | |
685 mCertListWidget = new QListWidget; | |
686 connect(mCertListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), | |
687 this, SLOT(showDetails(QListWidgetItem*))); | |
688 certLayout->addWidget(mCertListWidget); | |
689 | |
690 mCurrentListDate = new QLabel(tr("Current List Date: %1").arg("")); | |
691 mNewListDate = new QLabel(""); | |
692 listInfoLayout->addWidget(mCurrentListDate); | |
693 listInfoLayout->addWidget(mNewListDate); | |
694 certLayout->addLayout(listInfoLayout); | |
695 | |
696 certBox->setLayout(certLayout); | |
697 | |
424 | 698 |
425 // The settings. | 699 // The settings. |
426 QGroupBox *settingsBox = new QGroupBox(tr("Settings")); | 700 QGroupBox *settingsBox = new QGroupBox(tr("Settings")); |
427 mAutoUpdateOption = new QCheckBox(tr("Autoupdate")); | 701 mAutoUpdateOption = new QCheckBox(tr("Autoupdate")); |
428 mAutoStartOption = new QCheckBox(tr("Autostart")); | 702 mAutoStartOption = new QCheckBox(tr("Autostart")); |
438 bool autoStart = mSettings.value("autostart", true).toBool(); | 712 bool autoStart = mSettings.value("autostart", true).toBool(); |
439 mSettings.endGroup(); | 713 mSettings.endGroup(); |
440 mAutoUpdateOption->setCheckState(autoUpdate ? Qt::Checked : Qt::Unchecked); | 714 mAutoUpdateOption->setCheckState(autoUpdate ? Qt::Checked : Qt::Unchecked); |
441 mAutoStartOption->setCheckState(autoStart ? Qt::Checked : Qt::Unchecked); | 715 mAutoStartOption->setCheckState(autoStart ? Qt::Checked : Qt::Unchecked); |
442 | 716 |
443 | |
444 // The buttons. | |
445 bottomLayout->setAlignment(Qt::AlignBottom); | |
446 installButton = new QPushButton(tr("Install selected")); | |
447 installButton->setFixedHeight(80); | |
448 connect(installButton, SIGNAL(clicked()), this, SLOT(resizeButtons())); | |
449 connect(installButton, SIGNAL(clicked()), this, SLOT(installCerts())); | |
450 quitButton = new QPushButton(tr("Quit")); | |
451 quitButton->setFixedHeight(20); | |
452 connect(quitButton, SIGNAL(clicked()), this, SLOT(closeApp())); | |
453 bottomLayout->insertStretch(0, 10); | |
454 bottomLayout->addWidget(installButton); | |
455 bottomLayout->setAlignment(installButton, Qt::AlignBottom); | |
456 bottomLayout->addWidget(quitButton); | |
457 bottomLayout->setAlignment(quitButton, Qt::AlignBottom); | |
458 | 717 |
459 #ifdef Q_OS_WIN | 718 #ifdef Q_OS_WIN |
460 if (is_admin()) { | 719 if (is_admin()) { |
461 QIcon uacShield = QApplication::style()->standardIcon(QStyle::SP_VistaShield); | 720 QIcon uacShield = QApplication::style()->standardIcon(QStyle::SP_VistaShield); |
462 installButton->setIcon(uacShield); | 721 installButton->setIcon(uacShield); |
498 detailLayout->addLayout(detailContentLayout); | 757 detailLayout->addLayout(detailContentLayout); |
499 detailBox->setLayout(detailLayout); | 758 detailBox->setLayout(detailLayout); |
500 | 759 |
501 infoLayout->addSpacing(20); | 760 infoLayout->addSpacing(20); |
502 infoLayout->addLayout(headerLayout); | 761 infoLayout->addLayout(headerLayout); |
503 infoLayout->addWidget(detailBox); | 762 //infoLayout->addWidget(detailBox); |
504 infoLayout->addWidget(settingsBox); | 763 //infoLayout->addWidget(settingsBox); |
505 infoLayout->addLayout(bottomLayout); | 764 infoLayout->addLayout(bottomLayout); |
506 | 765 |
507 mainLayout->addWidget(certBox); | 766 //mainLayout->addWidget(certBox); |
508 mainLayout->addLayout(infoLayout); | 767 mainLayout->addLayout(infoLayout); |
509 mainLayout->setStretchFactor(certBox, 37); | 768 mainLayout->setStretchFactor(certBox, 37); |
510 mainLayout->setStretchFactor(infoLayout, 63); | 769 mainLayout->setStretchFactor(infoLayout, 63); |
511 | 770 |
512 // QMainWindow allready has a layout. All child layouts and widgets are | 771 // QMainWindow allready has a layout. All child layouts and widgets are |
513 // managed in the central widget. | 772 // managed in the central widget. |
773 */ | |
774 | |
775 QFrame *topSeparator = new QFrame(); | |
776 topSeparator->setFrameShape(QFrame::HLine); | |
777 topSeparator->setFrameShadow(QFrame::Sunken); | |
778 | |
779 mainLayout->addLayout(headerLayout); | |
780 mainLayout->addWidget(topSeparator); | |
781 mainLayout->addLayout(centerLayout); | |
782 mainLayout->addLayout(bottomLayout); | |
514 base->setLayout(mainLayout); | 783 base->setLayout(mainLayout); |
515 setCentralWidget(base); | 784 setCentralWidget(base); |
516 } | 785 } |
517 | 786 |
518 void MainWindow::loadCertificateList() | 787 void MainWindow::loadCertificateList() |
519 { | 788 { |
520 mCertListWidget->clear(); | 789 //mCertListWidget->clear(); |
521 int i = 0; | 790 //int i = 0; |
522 | 791 |
523 /* TODO: if nothing is available (neither old nor new) add some progress | 792 /* TODO: if nothing is available (neither old nor new) add some progress |
524 * indication */ | 793 * indication */ |
525 QList<Certificate> newInstallCerts; | 794 QList<Certificate> newInstallCerts; |
526 QList<Certificate> newRemoveCerts; | 795 QList<Certificate> newRemoveCerts; |
530 if (mListToInstall.getCertificates().isEmpty()) { | 799 if (mListToInstall.getCertificates().isEmpty()) { |
531 // No new list available, add old certificates. | 800 // No new list available, add old certificates. |
532 foreach (const Certificate &cert, mInstalledList.getCertificates()) { | 801 foreach (const Certificate &cert, mInstalledList.getCertificates()) { |
533 if (cert.isInstallCert()) { | 802 if (cert.isInstallCert()) { |
534 oldInstallCerts.append(cert); | 803 oldInstallCerts.append(cert); |
804 mInstallList->addCertificate(cert); | |
535 } | 805 } |
536 else { | 806 else { |
537 oldRemoveCerts.append(cert); | 807 oldRemoveCerts.append(cert); |
538 } | 808 } |
539 } | 809 } |
551 oldInstallCerts.append(cert); | 821 oldInstallCerts.append(cert); |
552 } | 822 } |
553 else { | 823 else { |
554 // Is a brand new certificate | 824 // Is a brand new certificate |
555 newInstallCerts.append(cert); | 825 newInstallCerts.append(cert); |
826 mUpdatesNew->addCertificate(cert); | |
556 } | 827 } |
557 } | 828 } |
558 else { | 829 else { |
559 // Certificate with status "remove". | 830 // Certificate with status "remove". |
560 if (mInstalledList.getCertificates().contains(cert)) { | 831 if (mInstalledList.getCertificates().contains(cert)) { |
566 // status "remove". | 837 // status "remove". |
567 newRemoveCerts.append(cert); | 838 newRemoveCerts.append(cert); |
568 } | 839 } |
569 } | 840 } |
570 } | 841 } |
571 mCurrentListDate->setText(tr("Current List Date: %1") | 842 /* mCurrentListDate->setText(tr("Current List Date: %1") |
572 .arg(mInstalledList.date().toString())); | 843 .arg(mInstalledList.date().toString())); |
573 mNewListDate->setText(tr("New List Date: %1").arg(mListToInstall.date().toString())); | 844 mNewListDate->setText(tr("New List Date: %1").arg(mListToInstall.date().toString()));*/ |
574 } | 845 } |
575 | 846 /* |
576 // Add separators and certificates to list widget. | 847 // Add separators and certificates to list widget. |
577 if (!newInstallCerts.isEmpty()) { | 848 if (!newInstallCerts.isEmpty()) { |
578 mCertListWidget->addItem(createSeparator(tr("New certificates to install"), i++)); | 849 mCertListWidget->addItem(createSeparator(tr("New certificates to install"), i++)); |
579 foreach (const Certificate &cert, newInstallCerts) { | 850 foreach (const Certificate &cert, newInstallCerts) { |
580 mCertListWidget->addItem(createListItem(cert, Certificate::InstallNew, i++)); | 851 mCertListWidget->addItem(createListItem(cert, Certificate::InstallNew, i++)); |
599 mCertListWidget->addItem(createSeparator(tr("Old certificates to remove"), i++)); | 870 mCertListWidget->addItem(createSeparator(tr("Old certificates to remove"), i++)); |
600 foreach (const Certificate &cert, oldRemoveCerts) { | 871 foreach (const Certificate &cert, oldRemoveCerts) { |
601 mCertListWidget->addItem(createListItem(cert, Certificate::RemoveOld, i++)); | 872 mCertListWidget->addItem(createListItem(cert, Certificate::RemoveOld, i++)); |
602 } | 873 } |
603 } | 874 } |
875 */ | |
604 } | 876 } |
605 | 877 |
606 QListWidgetItem* MainWindow::createSeparator(const QString &text, int index) | 878 QListWidgetItem* MainWindow::createSeparator(const QString &text, int index) |
607 { | 879 { |
608 SeparatorItemDelegate *separatorDelegate = new SeparatorItemDelegate(); | 880 SeparatorItemDelegate *separatorDelegate = new SeparatorItemDelegate(); |
693 mSettings.setValue("List/installed", listFileName); | 965 mSettings.setValue("List/installed", listFileName); |
694 mSettings.setValue("List/installedDate", listFileDate); | 966 mSettings.setValue("List/installedDate", listFileDate); |
695 mInstalledList = mListToInstall; | 967 mInstalledList = mListToInstall; |
696 mListToInstall = CertificateList(); | 968 mListToInstall = CertificateList(); |
697 } | 969 } |
698 loadCertificateList(); | 970 //loadCertificateList(); |
699 } | 971 } |
700 | 972 |
701 void MainWindow::installCerts() { | 973 void MainWindow::installCerts() { |
702 QStringList choices; | 974 QStringList choices; |
703 | 975 |
734 connect(instWrap, SIGNAL(installationSuccessful()), | 1006 connect(instWrap, SIGNAL(installationSuccessful()), |
735 this, SLOT(installerSuccess())); | 1007 this, SLOT(installerSuccess())); |
736 connect(instWrap, SIGNAL(error(const QString &)), | 1008 connect(instWrap, SIGNAL(error(const QString &)), |
737 this, SLOT(installerError(const QString &))); | 1009 this, SLOT(installerError(const QString &))); |
738 instWrap->start(); | 1010 instWrap->start(); |
739 | 1011 /* |
740 if (!saveUnselectedCertificates()) { | 1012 if (!saveUnselectedCertificates()) { |
741 qWarning() << "Failed to save previosly unselected certificates."; | 1013 qWarning() << "Failed to save previosly unselected certificates."; |
742 } | 1014 } |
1015 */ | |
743 } | 1016 } |
744 | 1017 |
745 void MainWindow::loadUnselectedCertificates() | 1018 void MainWindow::loadUnselectedCertificates() |
746 { | 1019 { |
747 mPreviouslyUnselected.clear(); | 1020 mPreviouslyUnselected.clear(); |
788 mSettings.endGroup(); | 1061 mSettings.endGroup(); |
789 } | 1062 } |
790 | 1063 |
791 void MainWindow::closeApp() | 1064 void MainWindow::closeApp() |
792 { | 1065 { |
793 saveUnselectedCertificates(); | 1066 //saveUnselectedCertificates(); |
794 qApp->quit(); | 1067 qApp->quit(); |
795 } | 1068 } |
1069 | |
1070 void MainWindow::togglePages(int button) | |
1071 { | |
1072 mUpdatesPanel->hide(); | |
1073 mInstallPanel->hide(); | |
1074 mRemovePanel->hide(); | |
1075 mInfoPanel->hide(); | |
1076 switch(button) { | |
1077 case 0: mUpdatesPanel->show(); break; | |
1078 case 1: mInstallPanel->show(); break; | |
1079 case 2: mRemovePanel->show(); break; | |
1080 case 3: mInfoPanel->show(); break; | |
1081 default: mUpdatesPanel->show(); break; | |
1082 } | |
1083 return; | |
1084 } | |
1085 | |
1086 void MainWindow::toggleUpdatesNew() { | |
1087 QSize old = mUpdatesWidget->size(); | |
1088 if (!mUpdatesNew->isVisible()) { | |
1089 mUpdatesWidget->resize(old.width(), old.height() + mUpdatesNew->height()); | |
1090 mUpdatesNew->show(); | |
1091 } | |
1092 else { | |
1093 mUpdatesWidget->resize(old.width(), old.height() - mUpdatesNew->height()); | |
1094 mUpdatesNew->hide(); | |
1095 } | |
1096 } | |
1097 | |
1098 void MainWindow::toggleUpdatesRemove() { | |
1099 QSize old = mUpdatesWidget->size(); | |
1100 if (!mUpdatesRemove->isVisible()) { | |
1101 mUpdatesWidget->resize(old.width(), old.height() + mUpdatesRemove->height()); | |
1102 mUpdatesRemove->show(); | |
1103 } | |
1104 else { | |
1105 mUpdatesWidget->resize(old.width(), old.height() - mUpdatesRemove->height()); | |
1106 mUpdatesRemove->hide(); | |
1107 } | |
1108 } | |
1109 | |
1110 void MainWindow::toggleUpdatesManual() { | |
1111 QSize old = mUpdatesWidget->size(); | |
1112 if (!mUpdatesManual->isVisible()) { | |
1113 mUpdatesWidget->resize(old.width(), old.height() + mUpdatesManual->height()); | |
1114 mUpdatesManual->show(); | |
1115 } | |
1116 else { | |
1117 mUpdatesManual->hide(); | |
1118 mUpdatesWidget->resize(old.width(), old.height() - mUpdatesManual->height()); | |
1119 } | |
1120 } |