Mercurial > trustbridge
comparison ui/mainwindow.cpp @ 743:a467204a35f5
Rework User Interface.
Certificate lists are now plain lists of widgets and no longer
a ListWidget. Details are no longer shown extra but included
in the list. List entries are somewhat larger accordingly.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 04 Jul 2014 16:15:59 +0200 |
parents | 8efd10afb883 |
children | d73f4e58d117 |
comparison
equal
deleted
inserted
replaced
742:627e8d678b6d | 743:a467204a35f5 |
---|---|
32 | 32 |
33 #include "certificatelist.h" | 33 #include "certificatelist.h" |
34 #include "downloader.h" | 34 #include "downloader.h" |
35 #include "helpdialog.h" | 35 #include "helpdialog.h" |
36 #include "aboutdialog.h" | 36 #include "aboutdialog.h" |
37 #include "certificateitemdelegate.h" | |
38 #include "separatoritemdelegate.h" | 37 #include "separatoritemdelegate.h" |
39 #include "installwrapper.h" | 38 #include "installwrapper.h" |
40 #include "util.h" | 39 #include "util.h" |
41 #include "logging.h" | 40 #include "logging.h" |
42 #include "binverify.h" | 41 #include "binverify.h" |
431 mTrayIcon->setToolTip(tr("TrustBridge")); | 430 mTrayIcon->setToolTip(tr("TrustBridge")); |
432 | 431 |
433 connect(mTrayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked())); | 432 connect(mTrayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked())); |
434 } | 433 } |
435 | 434 |
436 QLayout * createInfoPanelLayout() | 435 QWidget * MainWindow::createInfoWidget() |
437 { | 436 { |
437 QWidget *theWidget = new QWidget; | |
438 QVBoxLayout *infoPanelLayout = new QVBoxLayout; | 438 QVBoxLayout *infoPanelLayout = new QVBoxLayout; |
439 QHBoxLayout *infoHeaderLayout = new QHBoxLayout; | 439 QHBoxLayout *infoHeaderLayout = new QHBoxLayout; |
440 QVBoxLayout *infoHeaderTextLayout = new QVBoxLayout; | 440 QVBoxLayout *infoHeaderTextLayout = new QVBoxLayout; |
441 QVBoxLayout *infoCenterLayout = new QVBoxLayout; | 441 QVBoxLayout *infoCenterLayout = new QVBoxLayout; |
442 | 442 |
443 QImage *infoLogoImage = new QImage(":/img/logo.png"); | 443 QImage *infoLogoImage = new QImage(":/img/logo.png"); |
444 QLabel *infoLogo = new QLabel; | 444 QLabel *infoLogo = new QLabel; |
445 infoLogo->setBackgroundRole(QPalette::Base); | 445 infoLogo->setBackgroundRole(QPalette::Base); |
446 infoLogo->setPixmap(QPixmap::fromImage(*infoLogoImage)); | 446 infoLogo->setPixmap(QPixmap::fromImage(*infoLogoImage)); |
447 QLabel *infoTitle = new QLabel("<h1>" + QObject::tr("TrustBridge") + "</h1>"); | 447 QLabel *infoTitle = new QLabel("<h1>" + tr("TrustBridge") + "</h1>"); |
448 QString infoVersion = QObject::tr("Version: "); | 448 QString infoVersion = tr("Version: "); |
449 infoVersion.append(QApplication::applicationVersion()); | 449 infoVersion.append(QApplication::applicationVersion()); |
450 QLabel *appVersion = new QLabel(infoVersion); | 450 QLabel *appVersion = new QLabel(infoVersion); |
451 appVersion->setTextInteractionFlags( | 451 appVersion->setTextInteractionFlags( |
452 Qt::TextSelectableByMouse | | 452 Qt::TextSelectableByMouse | |
453 Qt::TextSelectableByKeyboard); | 453 Qt::TextSelectableByKeyboard); |
460 infoHeaderTextLayout->addWidget(appVersion); | 460 infoHeaderTextLayout->addWidget(appVersion); |
461 infoHeaderLayout->addWidget(infoLogo); | 461 infoHeaderLayout->addWidget(infoLogo); |
462 infoHeaderLayout->addLayout(infoHeaderTextLayout); | 462 infoHeaderLayout->addLayout(infoHeaderTextLayout); |
463 infoHeaderLayout->insertStretch(2, 10); | 463 infoHeaderLayout->insertStretch(2, 10); |
464 | 464 |
465 QLabel *textDesc = new QLabel(QObject::tr("TrustBridge is a root certificate" | 465 QLabel *textDesc = new QLabel(tr("TrustBridge is a root certificate" |
466 " installer for Windows and Linux.")); | 466 " installer for Windows and Linux.")); |
467 textDesc->setTextInteractionFlags( | 467 textDesc->setTextInteractionFlags( |
468 Qt::TextSelectableByMouse | | 468 Qt::TextSelectableByMouse | |
469 Qt::TextSelectableByKeyboard); | 469 Qt::TextSelectableByKeyboard); |
470 QLabel *textManage = new QLabel(QObject::tr("The root certificate lists are managed" | 470 QLabel *textManage = new QLabel(tr("The root certificate lists are managed" |
471 " by the German <a href=\"https://www.bsi.bund.de\">" | 471 " by the German <a href=\"https://www.bsi.bund.de\">" |
472 "Federal Office for Information Security (BSI)</a>.\n\n")); | 472 "Federal Office for Information Security (BSI)</a>.\n\n")); |
473 textManage->setTextInteractionFlags( | 473 textManage->setTextInteractionFlags( |
474 Qt::TextBrowserInteraction | | 474 Qt::TextBrowserInteraction | |
475 Qt::TextSelectableByKeyboard); | 475 Qt::TextSelectableByKeyboard); |
476 QLabel *textDevel = new QLabel(QObject::tr("The software was developed by the companies" | 476 QLabel *textDevel = new QLabel(tr("The software was developed by the companies" |
477 " <a href=\"http://www.intevation.de\">Intevation GmbH</a> and " | 477 " <a href=\"http://www.intevation.de\">Intevation GmbH</a> and " |
478 " <a href=\"http://www.dn-systems.de\">DN-Systems GmbH</a>, <br>" | 478 " <a href=\"http://www.dn-systems.de\">DN-Systems GmbH</a>, <br>" |
479 " contracted by the German Federal Office for Information Security (BSI).\n\n")); | 479 " contracted by the German Federal Office for Information Security (BSI).\n\n")); |
480 textDevel->setTextInteractionFlags( | 480 textDevel->setTextInteractionFlags( |
481 Qt::TextBrowserInteraction | | 481 Qt::TextBrowserInteraction | |
482 Qt::TextSelectableByKeyboard); | 482 Qt::TextSelectableByKeyboard); |
483 QLabel *textLicense = new QLabel(QObject::tr("TrustBridge is Free Software licensed" | 483 QLabel *textLicense = new QLabel(tr("TrustBridge is Free Software licensed" |
484 " under GNU GPL v2+.\n\nCopyright (C) 2014 by Bundesamt für Sicherheit" | 484 " under GNU GPL v2+.\n\nCopyright (C) 2014 by Bundesamt für Sicherheit" |
485 " in der Informationstechnik")); | 485 " in der Informationstechnik")); |
486 textLicense->setTextInteractionFlags( | 486 textLicense->setTextInteractionFlags( |
487 Qt::TextSelectableByMouse | | 487 Qt::TextSelectableByMouse | |
488 Qt::TextSelectableByKeyboard); | 488 Qt::TextSelectableByKeyboard); |
497 infoCenterLayout->insertSpacing(6, 10); | 497 infoCenterLayout->insertSpacing(6, 10); |
498 infoCenterLayout->insertStretch(8, 10); | 498 infoCenterLayout->insertStretch(8, 10); |
499 | 499 |
500 infoPanelLayout->addLayout(infoHeaderLayout); | 500 infoPanelLayout->addLayout(infoHeaderLayout); |
501 infoPanelLayout->addLayout(infoCenterLayout); | 501 infoPanelLayout->addLayout(infoCenterLayout); |
502 return infoPanelLayout; | 502 theWidget->setLayout(infoPanelLayout); |
503 } | 503 |
504 | 504 return theWidget; |
505 void MainWindow::setupGUI() | 505 } |
506 { | 506 |
507 // Create a central widget containing the main layout. | 507 QWidget * MainWindow::createUpdatesWidget() |
508 QWidget *base = new QWidget; | 508 { |
509 | 509 QWidget * theWidget = new QWidget; |
510 // Layouts and Container | |
511 QVBoxLayout *mainLayout = new QVBoxLayout; | |
512 QHBoxLayout *headerLayout = new QHBoxLayout; | |
513 QVBoxLayout *headerTextLayout = new QVBoxLayout; | |
514 QHBoxLayout *centerLayout = new QHBoxLayout; | |
515 QVBoxLayout *buttonBarLayout = new QVBoxLayout; | |
516 QHBoxLayout *bottomLayout = new QHBoxLayout; | |
517 QHBoxLayout *containerLayout = new QHBoxLayout; | |
518 | |
519 // The header (icon, about text) | |
520 QImage *logoImage = new QImage(":/img/logo.png"); | |
521 QLabel *logo = new QLabel; | |
522 logo->setBackgroundRole(QPalette::Base); | |
523 logo->setPixmap(QPixmap::fromImage(*logoImage)); | |
524 QLabel *title = new QLabel("<h1>" + QString::fromLatin1(APPNAME) + "</h1>"); | |
525 QLabel *subTitle = new QLabel(tr("Trust in your digital communication")); | |
526 headerTextLayout->addWidget(title); | |
527 headerTextLayout->addWidget(subTitle); | |
528 headerLayout->addWidget(logo); | |
529 headerLayout->addLayout(headerTextLayout); | |
530 headerLayout->setStretch(0, 0); | |
531 headerLayout->setStretch(1, 10); | |
532 | |
533 /*********************************** | |
534 * The Buttonbar on the left side. | |
535 ***********************************/ | |
536 mButtonGroup = new QButtonGroup; | |
537 | |
538 TextOverlayButton *updatesButton = new TextOverlayButton; | |
539 updatesButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); | |
540 updatesButton->setIcon(QIcon(":/img/view-refresh.png")); | |
541 updatesButton->setIconSize(QSize(48, 48)); | |
542 updatesButton->setText(tr("Updates")); | |
543 updatesButton->setFixedWidth(120); | |
544 updatesButton->setFixedHeight(90); | |
545 updatesButton->setCheckable(true); | |
546 updatesButton->setChecked(true); | |
547 | |
548 connect(this, SIGNAL(changesChanged(const QString&)), | |
549 updatesButton, SLOT(setOverlay(const QString&))); | |
550 | |
551 QToolButton *allInstallButton = new QToolButton; | |
552 allInstallButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); | |
553 allInstallButton->setIcon(QIcon(":/img/document-encrypt.png")); | |
554 allInstallButton->setIconSize(QSize(48, 48)); | |
555 allInstallButton->setText(tr("Trusted\ncertificates")); | |
556 allInstallButton->setFixedWidth(120); | |
557 allInstallButton->setFixedHeight(90); | |
558 allInstallButton->setCheckable(true); | |
559 | |
560 QToolButton *allRemoveButton = new QToolButton; | |
561 allRemoveButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); | |
562 allRemoveButton->setIcon(QIcon(":/img/dialog-warning.png")); | |
563 allRemoveButton->setIconSize(QSize(48, 48)); | |
564 allRemoveButton->setText(tr("Revoked\ncertificates")); | |
565 allRemoveButton->setFixedWidth(120); | |
566 allRemoveButton->setFixedHeight(90); | |
567 allRemoveButton->setCheckable(true); | |
568 | |
569 QToolButton *infoButton = new QToolButton; | |
570 infoButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); | |
571 infoButton->setIcon(QIcon(":/img/dialog-information.png")); | |
572 infoButton->setIconSize(QSize(48, 48)); | |
573 infoButton->setText(tr("Information\nand help")); | |
574 infoButton->setFixedWidth(120); | |
575 infoButton->setFixedHeight(90); | |
576 infoButton->setCheckable(true); | |
577 | |
578 mButtonGroup->addButton(updatesButton); | |
579 mButtonGroup->addButton(allInstallButton); | |
580 mButtonGroup->addButton(allRemoveButton); | |
581 mButtonGroup->addButton(infoButton); | |
582 mButtonGroup->setId(updatesButton, 0); | |
583 mButtonGroup->setId(allInstallButton, 1); | |
584 mButtonGroup->setId(allRemoveButton, 2); | |
585 mButtonGroup->setId(infoButton, 3); | |
586 | |
587 connect(mButtonGroup, SIGNAL(buttonClicked(int)), | |
588 this, SLOT(togglePages(int))); | |
589 buttonBarLayout->addWidget(updatesButton); | |
590 buttonBarLayout->addWidget(allInstallButton); | |
591 buttonBarLayout->addWidget(allRemoveButton); | |
592 buttonBarLayout->insertStretch(3, 10); | |
593 buttonBarLayout->addWidget(infoButton); | |
594 | |
595 /******************************** | |
596 * The main pages. | |
597 ********************************/ | |
598 | |
599 /******************************** | |
600 * The updates page. | |
601 ********************************/ | |
602 QVBoxLayout *updatesMainLayout = new QVBoxLayout; | 510 QVBoxLayout *updatesMainLayout = new QVBoxLayout; |
603 mUpdatesPanel = new QScrollArea; | |
604 QScrollArea *updatesContent = new QScrollArea; | |
605 mUpdatesWidget = new QWidget; | |
606 | 511 |
607 /* The header */ | 512 /* The header */ |
608 QGridLayout *updatesHeaderLayout = new QGridLayout; | 513 QGridLayout *updatesHeaderLayout = new QGridLayout; |
609 | 514 |
610 /* Header 1: Update date and search button */ | 515 /* Header 1: Update date and search button */ |
664 updatesHeaderActionButtonLayout->addWidget(mQuitButton); | 569 updatesHeaderActionButtonLayout->addWidget(mQuitButton); |
665 updatesHeaderLayout->addLayout(updatesHeaderActionButtonLayout, 6, 0, 1, 1); | 570 updatesHeaderLayout->addLayout(updatesHeaderActionButtonLayout, 6, 0, 1, 1); |
666 updatesHeaderLayout->setRowMinimumHeight(7, 10); | 571 updatesHeaderLayout->setRowMinimumHeight(7, 10); |
667 | 572 |
668 /* The central panels. */ | 573 /* The central panels. */ |
574 QScrollArea *centralScrollArea = new QScrollArea; | |
669 QVBoxLayout *updatesCenterLayout = new QVBoxLayout; | 575 QVBoxLayout *updatesCenterLayout = new QVBoxLayout; |
670 QHBoxLayout *updatesNewLayout = new QHBoxLayout; | 576 QHBoxLayout *updatesNewLayout = new QHBoxLayout; |
671 QHBoxLayout *updatesRemoveLayout = new QHBoxLayout; | 577 QHBoxLayout *updatesRemoveLayout = new QHBoxLayout; |
672 QHBoxLayout *updatesManualLayout = new QHBoxLayout; | 578 QHBoxLayout *updatesManualLayout = new QHBoxLayout; |
673 mUpdatesNewCertificates = | 579 mUpdatesNewCertificates = |
678 connect(mUpdatesDetailsNew, | 584 connect(mUpdatesDetailsNew, |
679 SIGNAL(clicked()), | 585 SIGNAL(clicked()), |
680 this, | 586 this, |
681 SLOT(toggleUpdatesNew())); | 587 SLOT(toggleUpdatesNew())); |
682 updatesNewLayout->addWidget(mUpdatesNewCertificates); | 588 updatesNewLayout->addWidget(mUpdatesNewCertificates); |
589 updatesNewLayout->addStretch(1); | |
683 updatesNewLayout->addWidget(mUpdatesDetailsNew); | 590 updatesNewLayout->addWidget(mUpdatesDetailsNew); |
684 updatesNewLayout->insertStretch(2, 10); | |
685 mUpdatesNew = new CertificateListWidget(this); | 591 mUpdatesNew = new CertificateListWidget(this); |
686 connect(mUpdatesNew, SIGNAL(certListChanged(int)), | 592 connect(mUpdatesNew, SIGNAL(certListChanged(int)), |
687 this, SLOT(listChanged(int))); | 593 this, SLOT(listChanged(int))); |
688 mUpdatesNew->hide(); | 594 mUpdatesNew->hide(); |
689 | 595 |
696 SIGNAL(clicked()), | 602 SIGNAL(clicked()), |
697 this, | 603 this, |
698 SLOT(toggleUpdatesRemove())); | 604 SLOT(toggleUpdatesRemove())); |
699 updatesRemoveLayout->addWidget(mUpdatesRemoveCertificates); | 605 updatesRemoveLayout->addWidget(mUpdatesRemoveCertificates); |
700 updatesRemoveLayout->addWidget(mUpdatesDetailsRemove); | 606 updatesRemoveLayout->addWidget(mUpdatesDetailsRemove); |
701 updatesRemoveLayout->insertStretch(2, 10); | |
702 mUpdatesRemove = new CertificateListWidget(this); | 607 mUpdatesRemove = new CertificateListWidget(this); |
703 connect(mUpdatesRemove, SIGNAL(certListChanged(int)), | 608 connect(mUpdatesRemove, SIGNAL(certListChanged(int)), |
704 this, SLOT(listChanged(int))); | 609 this, SLOT(listChanged(int))); |
705 mUpdatesRemove->hide(); | 610 mUpdatesRemove->hide(); |
706 | 611 |
715 SLOT(toggleUpdatesManual())); | 620 SLOT(toggleUpdatesManual())); |
716 mUpdatesDetailsManual->hide(); | 621 mUpdatesDetailsManual->hide(); |
717 mUpdatesManualCertificates->hide(); | 622 mUpdatesManualCertificates->hide(); |
718 updatesManualLayout->addWidget(mUpdatesManualCertificates); | 623 updatesManualLayout->addWidget(mUpdatesManualCertificates); |
719 updatesManualLayout->addWidget(mUpdatesDetailsManual); | 624 updatesManualLayout->addWidget(mUpdatesDetailsManual); |
720 updatesManualLayout->insertStretch(2, 10); | |
721 mUpdatesManual = new CertificateListWidget(this); | 625 mUpdatesManual = new CertificateListWidget(this); |
722 mUpdatesManual->hide(); | 626 mUpdatesManual->hide(); |
723 connect(mUpdatesManual, SIGNAL(certChanged(bool, const Certificate&)), | 627 connect(mUpdatesManual, SIGNAL(certChanged(bool, const Certificate&)), |
724 this, SLOT(removeFromManual(bool, const Certificate&))); | 628 this, SLOT(removeFromManual(bool, const Certificate&))); |
725 connect(mUpdatesManual, SIGNAL(certListChanged(int)), | 629 connect(mUpdatesManual, SIGNAL(certListChanged(int)), |
732 updatesCenterLayout->addWidget(mUpdatesNew); | 636 updatesCenterLayout->addWidget(mUpdatesNew); |
733 updatesCenterLayout->addLayout(updatesRemoveLayout); | 637 updatesCenterLayout->addLayout(updatesRemoveLayout); |
734 updatesCenterLayout->addWidget(mUpdatesRemove); | 638 updatesCenterLayout->addWidget(mUpdatesRemove); |
735 updatesCenterLayout->addLayout(updatesManualLayout); | 639 updatesCenterLayout->addLayout(updatesManualLayout); |
736 updatesCenterLayout->addWidget(mUpdatesManual); | 640 updatesCenterLayout->addWidget(mUpdatesManual); |
737 updatesCenterLayout->addStretch(1); | 641 |
738 | 642 QWidget *dummyWidget = new QWidget; |
739 updatesCenterLayout->setSizeConstraint(QLayout::SetMinAndMaxSize); | 643 dummyWidget->setLayout(updatesCenterLayout); |
740 mUpdatesWidget->setLayout(updatesCenterLayout); | 644 centralScrollArea->setWidgetResizable(true); |
741 updatesContent->setWidget(mUpdatesWidget); | 645 centralScrollArea->setWidget(dummyWidget); |
646 centralScrollArea->setFrameShape(QFrame::NoFrame); | |
647 centralScrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
742 | 648 |
743 updatesMainLayout->addLayout(updatesHeaderLayout); | 649 updatesMainLayout->addLayout(updatesHeaderLayout); |
744 updatesMainLayout->addWidget(updatesContent); | 650 updatesMainLayout->addWidget(centralScrollArea); |
745 mUpdatesPanel->setLayout(updatesMainLayout); | 651 updatesCenterLayout->addSpacerItem(new QSpacerItem(0, 0, |
746 | 652 QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); |
747 /********************************* | 653 theWidget->setLayout(updatesMainLayout); |
748 * Panel for trusted certificates. | 654 return theWidget; |
749 *********************************/ | 655 } |
750 mInstallPanel = new QScrollArea; | 656 |
751 | 657 |
658 QWidget *MainWindow::createInstallWidget() | |
659 { | |
660 QWidget *theWidget = new QWidget; | |
661 QScrollArea *scrollArea = new QScrollArea; | |
752 QVBoxLayout *installPanelLayout = new QVBoxLayout; | 662 QVBoxLayout *installPanelLayout = new QVBoxLayout; |
753 QVBoxLayout *installHeaderLayout = new QVBoxLayout; | 663 QVBoxLayout *installHeaderLayout = new QVBoxLayout; |
754 QVBoxLayout *installCenterLayout = new QVBoxLayout; | 664 QVBoxLayout *installCenterLayout = new QVBoxLayout; |
755 | 665 |
756 QLabel *installHeaderLabel = | 666 QLabel *installHeaderLabel = |
765 QLabel *installCenterText = new QLabel(tr("Please choose the certificates" | 675 QLabel *installCenterText = new QLabel(tr("Please choose the certificates" |
766 " you want to trust or untrust. TrustBridge will install these certificates for your" | 676 " you want to trust or untrust. TrustBridge will install these certificates for your" |
767 " secure communication for email and internet.")); | 677 " secure communication for email and internet.")); |
768 installCenterText->setWordWrap(true); | 678 installCenterText->setWordWrap(true); |
769 installCenterLayout->addWidget(installCenterText); | 679 installCenterLayout->addWidget(installCenterText); |
680 | |
681 installPanelLayout->addLayout(installHeaderLayout); | |
682 installPanelLayout->addLayout(installCenterLayout); | |
683 | |
770 mInstallList = new CertificateListWidget(this); | 684 mInstallList = new CertificateListWidget(this); |
771 connect(mInstallList, SIGNAL(certChanged(bool, const Certificate&)), | 685 connect(mInstallList, SIGNAL(certChanged(bool, const Certificate&)), |
772 this, SLOT(toggleInManual(bool, const Certificate&))); | 686 this, SLOT(toggleInManual(bool, const Certificate&))); |
773 | 687 |
774 installPanelLayout->addLayout(installHeaderLayout); | 688 scrollArea->setWidgetResizable(true); |
775 installPanelLayout->addLayout(installCenterLayout); | 689 scrollArea->setWidget(mInstallList); |
776 installPanelLayout->addWidget(mInstallList); | 690 scrollArea->setFrameShape(QFrame::NoFrame); |
777 mInstallPanel->setLayout(installPanelLayout); | 691 |
778 | 692 installPanelLayout->addWidget(scrollArea); |
779 /********************************** | 693 |
780 * Panel for certificates to be removed. | 694 theWidget->setLayout(installPanelLayout); |
781 **********************************/ | 695 |
782 mRemovePanel = new QScrollArea; | 696 return theWidget; |
697 } | |
698 | |
699 QWidget *MainWindow::createRemoveWidget() | |
700 { | |
701 QWidget * theWidget = new QWidget; | |
702 QScrollArea *scrollArea = new QScrollArea; | |
783 QVBoxLayout *removePanelLayout = new QVBoxLayout; | 703 QVBoxLayout *removePanelLayout = new QVBoxLayout; |
784 QVBoxLayout *removeHeaderLayout = new QVBoxLayout; | 704 QVBoxLayout *removeHeaderLayout = new QVBoxLayout; |
785 QVBoxLayout *removeCenterLayout = new QVBoxLayout; | 705 QVBoxLayout *removeCenterLayout = new QVBoxLayout; |
786 | 706 |
787 QLabel *removeHeaderLabel = | 707 QLabel *removeHeaderLabel = |
803 connect(mRemoveList, SIGNAL(certChanged(bool, const Certificate&)), | 723 connect(mRemoveList, SIGNAL(certChanged(bool, const Certificate&)), |
804 this, SLOT(toggleInManual(bool, const Certificate&))); | 724 this, SLOT(toggleInManual(bool, const Certificate&))); |
805 | 725 |
806 removePanelLayout->addLayout(removeHeaderLayout); | 726 removePanelLayout->addLayout(removeHeaderLayout); |
807 removePanelLayout->addLayout(removeCenterLayout); | 727 removePanelLayout->addLayout(removeCenterLayout); |
808 removePanelLayout->addWidget(mRemoveList); | 728 |
809 mRemovePanel->setLayout(removePanelLayout); | 729 scrollArea->setWidgetResizable(true); |
730 scrollArea->setWidget(mRemoveList); | |
731 scrollArea->setFrameShape(QFrame::NoFrame); | |
732 removePanelLayout->addWidget(scrollArea); | |
733 theWidget->setLayout(removePanelLayout); | |
734 | |
735 return theWidget; | |
736 } | |
737 | |
738 void MainWindow::setupGUI() | |
739 { | |
740 // Create a central widget containing the main layout. | |
741 QWidget *base = new QWidget; | |
742 | |
743 // Layouts and Container | |
744 QVBoxLayout *mainLayout = new QVBoxLayout; | |
745 QHBoxLayout *headerLayout = new QHBoxLayout; | |
746 QVBoxLayout *headerTextLayout = new QVBoxLayout; | |
747 QHBoxLayout *centerLayout = new QHBoxLayout; | |
748 QVBoxLayout *buttonBarLayout = new QVBoxLayout; | |
749 QHBoxLayout *bottomLayout = new QHBoxLayout; | |
750 QHBoxLayout *containerLayout = new QHBoxLayout; | |
751 | |
752 // The header (icon, about text) | |
753 QImage *logoImage = new QImage(":/img/logo.png"); | |
754 QLabel *logo = new QLabel; | |
755 logo->setBackgroundRole(QPalette::Base); | |
756 logo->setPixmap(QPixmap::fromImage(*logoImage)); | |
757 QLabel *title = new QLabel("<h1>" + QString::fromLatin1(APPNAME) + "</h1>"); | |
758 QLabel *subTitle = new QLabel(tr("Trust in your digital communication")); | |
759 headerTextLayout->addWidget(title); | |
760 headerTextLayout->addWidget(subTitle); | |
761 headerLayout->addWidget(logo); | |
762 headerLayout->addLayout(headerTextLayout); | |
763 headerLayout->setStretch(0, 0); | |
764 headerLayout->setStretch(1, 10); | |
765 | |
766 /*********************************** | |
767 * The Buttonbar on the left side. | |
768 ***********************************/ | |
769 mButtonGroup = new QButtonGroup; | |
770 | |
771 TextOverlayButton *updatesButton = new TextOverlayButton; | |
772 updatesButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); | |
773 updatesButton->setIcon(QIcon(":/img/view-refresh.png")); | |
774 updatesButton->setIconSize(QSize(48, 48)); | |
775 updatesButton->setText(tr("Updates")); | |
776 updatesButton->setFixedWidth(120); | |
777 updatesButton->setFixedHeight(90); | |
778 updatesButton->setCheckable(true); | |
779 updatesButton->setChecked(true); | |
780 | |
781 connect(this, SIGNAL(changesChanged(const QString&)), | |
782 updatesButton, SLOT(setOverlay(const QString&))); | |
783 | |
784 QToolButton *allInstallButton = new QToolButton; | |
785 allInstallButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); | |
786 allInstallButton->setIcon(QIcon(":/img/document-encrypt.png")); | |
787 allInstallButton->setIconSize(QSize(48, 48)); | |
788 allInstallButton->setText(tr("Trusted\ncertificates")); | |
789 allInstallButton->setFixedWidth(120); | |
790 allInstallButton->setFixedHeight(90); | |
791 allInstallButton->setCheckable(true); | |
792 | |
793 QToolButton *allRemoveButton = new QToolButton; | |
794 allRemoveButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); | |
795 allRemoveButton->setIcon(QIcon(":/img/dialog-warning.png")); | |
796 allRemoveButton->setIconSize(QSize(48, 48)); | |
797 allRemoveButton->setText(tr("Revoked\ncertificates")); | |
798 allRemoveButton->setFixedWidth(120); | |
799 allRemoveButton->setFixedHeight(90); | |
800 allRemoveButton->setCheckable(true); | |
801 | |
802 QToolButton *infoButton = new QToolButton; | |
803 infoButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); | |
804 infoButton->setIcon(QIcon(":/img/dialog-information.png")); | |
805 infoButton->setIconSize(QSize(48, 48)); | |
806 infoButton->setText(tr("Information\nand help")); | |
807 infoButton->setFixedWidth(120); | |
808 infoButton->setFixedHeight(90); | |
809 infoButton->setCheckable(true); | |
810 | |
811 mButtonGroup->addButton(updatesButton); | |
812 mButtonGroup->addButton(allInstallButton); | |
813 mButtonGroup->addButton(allRemoveButton); | |
814 mButtonGroup->addButton(infoButton); | |
815 mButtonGroup->setId(updatesButton, 0); | |
816 mButtonGroup->setId(allInstallButton, 1); | |
817 mButtonGroup->setId(allRemoveButton, 2); | |
818 mButtonGroup->setId(infoButton, 3); | |
819 | |
820 connect(mButtonGroup, SIGNAL(buttonClicked(int)), | |
821 this, SLOT(togglePages(int))); | |
822 buttonBarLayout->addWidget(updatesButton); | |
823 buttonBarLayout->addWidget(allInstallButton); | |
824 buttonBarLayout->addWidget(allRemoveButton); | |
825 buttonBarLayout->insertStretch(3, 10); | |
826 buttonBarLayout->addWidget(infoButton); | |
827 | |
828 /* The main pages.*/ | |
829 | |
830 /* The updates page. */ | |
831 mUpdatesWidget = createUpdatesWidget(); | |
832 | |
833 /* Install (trusted certs) Page */ | |
834 mInstallWidget = createInstallWidget(); | |
810 | 835 |
811 /********************************** | 836 /********************************** |
812 * The info panel. | 837 * Page for certificates to be removed. |
813 **********************************/ | 838 **********************************/ |
814 mInfoPanel = new QScrollArea; | 839 mRemoveWidget = createRemoveWidget(); |
815 mInfoPanel->setLayout(createInfoPanelLayout()); | 840 |
816 | 841 /********************************** |
842 * The info page. | |
843 **********************************/ | |
844 mInfoWidget = createInfoWidget(); | |
817 | 845 |
818 /******************************** | 846 /******************************** |
819 * The main layout for pages. | 847 * The main layout for pages. |
820 ********************************/ | 848 ********************************/ |
821 mInstallPanel->hide(); | 849 mInstallWidget->hide(); |
822 mRemovePanel->hide(); | 850 mRemoveWidget->hide(); |
823 mInfoPanel->hide(); | 851 mInfoWidget->hide(); |
824 containerLayout->addWidget(mUpdatesPanel); | 852 containerLayout->addWidget(mUpdatesWidget); |
825 containerLayout->addWidget(mInstallPanel); | 853 containerLayout->addWidget(mInstallWidget); |
826 containerLayout->addWidget(mRemovePanel); | 854 containerLayout->addWidget(mRemoveWidget); |
827 containerLayout->addWidget(mInfoPanel); | 855 containerLayout->addWidget(mInfoWidget); |
828 | 856 |
829 centerLayout->addLayout(buttonBarLayout); | 857 centerLayout->addLayout(buttonBarLayout); |
830 centerLayout->addLayout(containerLayout); | 858 centerLayout->addLayout(containerLayout); |
831 | 859 |
832 mainLayout->addLayout(headerLayout); | 860 mainLayout->addLayout(headerLayout); |
928 foreach (const Certificate &cert, mInstalledList.getCertificates()) { | 956 foreach (const Certificate &cert, mInstalledList.getCertificates()) { |
929 bool state = !mPreviouslyUnselected.contains(cert.base64Line()); | 957 bool state = !mPreviouslyUnselected.contains(cert.base64Line()); |
930 if (cert.isInstallCert()) { | 958 if (cert.isInstallCert()) { |
931 oldInstallCerts.append(cert); | 959 oldInstallCerts.append(cert); |
932 mInstallList->addCertificate(cert, state); | 960 mInstallList->addCertificate(cert, state); |
961 qDebug() << "Added cert to installList"; | |
933 } | 962 } |
934 else { | 963 else { |
935 oldRemoveCerts.append(cert); | 964 oldRemoveCerts.append(cert); |
936 mRemoveList->addCertificate(cert, state, !state); | 965 mRemoveList->addCertificate(cert, state, !state); |
937 } | 966 } |
1157 return; | 1186 return; |
1158 } | 1187 } |
1159 | 1188 |
1160 void MainWindow::togglePages(int button) | 1189 void MainWindow::togglePages(int button) |
1161 { | 1190 { |
1162 mUpdatesPanel->hide(); | 1191 mUpdatesWidget->hide(); |
1163 mInstallPanel->hide(); | 1192 mInstallWidget->hide(); |
1164 mRemovePanel->hide(); | 1193 mRemoveWidget->hide(); |
1165 mInfoPanel->hide(); | 1194 mInfoWidget->hide(); |
1166 switch(button) { | 1195 switch(button) { |
1167 case 0: mUpdatesPanel->show(); break; | 1196 case 0: mUpdatesWidget->show(); break; |
1168 case 1: mInstallPanel->show(); break; | 1197 case 1: mInstallWidget->show(); break; |
1169 case 2: mRemovePanel->show(); break; | 1198 case 2: mRemoveWidget->show(); break; |
1170 case 3: mInfoPanel->show(); break; | 1199 case 3: mInfoWidget->show(); break; |
1171 default: mUpdatesPanel->show(); break; | 1200 default: mUpdatesWidget->show(); break; |
1172 } | 1201 } |
1173 return; | 1202 return; |
1174 } | 1203 } |
1175 | 1204 |
1176 void MainWindow::toggleUpdatesNew() { | 1205 void MainWindow::toggleUpdatesNew() { |
1177 if (!mUpdatesNew->isVisible()) { | 1206 if (!mUpdatesNew->isVisible()) { |
1178 mUpdatesDetailsNew->setText(tr("Hide details")); | 1207 mUpdatesDetailsNew->setText(tr("Hide details")); |
1179 mUpdatesNew->show(); | 1208 mUpdatesNew->show(); |
1180 mUpdatesNew->setSelected(mUpdatesNew->selected()); | |
1181 } | 1209 } |
1182 else { | 1210 else { |
1183 mUpdatesNew->hide(); | 1211 mUpdatesNew->hide(); |
1184 mUpdatesDetailsNew->setText(tr("Show details")); | 1212 mUpdatesDetailsNew->setText(tr("Show details")); |
1185 QSize old = mUpdatesWidget->size(); | |
1186 mUpdatesWidget->resize(old.width(), old.height() - mUpdatesNew->height()); | |
1187 } | 1213 } |
1188 } | 1214 } |
1189 | 1215 |
1190 void MainWindow::toggleUpdatesRemove() { | 1216 void MainWindow::toggleUpdatesRemove() { |
1191 if (!mUpdatesRemove->isVisible()) { | 1217 if (!mUpdatesRemove->isVisible()) { |
1192 mUpdatesDetailsRemove->setText(tr("Hide details")); | 1218 mUpdatesDetailsRemove->setText(tr("Hide details")); |
1193 mUpdatesRemove->show(); | 1219 mUpdatesRemove->show(); |
1194 mUpdatesRemove->setSelected(0); | |
1195 } | 1220 } |
1196 else { | 1221 else { |
1197 mUpdatesRemove->hide(); | 1222 mUpdatesRemove->hide(); |
1198 mUpdatesDetailsRemove->setText(tr("Show details")); | 1223 mUpdatesDetailsRemove->setText(tr("Show details")); |
1199 QSize old = mUpdatesWidget->size(); | |
1200 mUpdatesWidget->resize(old.width(), old.height() - mUpdatesRemove->height()); | |
1201 } | 1224 } |
1202 } | 1225 } |
1203 | 1226 |
1204 void MainWindow::toggleUpdatesManual() { | 1227 void MainWindow::toggleUpdatesManual() { |
1205 if (!mUpdatesManual->isVisible()) { | 1228 if (!mUpdatesManual->isVisible()) { |
1206 mUpdatesDetailsManual->setText(tr("Hide details")); | 1229 mUpdatesDetailsManual->setText(tr("Hide details")); |
1207 mUpdatesManual->show(); | 1230 mUpdatesManual->show(); |
1208 mUpdatesManual->setSelected(0); | |
1209 } | 1231 } |
1210 else { | 1232 else { |
1211 mUpdatesDetailsManual->setText(tr("Show details")); | 1233 mUpdatesDetailsManual->setText(tr("Show details")); |
1212 mUpdatesManual->hide(); | 1234 mUpdatesManual->hide(); |
1213 QSize old = mUpdatesWidget->size(); | |
1214 mUpdatesWidget->resize(old.width(), old.height() - mUpdatesManual->height()); | |
1215 } | 1235 } |
1216 } | 1236 } |
1217 | 1237 |
1218 void MainWindow::closeEvent(QCloseEvent *event) | 1238 void MainWindow::closeEvent(QCloseEvent *event) |
1219 { | 1239 { |