diff ui/mainwindow.cpp @ 722:b0929968562a

(Issue31) Add textoverlaybutton to show a text in the button.
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 02 Jul 2014 18:35:30 +0200
parents 49bf73b5c7de
children d39b5b65366e
line wrap: on
line diff
--- a/ui/mainwindow.cpp	Wed Jul 02 17:04:02 2014 +0200
+++ b/ui/mainwindow.cpp	Wed Jul 02 18:35:30 2014 +0200
@@ -466,7 +466,7 @@
      ***********************************/
     mButtonGroup = new QButtonGroup;
 
-    QToolButton *updatesButton = new QToolButton;
+    TextOverlayButton *updatesButton = new TextOverlayButton;
     updatesButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
     updatesButton->setIcon(QIcon(":/img/view-refresh.png"));
     updatesButton->setIconSize(QSize(40, 40));
@@ -476,6 +476,9 @@
     updatesButton->setCheckable(true);
     updatesButton->setChecked(true);
 
+    connect(this, SIGNAL(changesChanged(const QString&)),
+            updatesButton, SLOT(setOverlay(const QString&)));
+
     QToolButton *allInstallButton = new QToolButton;
     allInstallButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
     allInstallButton->setIcon(QIcon(":/img/document-encrypt.png"));
@@ -831,8 +834,8 @@
 void MainWindow::listChanged(int selected)
 {
     Q_UNUSED (selected);
-    mChangeCount = mUpdatesRemove->selectedCertCount() +
-        mUpdatesNew->selectedCertCount() + mUpdatesManual->certificates().size();
+    setChangeCount(mUpdatesRemove->selectedCertCount() +
+        mUpdatesNew->selectedCertCount() + mUpdatesManual->certificates().size());
 
     /* Show a different tip in case of manual changes, updates aviailable, updates and manual
      * changes available */
@@ -1169,7 +1172,7 @@
     if (!mUpdatesNew->isVisible()) {
         mUpdatesDetailsNew->setText(tr("Hide details"));
         mUpdatesNew->show();
-        mUpdatesNew->setSelected(0);
+        mUpdatesNew->setSelected(mUpdatesNew->selected());
     }
     else {
         mUpdatesNew->hide();
@@ -1233,3 +1236,11 @@
 {
     return mChangeCount;
 }
+
+void MainWindow::setChangeCount(int cnt)
+{
+    if (mChangeCount != cnt) {
+        mChangeCount = cnt;
+        emit changesChanged(QString("%1").arg(cnt));
+    }
+}

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