[PATCH 4 of 5] Updated mainwindow layout and removed obsolete code

Wald Commits scm-commit at wald.intevation.org
Wed Jun 25 14:56:45 CEST 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1403700885 -7200
# Branch trustbridge-refactor
# Node ID f65503c1833bb17a4d86fe3387c2de2bf4fdfb40
# Parent  7cd6602e3fa2d164de941c819af0deb581c8325c
Updated mainwindow layout and removed obsolete code.

diff -r 7cd6602e3fa2 -r f65503c1833b ui/mainwindow.cpp
--- a/ui/mainwindow.cpp	Wed Jun 25 14:51:43 2014 +0200
+++ b/ui/mainwindow.cpp	Wed Jun 25 14:54:45 2014 +0200
@@ -59,9 +59,6 @@
 MainWindow::MainWindow(bool trayMode):
     mTrayMode(trayMode)
 {
-    mUpdatesNewSize = 0;
-    mUpdatesRemoveSize = 0;
-    mUpdatesManualSize = 0;
     createActions();
     createTrayIcon();
     createContent();
@@ -375,7 +372,6 @@
     QVBoxLayout *buttonBarLayout = new QVBoxLayout;
     QHBoxLayout *bottomLayout = new QHBoxLayout;
     QHBoxLayout *containerLayout = new QHBoxLayout;
-    QVBoxLayout *updatesPanelLayout = new QVBoxLayout;
 
     // The header (icon, about text)
     QImage *logoImage = new QImage(":/img/logo.png");
@@ -391,7 +387,9 @@
     headerLayout->setStretch(0, 0);
     headerLayout->setStretch(1, 10);
 
-    // Buttonbar
+    /***********************************
+     * The Buttonbar on the left side.
+     ***********************************/
     mButtonGroup = new QButtonGroup;
 
     QToolButton *updatesButton = new QToolButton;
@@ -448,49 +446,86 @@
     buttonBarLayout->insertStretch(3, 10);
     buttonBarLayout->addWidget(infoButton);
 
-    //The main panels.
-    //The updates page.
+    /********************************
+     * The main pages.
+     ********************************/
+
+    /********************************
+     * The updates page.
+     ********************************/
+    QVBoxLayout *updatesMainLayout = new QVBoxLayout;
     mUpdatesPanel = new QScrollArea;
+    QScrollArea *updatesContent = new QScrollArea;
+//    updatesContent->setFrameShape(QFrame::NoFrame);
     mUpdatesWidget = new QWidget;
+
+    /* The updates header */
     QHBoxLayout *updatesHeaderLayout = new QHBoxLayout;
     QVBoxLayout *updatesHeaderTextLayout = new QVBoxLayout;
-    QVBoxLayout *updatesHeaderSettLayout = new QVBoxLayout;
+    QVBoxLayout *updatesHeaderButtonLayout = new QVBoxLayout;
+    QHBoxLayout *updatesHeaderActionLayout = new QHBoxLayout;
+    QHBoxLayout *updatesHeaderSearchLayout = new QHBoxLayout;
 
     mUpdatesHeader =
-        new QLabel("<h2>" + tr("Updates (%1/%2)").arg(2).arg(4)+ "</h2>");
+        new QLabel("<h2>" + tr("Updates (%1/%2)").arg(0).arg(0)+ "</h2>");
     mLastCertUpdate =
-        new QLabel(tr("Last certificate update: %1").arg("today"));
+        new QLabel(tr("Last certificate update: %1").arg(""));
     mLastSWupdate =
-        new QLabel(tr("Last Software update: %1").arg("today"));
+        new QLabel(tr("Last Software update: %1").arg(""));
+    QLabel *updatesTip =
+        new QLabel("<h4>" + tr("The following certificate changes are recommended.") + "</h4>");
+
     updatesHeaderTextLayout->addWidget(mUpdatesHeader);
     updatesHeaderTextLayout->addWidget(mLastCertUpdate);
     updatesHeaderTextLayout->addWidget(mLastSWupdate);
+    updatesHeaderTextLayout->addSpacing(10);
+    updatesHeaderTextLayout->addWidget(updatesTip);
 
     QPushButton *searchUpdates = new QPushButton(tr("Search for Updates"));
+    searchUpdates->setIcon(QIcon(":/img/system-search.png"));
+    QPushButton *quitButton = new QPushButton(tr("Quit without saving"));
+    quitButton->setIcon(QIcon(":/img/system-shutdown.png"));
+    QPushButton *installButton = new QPushButton(tr("Update"));
+#ifdef Q_OS_WIN
+    if (is_admin()) {
+        QIcon uacShield = QApplication::style()->standardIcon(QStyle::SP_VistaShield);
+        installButton->setIcon(uacShield);
+    }
+#else
+    installButton->setIcon(QIcon(":/img/edit-redo.png"));
+#endif
+    connect(quitButton, SIGNAL(clicked()), this, SLOT(closeApp()));
+    connect(installButton, SIGNAL(clicked()), this, SLOT(installCerts()));
     connect(searchUpdates, SIGNAL(clicked()), this, SLOT(checkUpdates()));
-    updatesHeaderSettLayout->insertStretch(0, 10);
-    updatesHeaderSettLayout->addWidget(searchUpdates);
+
+    updatesHeaderActionLayout->addWidget(installButton);
+    updatesHeaderActionLayout->addWidget(quitButton);
+    updatesHeaderSearchLayout->insertStretch(0, 1);
+    updatesHeaderSearchLayout->addWidget(searchUpdates);
+
+    updatesHeaderButtonLayout->addLayout(updatesHeaderSearchLayout);
+    updatesHeaderButtonLayout->addLayout(updatesHeaderActionLayout);
+
     updatesHeaderLayout->addLayout(updatesHeaderTextLayout);
     updatesHeaderLayout->insertStretch(1, 10);
-    updatesHeaderLayout->addLayout(updatesHeaderSettLayout);
+    updatesHeaderLayout->addLayout(updatesHeaderButtonLayout);
 
+    /* The central panels. */
     QVBoxLayout *updatesCenterLayout = new QVBoxLayout;
     QHBoxLayout *updatesNewLayout = new QHBoxLayout;
     QHBoxLayout *updatesRemoveLayout = new QHBoxLayout;
     QHBoxLayout *updatesManualLayout = new QHBoxLayout;
-    QLabel *updatesTip =
-        new QLabel(tr("The following certificate changes are recommended."));
     mUpdatesNewCertificates =
         new QLabel("<h3>" +
-            tr("Install new Certificates (%1/%2)").arg(2).arg(2) +
+            tr("Install new Certificates (%1/%2)").arg(0).arg(0) +
             "</h3>");
-    QPushButton *updatesDetailsNew = new QPushButton(tr("Details"));
-    connect(updatesDetailsNew,
+    mUpdatesDetailsNew = new QPushButton(tr("Show Details"));
+    connect(mUpdatesDetailsNew,
         SIGNAL(clicked()),
         this,
         SLOT(toggleUpdatesNew()));
     updatesNewLayout->addWidget(mUpdatesNewCertificates);
-    updatesNewLayout->addWidget(updatesDetailsNew);
+    updatesNewLayout->addWidget(mUpdatesDetailsNew);
     updatesNewLayout->insertStretch(2, 10);
     mUpdatesNew = new CertificateListWidget(this);
     connect(mUpdatesNew, SIGNAL(certListChanged(int)),
@@ -499,15 +534,15 @@
 
     mUpdatesRemoveCertificates =
         new QLabel("<h3>" +
-            tr("Remove insecure Certificates (%1/%2)").arg(2).arg(2) +
+            tr("Remove insecure Certificates (%1/%2)").arg(0).arg(0) +
             "</h3>");
-    QPushButton *updatesDetailsRemove = new QPushButton(tr("Details"));
-    connect(updatesDetailsRemove,
+    mUpdatesDetailsRemove = new QPushButton(tr("Show Details"));
+    connect(mUpdatesDetailsRemove,
         SIGNAL(clicked()),
         this,
         SLOT(toggleUpdatesRemove()));
     updatesRemoveLayout->addWidget(mUpdatesRemoveCertificates);
-    updatesRemoveLayout->addWidget(updatesDetailsRemove);
+    updatesRemoveLayout->addWidget(mUpdatesDetailsRemove);
     updatesRemoveLayout->insertStretch(2, 10);
     mUpdatesRemove = new CertificateListWidget(this);
     connect(mUpdatesRemove, SIGNAL(certListChanged(int)),
@@ -516,68 +551,43 @@
 
     mUpdatesManualCertificates =
         new QLabel("<h3>" +
-            tr("Manualy changed Certificates (%1)").arg(2) +
+            tr("Manualy changed Certificates (%1)").arg(0) +
             "</h3>");
-    QPushButton *updatesDetailsManual = new QPushButton(tr("Details"));
-    connect(updatesDetailsManual,
+    mUpdatesDetailsManual = new QPushButton(tr("Show Details"));
+    connect(mUpdatesDetailsManual,
         SIGNAL(clicked()),
         this,
         SLOT(toggleUpdatesManual()));
     updatesManualLayout->addWidget(mUpdatesManualCertificates);
-    updatesManualLayout->addWidget(updatesDetailsManual);
+    updatesManualLayout->addWidget(mUpdatesDetailsManual);
     updatesManualLayout->insertStretch(2, 10);
     mUpdatesManual = new CertificateListWidget(this);
     mUpdatesManual->hide();
     connect(mUpdatesManual, SIGNAL(certChanged(bool, const Certificate&)),
         this, SLOT(removeFromManual(bool, const Certificate&)));
 
-    QHBoxLayout *updatesBottomLayout = new QHBoxLayout;
-    QPushButton *quitButton = new QPushButton(tr("Quit without saving"));
-    QPushButton *installButton = new QPushButton(tr("Update"));
-#ifdef Q_OS_WIN
-    if (is_admin()) {
-        QIcon uacShield = QApplication::style()->standardIcon(QStyle::SP_VistaShield);
-        installButton->setIcon(uacShield);
-    }
-#endif
-    connect(quitButton, SIGNAL(clicked()), this, SLOT(closeApp()));
-    connect(installButton, SIGNAL(clicked()), this, SLOT(installCerts()));
-    updatesBottomLayout->insertStretch(0, 10);
-    updatesBottomLayout->addWidget(installButton);
-    updatesBottomLayout->addWidget(quitButton);
-    updatesBottomLayout->setAlignment(Qt::AlignBottom);
-
     updatesNewLayout->setAlignment(Qt::AlignTop);
     updatesRemoveLayout->setAlignment(Qt::AlignTop);
     updatesManualLayout->setAlignment(Qt::AlignTop);
-    updatesCenterLayout->addWidget(updatesTip, 0, Qt::AlignTop);
     updatesCenterLayout->addLayout(updatesNewLayout);
-//    updatesCenterLayout->setStretchFactor(updatesNewLayout, 100);
-    updatesCenterLayout->addWidget(mUpdatesNew, 1, Qt::AlignTop);
+    updatesCenterLayout->addWidget(mUpdatesNew);
     updatesCenterLayout->addLayout(updatesRemoveLayout);
-//    updatesCenterLayout->setStretchFactor(updatesRemoveLayout, 100);
-    updatesCenterLayout->addWidget(mUpdatesRemove, 1, Qt::AlignTop);
+    updatesCenterLayout->addWidget(mUpdatesRemove);
     updatesCenterLayout->addLayout(updatesManualLayout);
-//    updatesCenterLayout->setStretchFactor(updatesManualLayout, 100);
-    updatesCenterLayout->addWidget(mUpdatesManual, 1, Qt::AlignTop);
-    updatesCenterLayout->insertStretch(7, 0);
-    updatesCenterLayout->addLayout(updatesBottomLayout);
+    updatesCenterLayout->addWidget(mUpdatesManual);
+    updatesCenterLayout->addStretch(1);
 
+    updatesCenterLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
+    mUpdatesWidget->setLayout(updatesCenterLayout);
+    updatesContent->setWidget(mUpdatesWidget);
 
-    QFrame *updatesPanelSeparator = new QFrame();
-    updatesPanelSeparator->setFrameShape(QFrame::HLine);
-    updatesPanelSeparator->setFrameShadow(QFrame::Sunken);
-    updatesPanelLayout->addLayout(updatesHeaderLayout);
-    updatesPanelLayout->addWidget(updatesPanelSeparator);
-    updatesPanelLayout->addLayout(updatesCenterLayout);
-    updatesPanelLayout->setStretchFactor(updatesCenterLayout, 1);
-    //updatesPanelLayout->insertStretch(3, 2);
-    //updatesPanelLayout->addLayout(updatesBottomLayout);
-    mUpdatesWidget->setLayout(updatesPanelLayout);
-    mUpdatesWidget->setMinimumSize(QSize(820, 440));
-    mUpdatesPanel->setWidget(mUpdatesWidget);
+    updatesMainLayout->addLayout(updatesHeaderLayout);
+    updatesMainLayout->addWidget(updatesContent);
+    mUpdatesPanel->setLayout(updatesMainLayout);
 
-    // Panel for trusted certificates.
+    /*********************************
+     * Panel for trusted certificates.
+     *********************************/
     mInstallPanel = new QScrollArea;
 
     QVBoxLayout *installPanelLayout = new QVBoxLayout;
@@ -606,7 +616,9 @@
     installPanelLayout->addWidget(mInstallList);
     mInstallPanel->setLayout(installPanelLayout);
 
-    // Panel for insecure certificates.
+    /**********************************
+     * Panel for insecure certificates.
+     **********************************/
     mRemovePanel = new QScrollArea;
     QVBoxLayout *removePanelLayout = new QVBoxLayout;
     QVBoxLayout *removeHeaderLayout = new QVBoxLayout;
@@ -632,7 +644,9 @@
     removePanelLayout->addWidget(mRemoveList);
     mRemovePanel->setLayout(removePanelLayout);
 
-    // Info panel.
+    /**********************************
+     * The info panel.
+     **********************************/
     mInfoPanel = new QScrollArea;
 
     QVBoxLayout *infoPanelLayout = new QVBoxLayout;
@@ -701,7 +715,9 @@
     infoPanelLayout->addLayout(infoCenterLayout);
     mInfoPanel->setLayout(infoPanelLayout);
 
-    // The main layout for pages.
+    /********************************
+     * The main layout for pages.
+     ********************************/
     mInstallPanel->hide();
     mRemovePanel->hide();
     mInfoPanel->hide();
@@ -713,12 +729,7 @@
     centerLayout->addLayout(buttonBarLayout);
     centerLayout->addLayout(containerLayout);
 
-    QFrame *topSeparator = new QFrame();
-    topSeparator->setFrameShape(QFrame::HLine);
-    topSeparator->setFrameShadow(QFrame::Sunken);
-
     mainLayout->addLayout(headerLayout);
-    mainLayout->addWidget(topSeparator);
     mainLayout->addLayout(centerLayout);
     mainLayout->addLayout(bottomLayout);
     base->setLayout(mainLayout);
@@ -769,9 +780,6 @@
                 mRemoveList->addCertificate(cert, state, !state);
             }
         }
-        // Set the date of the old list.
-//        mCurrentListDate->setText(tr("Current List Date: %1")
-//            .arg(mInstalledList.date().toString()));
     }
     else {
         // Sort and filter both lists.
@@ -812,9 +820,6 @@
                 .arg(newRemoveCerts.size() + newInstallCerts.size()) + "</h2>");
         mLastCertUpdate->setText(tr("Last certificate update: %1")
             .arg(mInstalledList.date().toString()));
-/*        mCurrentListDate->setText(tr("Current List Date: %1")
-            .arg(mInstalledList.date().toString()));
-        mNewListDate->setText(tr("New List Date: %1").arg(mListToInstall.date().toString()));*/
     }
     mUpdatesNewCertificates->setText("<h3>" +
             tr("Install new Certificates (%1/%2)")
@@ -992,7 +997,6 @@
 }
 
 void MainWindow::toggleUpdatesNew() {
-    QSize old = mUpdatesWidget->size();
     if (!mUpdatesNew->isVisible()) {
         mUpdatesNew->show();
         if (mUpdatesNewSize == 0) {
diff -r 7cd6602e3fa2 -r f65503c1833b ui/mainwindow.h
--- a/ui/mainwindow.h	Wed Jun 25 14:51:43 2014 +0200
+++ b/ui/mainwindow.h	Wed Jun 25 14:54:45 2014 +0200
@@ -197,9 +197,10 @@
     CertificateListWidget *mUpdatesManual;
     CertificateListWidget *mInstallList;
     CertificateListWidget *mRemoveList;
-    int mUpdatesNewSize;
-    int mUpdatesRemoveSize;
-    int mUpdatesManualSize;
+
+    QPushButton *mUpdatesDetailsNew;
+    QPushButton *mUpdatesDetailsRemove;
+    QPushButton *mUpdatesDetailsManual;
 };
 
 #endif // MAINWINDOW_H


More information about the Trustbridge-commits mailing list