[PATCH 2 of 2] (issue111) Rework Updates ui
Wald Commits
scm-commit at wald.intevation.org
Mon Sep 15 12:45:27 CEST 2014
# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1410777922 -7200
# Node ID 75a5bfe0525e7a22b3e134466215ee5cde4d0b30
# Parent b033a7d26f2ee3520ec217555885b2fa5054772e
(issue111) Rework Updates ui
This also concentrates label changes into the listChanged method.
diff -r b033a7d26f2e -r 75a5bfe0525e ui/mainwindow.cpp
--- a/ui/mainwindow.cpp Mon Sep 15 12:44:31 2014 +0200
+++ b/ui/mainwindow.cpp Mon Sep 15 12:45:22 2014 +0200
@@ -602,45 +602,13 @@
/* The header */
QVBoxLayout *updatesHeaderLayout = new QVBoxLayout;
+ QGridLayout *detailsLayout = new QGridLayout;
- /* Header 1: Update date and search button */
- QHBoxLayout *updateDateAndSearchButton = new QHBoxLayout;
+ /* Header 1: Action buttons and summary*/
mUpdatesHeader =
new QLabel("<h2>" + tr("Certificates unchanged")+ "</h2>");
- mLastCertUpdate =
- new QLabel(tr("Installed certificates from:"));
- mLastCertUpdateContents = new QLabel(QString());
- mLastCertUpdate->hide();
- mLastCertUpdateContents->hide();
- const QDateTime lastCheck = mSettings.value("lastUpdateCheck").toDateTime().toLocalTime();
- if (lastCheck.isValid()) {
- const QString lastUpdateCheck = QLocale::system().toString(lastCheck, DATETIME_FORMAT);
- mLastUpdateCheck =
- new QLabel(tr("Last successful update check:"));
- mLastUpdateCheckContents = new QLabel(lastUpdateCheck);
- } else {
- mLastUpdateCheck = new QLabel(tr("Last successful update check:"));
- mLastUpdateCheckContents = new QLabel(tr("No connection with the updateserver."));
- }
- QPushButton *searchUpdates = new QPushButton(" " + tr("Update"));
- searchUpdates->setFixedHeight(22);
- searchUpdates->setToolTip(tr("Check for Updates"));
- searchUpdates->setStyleSheet("font-size: 10px;");
- searchUpdates->setIcon(QIcon(":/img/update-list.png"));
- connect(searchUpdates, SIGNAL(clicked()), this, SLOT(checkUpdates()));
- updateDateAndSearchButton->addWidget(mLastUpdateCheckContents);
- updateDateAndSearchButton->addWidget(searchUpdates);
+ updatesHeaderLayout->addWidget(mUpdatesHeader);
- updatesHeaderLayout->addWidget(mUpdatesHeader);
-// TODO updatesHeaderLayout->addWidget(mLastUpdateCheck, 2, 0, 1, 1);
-// TODO updatesHeaderLayout->addLayout(updateDateAndSearchButton, 2, 1, 1, 1);
-// TODO updatesHeaderLayout->addWidget(mLastCertUpdate, 3, 0, 1, 1);
-// TODO updatesHeaderLayout->addWidget(mLastCertUpdateContents, 3, 1, 1, 1);
-
- /* Header 2: Action text and buttons */
- mUpdatesTip =
- new QLabel(tr("There are currently no changes for your certificate stores."));
- mUpdatesTip->setWordWrap(true);
QHBoxLayout *updatesHeaderActionButtonLayout = new QHBoxLayout;
mQuitButton = new QPushButton(" " + tr("Quit without saving"));
mQuitButton->setIcon(QIcon(":/img/application-exit.png"));
@@ -659,11 +627,10 @@
connect(mQuitButton, SIGNAL(clicked()), this, SLOT(closeApp()));
connect(mInstallButton, SIGNAL(clicked()), this, SLOT(checkAndInstallCerts()));
- // addWidget(*Widget, row, column, rowspan, colspan)
-// TODO updatesHeaderLayout->addWidget(mUpdatesTip, 5, 0, 1, 4);
updatesHeaderActionButtonLayout->addWidget(mInstallButton);
updatesHeaderActionButtonLayout->addWidget(mQuitButton);
updatesHeaderActionButtonLayout->addStretch(-1);
+
updatesHeaderLayout->addLayout(updatesHeaderActionButtonLayout);
updatesHeaderLayout->addSpacing(20);
@@ -673,6 +640,51 @@
line->setFrameShadow(QFrame::Sunken);
updatesHeaderLayout->addWidget(line);
+ updatesMainLayout->addLayout(updatesHeaderLayout);
+ /* Header 2: Details and update button */
+ mUpdatesDetailsHeader = new QLabel(QString());
+
+ QHBoxLayout *updateDateAndSearchButton = new QHBoxLayout;
+ mCertListVersion =
+ new QLabel(QString());
+ mCertListVersionContents = new QLabel(QString());
+ const QDateTime lastCheck = mSettings.value("lastUpdateCheck").toDateTime().toLocalTime();
+ if (lastCheck.isValid()) {
+ const QString lastUpdateCheck = QLocale::system().toString(lastCheck, DATETIME_FORMAT);
+ mLastUpdateCheck =
+ new QLabel(tr("Last successful update check:"));
+ mLastUpdateCheckContents = new QLabel(lastUpdateCheck);
+ } else {
+ mLastUpdateCheck = new QLabel(tr("Last successful update check:"));
+ mLastUpdateCheckContents = new QLabel(tr("No connection with the updateserver."));
+ }
+ QPushButton *searchUpdates = new QPushButton(" " + tr("Update"));
+ searchUpdates->setFixedHeight(18);
+ searchUpdates->setToolTip(tr("Check for Updates"));
+ searchUpdates->setStyleSheet("font-size: 10px;");
+ searchUpdates->setIcon(QIcon(":/img/update-list.png"));
+ connect(searchUpdates, SIGNAL(clicked()), this, SLOT(checkUpdates()));
+ updateDateAndSearchButton->addWidget(mLastUpdateCheckContents);
+ updateDateAndSearchButton->addWidget(searchUpdates);
+
+ mUpdatesTip =
+ new QLabel(QString());
+ mUpdatesTip->setWordWrap(true);
+
+ // addWidget(*Widget, row, column, rowspan, colspan)
+ updatesMainLayout->addWidget(mUpdatesDetailsHeader);
+ detailsLayout->addWidget(mLastUpdateCheck, 0, 0, 1, 1);
+ detailsLayout->addLayout(updateDateAndSearchButton, 0, 1, 1, 1);
+ detailsLayout->addWidget(mCertListVersion, 1, 0, 1, 1);
+ detailsLayout->addWidget(mCertListVersionContents, 1, 1, 1, 1);
+ detailsLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum), 2, 2, 1, 1);
+ detailsLayout->setColumnStretch(2, 1);
+
+ updatesMainLayout->addLayout(detailsLayout);
+
+ updatesMainLayout->addItem(new QSpacerItem(100, 10));
+ updatesMainLayout->addWidget(mUpdatesTip);
+
/* The central panels. */
QScrollArea *centralScrollArea = new QScrollArea;
QVBoxLayout *updatesCenterLayout = new QVBoxLayout;
@@ -723,10 +735,7 @@
this, SLOT(listChanged(int)));
mUpdatesRemove->hide();
- mUpdatesManualCertificates =
- new QLabel("<h3>" +
- tr("Manually changed certificates (%1)").arg(0) +
- "</h3>");
+ mUpdatesManualCertificates = new QLabel(QString());
mUpdatesDetailsManual = new QPushButton();
mUpdatesDetailsManual->setText(" " + tr("Details"));
mUpdatesDetailsManual->setToolTip(tr("Show details"));
@@ -738,7 +747,6 @@
this,
SLOT(toggleUpdatesManual()));
mUpdatesDetailsManual->hide();
- mUpdatesManualCertificates->hide();
updatesManualLayout->addWidget(mUpdatesManualCertificates);
updatesManualLayout->addWidget(mUpdatesDetailsManual);
updatesManualLayout->addStretch(1);
@@ -756,6 +764,7 @@
updatesCenterLayout->addWidget(mUpdatesNew);
updatesCenterLayout->addLayout(updatesRemoveLayout);
updatesCenterLayout->addWidget(mUpdatesRemove);
+ updatesCenterLayout->addSpacing(10);
updatesCenterLayout->addLayout(updatesManualLayout);
updatesCenterLayout->addWidget(mUpdatesManual);
@@ -766,7 +775,6 @@
centralScrollArea->setFrameShape(QFrame::NoFrame);
centralScrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- updatesMainLayout->addLayout(updatesHeaderLayout);
updatesMainLayout->addWidget(centralScrollArea);
updatesCenterLayout->addSpacerItem(new QSpacerItem(0, 0,
QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
@@ -1025,7 +1033,7 @@
mInstallButton->setText(" " + tr("Install certificates again"));
} else {
mQuitButton->setText(" " + tr("Quit without saving"));
- mUpdatesHeader->setText("<h2>" + tr("Changes to certificate stores (%1)")
+ mUpdatesHeader->setText("<h2>" + tr("Outstanding changes (%1)")
.arg(changeCount()) +
"</h2>");
mInstallButton->setText(" " + tr("Apply changes"));
@@ -1035,12 +1043,13 @@
mUpdatesDetailsManual->show();
mUpdatesDetailsManual->setIcon(QIcon(":/img/dialog-information_16px.png"));
mUpdatesDetailsManual->setToolTip(tr("Show details"));
- mUpdatesManualCertificates->show();
} else {
mUpdatesDetailsManual->hide();
- mUpdatesManualCertificates->hide();
mUpdatesManual->hide();
}
+ mUpdatesManualCertificates->setText("<h2>" +
+ tr("Manually changed certificates (%1)").arg(mUpdatesManual->certificates().size()) +
+ "</h2>");
if (mUpdatesNew->certificates().size()) {
mUpdatesNewCertificates->setText("<h3>" +
@@ -1073,6 +1082,36 @@
mUpdatesDetailsRemove->hide();
mUpdatesRemove->hide();
}
+
+ /* Update the details header */
+ if (mUpdatesRemove->certificates().size() ||
+ mUpdatesNew->certificates().size()) {
+ mUpdatesDetailsHeader->setText("<h2>" +
+ tr("New, recommended changes (%1/%2)")
+ .arg(mUpdatesRemove->selectedCertCount() +
+ mUpdatesNew->selectedCertCount())
+ .arg(mUpdatesRemove->certificates().size() +
+ mUpdatesNew->certificates().size()) +
+ "</h2>");
+ } else {
+ mUpdatesDetailsHeader->setText(QString::fromLatin1("<h2>") +
+ tr("No new recommendations") + QString::fromLatin1("</h2>"));
+ }
+
+ if (mListToInstall.isValid()) {
+ mCertListVersion->setText(tr("Certificatelist from:"));
+ mCertListVersionContents->setText(QLocale::system().toString(
+ mListToInstall.date().toLocalTime(), DATETIME_FORMAT));
+ } else {
+ if (mInstalledList.isValid()) {
+ mCertListVersion->setText(tr("Currently installed Certificatelist:"));
+ mCertListVersionContents->setText(QLocale::system().toString(
+ mInstalledList.date().toLocalTime(), DATETIME_FORMAT));
+ } else {
+ mCertListVersion->setText(tr("No Certificatelist installed."));
+ mCertListVersionContents->setText("");
+ }
+ }
}
void MainWindow::loadCertificateList()
@@ -1138,15 +1177,6 @@
}
}
- if (mInstalledList.date().isValid()) {
- mLastCertUpdateContents->setText(QLocale::system().toString(mInstalledList.date().toLocalTime(),
- DATETIME_FORMAT));
- mLastCertUpdate->show();
- mLastCertUpdateContents->show();
- }
- mUpdatesManualCertificates->setText("<h3>" +
- tr("Manually changed certificates (%1)").arg(0) +
- "</h3>");
listChanged(0);
}
@@ -1315,22 +1345,12 @@
else {
mUpdatesManual->removeCertificate(cert);
}
-
- mUpdatesManualCertificates->setText("<h3>" +
- tr("Manually changed certificates (%1)")
- .arg(mUpdatesManual->certificates().size()) +
- "</h3>");
}
void MainWindow::removeFromManual(bool state, const Certificate &cert)
{
mUpdatesManual->removeCertificate(cert);
- mUpdatesManualCertificates->setText("<h3>" +
- tr("Manually changed certificates (%1)")
- .arg(mUpdatesManual->certificates().size()) +
- "</h3>");
-
if (cert.isInstallCert()) {
mInstallList->setCertState(state, cert);
}
@@ -1384,42 +1404,48 @@
return;
}
+static void deactivateDetailsButton(QPushButton *btn) {
+ btn->setToolTip(QObject::tr("Hide details"));
+ btn->setText(QObject::tr("Less"));
+ btn->setIcon(QIcon(":/img/dialog-information_grey_16px.png"));
+}
+
+static void activateDetailsButton(QPushButton *btn) {
+ btn->setToolTip(QObject::tr("Show details"));
+ btn->setText(QObject::tr("Details"));
+ btn->setIcon(QIcon(":/img/dialog-information_16px.png"));
+}
+
void MainWindow::toggleUpdatesNew() {
if (!mUpdatesNew->isVisible()) {
- mUpdatesDetailsNew->setToolTip(tr("Hide details"));
- mUpdatesDetailsNew->setIcon(QIcon(":/img/dialog-information_grey_16px.png"));
mUpdatesNew->show();
+ deactivateDetailsButton(mUpdatesDetailsNew);
}
else {
mUpdatesNew->hide();
- mUpdatesDetailsNew->setToolTip(tr("Show details"));
- mUpdatesDetailsNew->setIcon(QIcon(":/img/dialog-information_16px.png"));
+ activateDetailsButton(mUpdatesDetailsNew);
}
}
void MainWindow::toggleUpdatesRemove() {
if (!mUpdatesRemove->isVisible()) {
- mUpdatesDetailsRemove->setToolTip(tr("Hide details"));
- mUpdatesDetailsRemove->setIcon(QIcon(":/img/dialog-information_grey_16px.png"));
mUpdatesRemove->show();
+ deactivateDetailsButton(mUpdatesDetailsRemove);
}
else {
mUpdatesRemove->hide();
- mUpdatesDetailsRemove->setToolTip(tr("Show details"));
- mUpdatesDetailsRemove->setIcon(QIcon(":/img/dialog-information_16px.png"));
+ activateDetailsButton(mUpdatesDetailsRemove);
}
}
void MainWindow::toggleUpdatesManual() {
if (!mUpdatesManual->isVisible()) {
- mUpdatesDetailsManual->setToolTip(tr("Hide details"));
- mUpdatesDetailsManual->setIcon(QIcon(":/img/dialog-information_grey_16px.png"));
mUpdatesManual->show();
+ deactivateDetailsButton(mUpdatesDetailsManual);
}
else {
- mUpdatesDetailsManual->setToolTip(tr("Show details"));
- mUpdatesDetailsManual->setIcon(QIcon(":/img/dialog-information_16px.png"));
mUpdatesManual->hide();
+ activateDetailsButton(mUpdatesDetailsManual);
}
}
diff -r b033a7d26f2e -r 75a5bfe0525e ui/mainwindow.h
--- a/ui/mainwindow.h Mon Sep 15 12:44:31 2014 +0200
+++ b/ui/mainwindow.h Mon Sep 15 12:45:22 2014 +0200
@@ -263,10 +263,9 @@
QWidget *mInfoWidget;
QLabel *mUpdatesHeader;
- QLabel *mLastCertUpdate;
- QLabel *mLastCertUpdateContents;
- QLabel *mSoftwareVersionLabel;
- QLabel *mSoftwareVersionContents;
+ QLabel *mUpdatesDetailsHeader;
+ QLabel *mCertListVersion;
+ QLabel *mCertListVersionContents;
QLabel *mLastUpdateCheck;
QLabel *mLastUpdateCheckContents;
QLabel *mUpdatesNewCertificates;
More information about the Trustbridge-commits
mailing list