changeset 653:39f03316f675 trustbridge-refactor

Change button text when toggling details and select the first list item.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 25 Jun 2014 14:56:19 +0200
parents f65503c1833b
children 129e611eaf50 1bb40cbb1e39
files ui/certificatelistwidget.cpp ui/certificatelistwidget.h ui/mainwindow.cpp
diffstat 3 files changed, 24 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/ui/certificatelistwidget.cpp	Wed Jun 25 14:54:45 2014 +0200
+++ b/ui/certificatelistwidget.cpp	Wed Jun 25 14:56:19 2014 +0200
@@ -235,3 +235,11 @@
     }
     return false;
 }
+
+void CertificateListWidget::setSelected(int index)
+{
+    mCertificateList->setFocus();
+    if (mCertificateList->count() > 0) {
+        mCertificateList->item(0)->setSelected(true);
+    }
+}
--- a/ui/certificatelistwidget.h	Wed Jun 25 14:54:45 2014 +0200
+++ b/ui/certificatelistwidget.h	Wed Jun 25 14:56:19 2014 +0200
@@ -38,6 +38,7 @@
     QList<Certificate> certificateList();
     int selectedCertCount();
     bool contains(const Certificate &cert);
+    void setSelected(int index);
 
 private:
     void setupGUI();
--- a/ui/mainwindow.cpp	Wed Jun 25 14:54:45 2014 +0200
+++ b/ui/mainwindow.cpp	Wed Jun 25 14:56:19 2014 +0200
@@ -998,44 +998,42 @@
 
 void MainWindow::toggleUpdatesNew() {
     if (!mUpdatesNew->isVisible()) {
+        mUpdatesDetailsNew->setText(tr("Hide Details"));
         mUpdatesNew->show();
-        if (mUpdatesNewSize == 0) {
-            mUpdatesNewSize = mUpdatesNew->height();
-        }
-        mUpdatesWidget->resize(old.width(), old.height() + mUpdatesNewSize);
+        mUpdatesNew->setSelected(0);
     }
     else {
+        mUpdatesNew->hide();
+        mUpdatesDetailsNew->setText(tr("Show Details"));
+        QSize old = mUpdatesWidget->size();
         mUpdatesWidget->resize(old.width(), old.height() - mUpdatesNew->height());
-        mUpdatesNew->hide();
     }
 }
 
 void MainWindow::toggleUpdatesRemove() {
-    QSize old = mUpdatesWidget->size();
     if (!mUpdatesRemove->isVisible()) {
+        mUpdatesDetailsRemove->setText(tr("Hide Details"));
         mUpdatesRemove->show();
-        if (mUpdatesRemoveSize == 0) {
-            mUpdatesRemoveSize = mUpdatesRemove->height();
-        }
-        mUpdatesWidget->resize(old.width(), old.height() + mUpdatesRemoveSize);
+        mUpdatesRemove->setSelected(0);
     }
     else {
+        mUpdatesRemove->hide();
+        mUpdatesDetailsRemove->setText(tr("Show Details"));
+        QSize old = mUpdatesWidget->size();
         mUpdatesWidget->resize(old.width(), old.height() - mUpdatesRemove->height());
-        mUpdatesRemove->hide();
     }
 }
 
 void MainWindow::toggleUpdatesManual() {
-    QSize old = mUpdatesWidget->size();
     if (!mUpdatesManual->isVisible()) {
+        mUpdatesDetailsManual->setText(tr("Hide Details"));
         mUpdatesManual->show();
-        if (mUpdatesManualSize == 0) {
-            mUpdatesManualSize = mUpdatesManual->height();
-        }
-        mUpdatesWidget->resize(old.width(), old.height() + mUpdatesManualSize);
+        mUpdatesManual->setSelected(0);
     }
     else {
+        mUpdatesDetailsManual->setText(tr("Show Details"));
+        mUpdatesManual->hide();
+        QSize old = mUpdatesWidget->size();
         mUpdatesWidget->resize(old.width(), old.height() - mUpdatesManual->height());
-        mUpdatesManual->hide();
     }
 }

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