[PATCH 1 of 7] Factor out Info Panel creation

Wald Commits scm-commit at wald.intevation.org
Fri Jul 4 16:17:44 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1404465334 -7200
# Node ID 5f0fca113ff415b748ec55c9c6ff81ed560ad7a0
# Parent  ea8d13590cbd1fa87d46a43f29f4e75653d65a49
Factor out Info Panel creation.

diff -r ea8d13590cbd -r 5f0fca113ff4 ui/mainwindow.cpp
--- 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;
+    mInfoPanel->setLayout(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>" + 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);
-
-    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.
diff -r ea8d13590cbd -r 5f0fca113ff4 ui/mainwindow.h
--- 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 ?*/


More information about the Trustbridge-commits mailing list