diff ui/mainwindow.cpp @ 693:0fc1a20adaff

(Issue 27) Change Quit button text depending on changes or no changes.
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 01 Jul 2014 16:43:58 +0200
parents 3791a277f00b
children 25a73bfec359
line wrap: on
line diff
--- a/ui/mainwindow.cpp	Tue Jul 01 16:39:28 2014 +0200
+++ b/ui/mainwindow.cpp	Tue Jul 01 16:43:58 2014 +0200
@@ -549,8 +549,8 @@
 
     QPushButton *searchUpdates = new QPushButton(tr("Check for updates"));
     searchUpdates->setIcon(QIcon(":/img/edit-find.png"));
-    QPushButton *quitButton = new QPushButton(tr("Quit without saving"));
-    quitButton->setIcon(QIcon(":/img/application-exit.png"));
+    mQuitButton = new QPushButton(tr("Quit without saving"));
+    mQuitButton->setIcon(QIcon(":/img/application-exit.png"));
     QPushButton *installButton = new QPushButton(tr("Install updates"));
 #ifdef Q_OS_WIN
     if (is_admin()) {
@@ -560,12 +560,12 @@
 #else
     installButton->setIcon(QIcon(":/img/view-refresh.png"));
 #endif
-    connect(quitButton, SIGNAL(clicked()), this, SLOT(closeApp()));
+    connect(mQuitButton, SIGNAL(clicked()), this, SLOT(closeApp()));
     connect(installButton, SIGNAL(clicked()), this, SLOT(checkAndInstallCerts()));
     connect(searchUpdates, SIGNAL(clicked()), this, SLOT(checkUpdates()));
 
     updatesHeaderActionLayout->addWidget(installButton);
-    updatesHeaderActionLayout->addWidget(quitButton);
+    updatesHeaderActionLayout->addWidget(mQuitButton);
     updatesHeaderSearchLayout->insertStretch(0, 1);
     updatesHeaderSearchLayout->addWidget(searchUpdates);
 
@@ -807,6 +807,15 @@
 
 void MainWindow::listChanged(int selected)
 {
+    if (mUpdatesRemove->selectedCertCount() +
+        mUpdatesNew->selectedCertCount() +
+        mUpdatesManual->selectedCertCount() == 0) {
+        /* No changes */
+        mQuitButton->setText(tr("Quit"));
+    } else {
+        mQuitButton->setText(tr("Quit without saving"));
+    }
+
     mUpdatesHeader->setText("<h2>" + tr("Updates (%1/%2)")
             .arg(mUpdatesRemove->selectedCertCount() + mUpdatesNew->selectedCertCount())
             .arg(mUpdatesRemove->certificates().size() + mUpdatesNew->certificates().size()) +

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