changeset 739:5f0fca113ff4

Factor out Info Panel creation.
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 04 Jul 2014 11:15:34 +0200
parents ea8d13590cbd
children 8efd10afb883
files ui/mainwindow.cpp ui/mainwindow.h
diffstat 2 files changed, 73 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/ui/mainwindow.cpp	Fri Jul 04 12:32:51 2014 +0200
+++ b/ui/mainwindow.cpp	Fri Jul 04 11:15:34 2014 +0200
@@ -80,7 +80,7 @@
 {
     createActions();
     createTrayIcon();
-    createContent();
+    setupGUI();
     resize(1065, 600);
     setMinimumWidth(760);
     qRegisterMetaType<SSLConnection::ErrorCode>("SSLConnection::ErrorCode");
@@ -433,7 +433,76 @@
     connect(mTrayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked()));
 }
 
-void MainWindow::createContent()
+QLayout * createInfoPanelLayout()
+{
+    QVBoxLayout *infoPanelLayout = new QVBoxLayout;
+    QHBoxLayout *infoHeaderLayout = new QHBoxLayout;
+    QVBoxLayout *infoHeaderTextLayout = new QVBoxLayout;
+    QVBoxLayout *infoCenterLayout = new QVBoxLayout;
+
+    QImage *infoLogoImage = new QImage(":/img/logo.png");
+    QLabel *infoLogo = new QLabel;
+    infoLogo->setBackgroundRole(QPalette::Base);
+    infoLogo->setPixmap(QPixmap::fromImage(*infoLogoImage));
+    QLabel *infoTitle = new QLabel("<h1>" + QObject::tr("TrustBridge") + "</h1>");
+    QString infoVersion = QObject::tr("Version: ");
+    infoVersion.append(QApplication::applicationVersion());
+    QLabel *appVersion = new QLabel(infoVersion);
+    appVersion->setTextInteractionFlags(
+        Qt::TextSelectableByMouse |
+        Qt::TextSelectableByKeyboard);
+
+    QFrame *infoHeaderSeparator = new QFrame();
+    infoHeaderSeparator->setFrameShape(QFrame::HLine);
+    infoHeaderSeparator->setFrameShadow(QFrame::Sunken);
+
+    infoHeaderTextLayout->addWidget(infoTitle);
+    infoHeaderTextLayout->addWidget(appVersion);
+    infoHeaderLayout->addWidget(infoLogo);
+    infoHeaderLayout->addLayout(infoHeaderTextLayout);
+    infoHeaderLayout->insertStretch(2, 10);
+
+    QLabel *textDesc = new QLabel(QObject::tr("TrustBridge is a root certificate"
+        " installer for Windows and Linux."));
+    textDesc->setTextInteractionFlags(
+        Qt::TextSelectableByMouse |
+        Qt::TextSelectableByKeyboard);
+    QLabel *textManage = new QLabel(QObject::tr("The root certificate lists are managed"
+        " by the German <a href=\"https://www.bsi.bund.de\">"
+        "Federal Office for Information Security (BSI)</a>.\n\n"));
+    textManage->setTextInteractionFlags(
+        Qt::TextBrowserInteraction |
+        Qt::TextSelectableByKeyboard);
+    QLabel *textDevel = new QLabel(QObject::tr("The software was developed by the companies"
+        " <a href=\"http://www.intevation.de\">Intevation GmbH</a> and "
+        " <a href=\"http://www.dn-systems.de\">DN-Systems GmbH</a>, <br>"
+        " contracted by the German Federal Office for Information Security (BSI).\n\n"));
+    textDevel->setTextInteractionFlags(
+        Qt::TextBrowserInteraction |
+        Qt::TextSelectableByKeyboard);
+    QLabel *textLicense = new QLabel(QObject::tr("TrustBridge is Free Software licensed"
+        " under GNU GPL v2+.\n\nCopyright (C) 2014 by Bundesamt für Sicherheit"
+        " in der Informationstechnik"));
+    textLicense->setTextInteractionFlags(
+        Qt::TextSelectableByMouse |
+        Qt::TextSelectableByKeyboard);
+
+    infoCenterLayout->addWidget(infoHeaderSeparator);
+    infoCenterLayout->addWidget(textDesc);
+    infoCenterLayout->addWidget(textManage);
+    infoCenterLayout->addWidget(textDevel);
+    infoCenterLayout->addWidget(textLicense);
+    infoCenterLayout->insertSpacing(2, 10);
+    infoCenterLayout->insertSpacing(4, 10);
+    infoCenterLayout->insertSpacing(6, 10);
+    infoCenterLayout->insertStretch(8, 10);
+
+    infoPanelLayout->addLayout(infoHeaderLayout);
+    infoPanelLayout->addLayout(infoCenterLayout);
+    return infoPanelLayout;
+}
+
+void MainWindow::setupGUI()
 {
     // Create a central widget containing the main layout.
     QWidget *base = new QWidget;
@@ -743,72 +812,8 @@
      * The info panel.
      **********************************/
     mInfoPanel = new QScrollArea;
-
-    QVBoxLayout *infoPanelLayout = new QVBoxLayout;
-    QHBoxLayout *infoHeaderLayout = new QHBoxLayout;
-    QVBoxLayout *infoHeaderTextLayout = new QVBoxLayout;
-    QVBoxLayout *infoCenterLayout = new QVBoxLayout;
-
-    QImage *infoLogoImage = new QImage(":/img/logo.png");
-    QLabel *infoLogo = new QLabel;
-    infoLogo->setBackgroundRole(QPalette::Base);
-    infoLogo->setPixmap(QPixmap::fromImage(*infoLogoImage));
-    QLabel *infoTitle = new QLabel("<h1>" + tr("TrustBridge") + "</h1>");
-    QString infoVersion = tr("Version: ");
-    infoVersion.append(QApplication::applicationVersion());
-    QLabel *appVersion = new QLabel(infoVersion);
-    appVersion->setTextInteractionFlags(
-        Qt::TextSelectableByMouse |
-        Qt::TextSelectableByKeyboard);
-
-    QFrame *infoHeaderSeparator = new QFrame();
-    infoHeaderSeparator->setFrameShape(QFrame::HLine);
-    infoHeaderSeparator->setFrameShadow(QFrame::Sunken);
-
-    infoHeaderTextLayout->addWidget(infoTitle);
-    infoHeaderTextLayout->addWidget(appVersion);
-    infoHeaderLayout->addWidget(infoLogo);
-    infoHeaderLayout->addLayout(infoHeaderTextLayout);
-    infoHeaderLayout->insertStretch(2, 10);
+    mInfoPanel->setLayout(createInfoPanelLayout());
 
-    QLabel *textDesc = new QLabel(tr("TrustBridge is a root certificate"
-        " installer for Windows and Linux."));
-    textDesc->setTextInteractionFlags(
-        Qt::TextSelectableByMouse |
-        Qt::TextSelectableByKeyboard);
-    QLabel *textManage = new QLabel(tr("The root certificate lists are managed"
-        " by the German <a href=\"https://www.bsi.bund.de\">"
-        "Federal Office for Information Security (BSI)</a>.\n\n"));
-    textManage->setTextInteractionFlags(
-        Qt::TextBrowserInteraction |
-        Qt::TextSelectableByKeyboard);
-    QLabel *textDevel = new QLabel(tr("The software was developed by the companies"
-        " <a href=\"http://www.intevation.de\">Intevation GmbH</a> and "
-        " <a href=\"http://www.dn-systems.de\">DN-Systems GmbH</a>, <br>"
-        " contracted by the German Federal Office for Information Security (BSI).\n\n"));
-    textDevel->setTextInteractionFlags(
-        Qt::TextBrowserInteraction |
-        Qt::TextSelectableByKeyboard);
-    QLabel *textLicense = new QLabel(tr("TrustBridge is Free Software licensed"
-        " under GNU GPL v2+.\n\nCopyright (C) 2014 by Bundesamt für Sicherheit"
-        " in der Informationstechnik"));
-    textLicense->setTextInteractionFlags(
-        Qt::TextSelectableByMouse |
-        Qt::TextSelectableByKeyboard);
-
-    infoCenterLayout->addWidget(infoHeaderSeparator);
-    infoCenterLayout->addWidget(textDesc);
-    infoCenterLayout->addWidget(textManage);
-    infoCenterLayout->addWidget(textDevel);
-    infoCenterLayout->addWidget(textLicense);
-    infoCenterLayout->insertSpacing(2, 10);
-    infoCenterLayout->insertSpacing(4, 10);
-    infoCenterLayout->insertSpacing(6, 10);
-    infoCenterLayout->insertStretch(8, 10);
-
-    infoPanelLayout->addLayout(infoHeaderLayout);
-    infoPanelLayout->addLayout(infoCenterLayout);
-    mInfoPanel->setLayout(infoPanelLayout);
 
     /********************************
      * The main layout for pages.
--- a/ui/mainwindow.h	Fri Jul 04 12:32:51 2014 +0200
+++ b/ui/mainwindow.h	Fri Jul 04 11:15:34 2014 +0200
@@ -194,7 +194,7 @@
 
     void createTrayIcon();
     void createActions();
-    void createContent();
+    void setupGUI();
     void loadCertificateList();
 
     /* Are we running in tray mode ?*/

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