[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.3/kdebase/workspace/plasma/applets/systemtray
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2009-09-01 19:40:57
Message-ID: 1251834057.745749.14742.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1018527 by aseigo:

backport "only update status when the status changes" improvement


 M  +2 -2      core/extendertask.cpp  
 M  +3 -2      core/job.cpp  
 M  +6 -1      core/job.h  
 M  +1 -0      core/manager.cpp  
 M  +33 -25    ui/jobwidget.cpp  
 M  +1 -0      ui/jobwidget.h  


--- branches/KDE/4.3/kdebase/workspace/plasma/applets/systemtray/core/extendertask.cpp \
#1018526:1018527 @@ -64,7 +64,7 @@
             this, SLOT(updateTask()));
     connect(manager, SIGNAL(jobRemoved(SystemTray::Job*)),
             this, SLOT(updateTask()));
-    connect(manager, SIGNAL(jobChanged(SystemTray::Job*)),
+    connect(manager, SIGNAL(jobStateChanged(SystemTray::Job*)),
             this, SLOT(updateTask()));
 
     Plasma::Extender *extender = qobject_cast<Plasma::Extender \
*>(m_systray->graphicsWidget()); @@ -139,7 +139,7 @@
     int runningJobs = 0;
     int pausedJobs = 0;
     int completedJobs = 0;
-    foreach (Job *job, m_manager->jobs()) {
+    foreach (const Job *job, m_manager->jobs()) {
         if (job->state() == Job::Running) {
             runningJobs++;
         } else if (job->state() == Job::Suspended) {
--- branches/KDE/4.3/kdebase/workspace/plasma/applets/systemtray/core/job.cpp \
#1018526:1018527 @@ -220,7 +220,8 @@
 {
     if (d->state != state) {
         d->state = state;
-        scheduleChangedSignal();
+        show();
+        emit stateChanged(this);
     }
 }
 
@@ -294,7 +295,7 @@
 
 void Job::show()
 {
-    if (state() == Job::Running) {
+    if (state() == Job::Running && !d->shown) {
         d->shown = true;
         emit ready(this);
     }
--- branches/KDE/4.3/kdebase/workspace/plasma/applets/systemtray/core/job.h \
#1018526:1018527 @@ -128,8 +128,13 @@
     void ready(SystemTray::Job *job);
 
     /**
-     * Emitted when the job changes
+     * Emitted when the job changes state
      */
+    void stateChanged(SystemTray::Job *job);
+
+    /**
+     * Emitted when the job details change
+     */
     void changed(SystemTray::Job *job);
 
     /**
--- branches/KDE/4.3/kdebase/workspace/plasma/applets/systemtray/core/manager.cpp \
#1018526:1018527 @@ -185,6 +185,7 @@
 {
     connect(job, SIGNAL(destroyed(SystemTray::Job*)), this, \
                SLOT(removeJob(SystemTray::Job*)));
     connect(job, SIGNAL(changed(SystemTray::Job*)), this, \
SIGNAL(jobChanged(SystemTray::Job*))); +    connect(job, \
SIGNAL(stateChanged(SystemTray::Job*)), this, \
                SIGNAL(jobStateChanged(SystemTray::Job*)));
     connect(job, SIGNAL(changed(SystemTray::Job*)), this, SLOT(updateTotals()));
     connect(job, SIGNAL(destroyed(SystemTray::Job*)), this, SLOT(updateTotals()));
 
--- branches/KDE/4.3/kdebase/workspace/plasma/applets/systemtray/ui/jobwidget.cpp \
#1018526:1018527 @@ -40,10 +40,10 @@
 
 JobWidget::JobWidget(SystemTray::Job *job, Plasma::ExtenderItem *parent)
     : QGraphicsWidget(parent),
-    m_extenderItem(parent),
-    m_job(job),
-    m_updateTimerId(0),
-    m_extenderItemDestroyed(false)
+      m_extenderItem(parent),
+      m_job(job),
+      m_updateTimerId(0),
+      m_extenderItemDestroyed(false)
 {
     Q_ASSERT(m_extenderItem);
 
@@ -99,6 +99,7 @@
         m_details->setText(i18n("More"));
 
         connect(m_job, SIGNAL(changed(SystemTray::Job*)), this, \
SLOT(scheduleUpdateJob())); +        connect(m_job, \
                SIGNAL(stateChanged(SystemTray::Job*)), this, \
                SLOT(updateJobState()));
         connect(m_job, SIGNAL(destroyed(SystemTray::Job*)), this, \
SLOT(destroyExtenderItem()));  connect(m_details, SIGNAL(clicked()),
                 this, SLOT(detailsClicked()));
@@ -167,32 +168,12 @@
     }
 }
 
-void JobWidget::updateJob()
+void JobWidget::updateJobState()
 {
     if (m_extenderItemDestroyed) {
         return;
     }
 
-    m_meter->setValue(m_job->percentage());
-
-    if (m_job) {
-        if (m_job->labels().count() > 0) {
-            labelName0 = m_job->labels().value(0).first;
-            label0 = m_job->labels().value(0).second;
-        }
-        if (m_job->labels().count() > 1) {
-            labelName1 = m_job->labels().value(1).first;
-            label1 = m_job->labels().value(1).second;
-        }
-        KConfigGroup cg = m_extenderItem->config();
-        cg.writeEntry("labelName0", labelName0);
-        cg.writeEntry("label0", label0);
-        cg.writeEntry("labelName1", labelName1);
-        cg.writeEntry("label1", label1);
-    }
-
-    updateLabels();
-
     //show the current status in the title.
     if (!m_job->error().isEmpty()) {
         m_extenderItem->setTitle(m_job->error());
@@ -216,7 +197,34 @@
         m_extenderItem->showCloseButton();
         m_details->hide();
     }
+}
 
+void JobWidget::updateJob()
+{
+    if (m_extenderItemDestroyed) {
+        return;
+    }
+
+    m_meter->setValue(m_job->percentage());
+
+    if (m_job) {
+        if (m_job->labels().count() > 0) {
+            labelName0 = m_job->labels().value(0).first;
+            label0 = m_job->labels().value(0).second;
+        }
+        if (m_job->labels().count() > 1) {
+            labelName1 = m_job->labels().value(1).first;
+            label1 = m_job->labels().value(1).second;
+        }
+        KConfigGroup cg = m_extenderItem->config();
+        cg.writeEntry("labelName0", labelName0);
+        cg.writeEntry("label0", label0);
+        cg.writeEntry("labelName1", labelName1);
+        cg.writeEntry("label1", label1);
+    }
+
+    updateLabels();
+
     //set the correct actions to visible.
     if (m_extenderItem->action("suspend")) {
         m_extenderItem->action("suspend")->setVisible(m_job->isSuspendable() &&
--- branches/KDE/4.3/kdebase/workspace/plasma/applets/systemtray/ui/jobwidget.h \
#1018526:1018527 @@ -64,6 +64,7 @@
 
     private:
         void updateLabels();
+        void updateJobState();
         void updateJob();
 
         Plasma::ExtenderItem *m_extenderItem;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic