comparison ui/mainwindow.cpp @ 739:5f0fca113ff4

Factor out Info Panel creation.
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 04 Jul 2014 11:15:34 +0200
parents d39b5b65366e
children 8efd10afb883
comparison
equal deleted inserted replaced
738:ea8d13590cbd 739:5f0fca113ff4
78 MainWindow::MainWindow(bool trayMode): 78 MainWindow::MainWindow(bool trayMode):
79 mTrayMode(trayMode) 79 mTrayMode(trayMode)
80 { 80 {
81 createActions(); 81 createActions();
82 createTrayIcon(); 82 createTrayIcon();
83 createContent(); 83 setupGUI();
84 resize(1065, 600); 84 resize(1065, 600);
85 setMinimumWidth(760); 85 setMinimumWidth(760);
86 qRegisterMetaType<SSLConnection::ErrorCode>("SSLConnection::ErrorCode"); 86 qRegisterMetaType<SSLConnection::ErrorCode>("SSLConnection::ErrorCode");
87 qRegisterMetaType<Certificate::Status>("Certificate::Status"); 87 qRegisterMetaType<Certificate::Status>("Certificate::Status");
88 88
431 mTrayIcon->setToolTip(tr("TrustBridge")); 431 mTrayIcon->setToolTip(tr("TrustBridge"));
432 432
433 connect(mTrayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked())); 433 connect(mTrayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked()));
434 } 434 }
435 435
436 void MainWindow::createContent() 436 QLayout * createInfoPanelLayout()
437 {
438 QVBoxLayout *infoPanelLayout = new QVBoxLayout;
439 QHBoxLayout *infoHeaderLayout = new QHBoxLayout;
440 QVBoxLayout *infoHeaderTextLayout = new QVBoxLayout;
441 QVBoxLayout *infoCenterLayout = new QVBoxLayout;
442
443 QImage *infoLogoImage = new QImage(":/img/logo.png");
444 QLabel *infoLogo = new QLabel;
445 infoLogo->setBackgroundRole(QPalette::Base);
446 infoLogo->setPixmap(QPixmap::fromImage(*infoLogoImage));
447 QLabel *infoTitle = new QLabel("<h1>" + QObject::tr("TrustBridge") + "</h1>");
448 QString infoVersion = QObject::tr("Version: ");
449 infoVersion.append(QApplication::applicationVersion());
450 QLabel *appVersion = new QLabel(infoVersion);
451 appVersion->setTextInteractionFlags(
452 Qt::TextSelectableByMouse |
453 Qt::TextSelectableByKeyboard);
454
455 QFrame *infoHeaderSeparator = new QFrame();
456 infoHeaderSeparator->setFrameShape(QFrame::HLine);
457 infoHeaderSeparator->setFrameShadow(QFrame::Sunken);
458
459 infoHeaderTextLayout->addWidget(infoTitle);
460 infoHeaderTextLayout->addWidget(appVersion);
461 infoHeaderLayout->addWidget(infoLogo);
462 infoHeaderLayout->addLayout(infoHeaderTextLayout);
463 infoHeaderLayout->insertStretch(2, 10);
464
465 QLabel *textDesc = new QLabel(QObject::tr("TrustBridge is a root certificate"
466 " installer for Windows and Linux."));
467 textDesc->setTextInteractionFlags(
468 Qt::TextSelectableByMouse |
469 Qt::TextSelectableByKeyboard);
470 QLabel *textManage = new QLabel(QObject::tr("The root certificate lists are managed"
471 " by the German <a href=\"https://www.bsi.bund.de\">"
472 "Federal Office for Information Security (BSI)</a>.\n\n"));
473 textManage->setTextInteractionFlags(
474 Qt::TextBrowserInteraction |
475 Qt::TextSelectableByKeyboard);
476 QLabel *textDevel = new QLabel(QObject::tr("The software was developed by the companies"
477 " <a href=\"http://www.intevation.de\">Intevation GmbH</a> and "
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"));
480 textDevel->setTextInteractionFlags(
481 Qt::TextBrowserInteraction |
482 Qt::TextSelectableByKeyboard);
483 QLabel *textLicense = new QLabel(QObject::tr("TrustBridge is Free Software licensed"
484 " under GNU GPL v2+.\n\nCopyright (C) 2014 by Bundesamt für Sicherheit"
485 " in der Informationstechnik"));
486 textLicense->setTextInteractionFlags(
487 Qt::TextSelectableByMouse |
488 Qt::TextSelectableByKeyboard);
489
490 infoCenterLayout->addWidget(infoHeaderSeparator);
491 infoCenterLayout->addWidget(textDesc);
492 infoCenterLayout->addWidget(textManage);
493 infoCenterLayout->addWidget(textDevel);
494 infoCenterLayout->addWidget(textLicense);
495 infoCenterLayout->insertSpacing(2, 10);
496 infoCenterLayout->insertSpacing(4, 10);
497 infoCenterLayout->insertSpacing(6, 10);
498 infoCenterLayout->insertStretch(8, 10);
499
500 infoPanelLayout->addLayout(infoHeaderLayout);
501 infoPanelLayout->addLayout(infoCenterLayout);
502 return infoPanelLayout;
503 }
504
505 void MainWindow::setupGUI()
437 { 506 {
438 // Create a central widget containing the main layout. 507 // Create a central widget containing the main layout.
439 QWidget *base = new QWidget; 508 QWidget *base = new QWidget;
440 509
441 // Layouts and Container 510 // Layouts and Container
741 810
742 /********************************** 811 /**********************************
743 * The info panel. 812 * The info panel.
744 **********************************/ 813 **********************************/
745 mInfoPanel = new QScrollArea; 814 mInfoPanel = new QScrollArea;
746 815 mInfoPanel->setLayout(createInfoPanelLayout());
747 QVBoxLayout *infoPanelLayout = new QVBoxLayout; 816
748 QHBoxLayout *infoHeaderLayout = new QHBoxLayout;
749 QVBoxLayout *infoHeaderTextLayout = new QVBoxLayout;
750 QVBoxLayout *infoCenterLayout = new QVBoxLayout;
751
752 QImage *infoLogoImage = new QImage(":/img/logo.png");
753 QLabel *infoLogo = new QLabel;
754 infoLogo->setBackgroundRole(QPalette::Base);
755 infoLogo->setPixmap(QPixmap::fromImage(*infoLogoImage));
756 QLabel *infoTitle = new QLabel("<h1>" + tr("TrustBridge") + "</h1>");
757 QString infoVersion = tr("Version: ");
758 infoVersion.append(QApplication::applicationVersion());
759 QLabel *appVersion = new QLabel(infoVersion);
760 appVersion->setTextInteractionFlags(
761 Qt::TextSelectableByMouse |
762 Qt::TextSelectableByKeyboard);
763
764 QFrame *infoHeaderSeparator = new QFrame();
765 infoHeaderSeparator->setFrameShape(QFrame::HLine);
766 infoHeaderSeparator->setFrameShadow(QFrame::Sunken);
767
768 infoHeaderTextLayout->addWidget(infoTitle);
769 infoHeaderTextLayout->addWidget(appVersion);
770 infoHeaderLayout->addWidget(infoLogo);
771 infoHeaderLayout->addLayout(infoHeaderTextLayout);
772 infoHeaderLayout->insertStretch(2, 10);
773
774 QLabel *textDesc = new QLabel(tr("TrustBridge is a root certificate"
775 " installer for Windows and Linux."));
776 textDesc->setTextInteractionFlags(
777 Qt::TextSelectableByMouse |
778 Qt::TextSelectableByKeyboard);
779 QLabel *textManage = new QLabel(tr("The root certificate lists are managed"
780 " by the German <a href=\"https://www.bsi.bund.de\">"
781 "Federal Office for Information Security (BSI)</a>.\n\n"));
782 textManage->setTextInteractionFlags(
783 Qt::TextBrowserInteraction |
784 Qt::TextSelectableByKeyboard);
785 QLabel *textDevel = new QLabel(tr("The software was developed by the companies"
786 " <a href=\"http://www.intevation.de\">Intevation GmbH</a> and "
787 " <a href=\"http://www.dn-systems.de\">DN-Systems GmbH</a>, <br>"
788 " contracted by the German Federal Office for Information Security (BSI).\n\n"));
789 textDevel->setTextInteractionFlags(
790 Qt::TextBrowserInteraction |
791 Qt::TextSelectableByKeyboard);
792 QLabel *textLicense = new QLabel(tr("TrustBridge is Free Software licensed"
793 " under GNU GPL v2+.\n\nCopyright (C) 2014 by Bundesamt für Sicherheit"
794 " in der Informationstechnik"));
795 textLicense->setTextInteractionFlags(
796 Qt::TextSelectableByMouse |
797 Qt::TextSelectableByKeyboard);
798
799 infoCenterLayout->addWidget(infoHeaderSeparator);
800 infoCenterLayout->addWidget(textDesc);
801 infoCenterLayout->addWidget(textManage);
802 infoCenterLayout->addWidget(textDevel);
803 infoCenterLayout->addWidget(textLicense);
804 infoCenterLayout->insertSpacing(2, 10);
805 infoCenterLayout->insertSpacing(4, 10);
806 infoCenterLayout->insertSpacing(6, 10);
807 infoCenterLayout->insertStretch(8, 10);
808
809 infoPanelLayout->addLayout(infoHeaderLayout);
810 infoPanelLayout->addLayout(infoCenterLayout);
811 mInfoPanel->setLayout(infoPanelLayout);
812 817
813 /******************************** 818 /********************************
814 * The main layout for pages. 819 * The main layout for pages.
815 ********************************/ 820 ********************************/
816 mInstallPanel->hide(); 821 mInstallPanel->hide();

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