branches/KDE/4.5/kdebase/workspace/plasma/generic/applets/battery

Sebastian Kügler sebas at kde.org
Tue Aug 3 21:38:21 CEST 2010


SVN commit 1158800 by sebas:


    Revert r1157716: control amount of brightness sliders
    
    This patch produces 4 sliders on my machine (thinkpad T60).
    
    As 4 sliders on OK machines are worse than 1 slider We have to  revert it
    for now until we find a proper solution for it. I don't see anything I'd
    happily commit to the stable branch, so I'll backport this one and we'll
    let the bug in until we have something that works *and* doesn't break
    machines that are otherwise OK.
    
    CCBUG:199520
    CCMAIL:zajec5 at gmail.com

Dirk, any way we can get this one into 4.5.0 still? (It was about time that I'd 
be the one coming with last minute screw-ups and asking everybody to re-roll. 
Sorry, really. :/)

CCMAIL:release-team at kde.org


 M  +23 -46    battery.cpp  
 M  +3 -8      battery.h  


--- branches/KDE/4.5/kdebase/workspace/plasma/generic/applets/battery/battery.cpp #1158799:1158800
@@ -81,9 +81,9 @@
       m_batteryInfoLabel(0),
       m_acLabelLabel(0),
       m_acInfoLabel(0),
-      m_brightnessSliders(0),
       m_profileLabel(0),
       m_profileCombo(0),
+      m_brightnessSlider(0),
       m_minutes(0),
       m_hours(0),
       m_theme(0),
@@ -408,24 +408,15 @@
 void Battery::brightnessChanged(const int brightness)
 {
     if (!m_ignoreBrightnessChange) {
-        for (int i = 0; i < m_brightnessSliders->size(); ++i) {
-            const struct BrightnessSet *bs = &m_brightnessSliders->at(i);
-            if (bs->slider == sender()) {
-                Solid::Control::PowerManager::setBrightness(brightness, bs->device);
-                return;
+        Solid::Control::PowerManager::setBrightness(brightness);
             }
         }
-        kDebug() << "Received signal from not stored slider";
-    }
-}
 
-void Battery::updateSliders()
+void Battery::updateSlider(const float brightness)
 {
-    for (int i = 0; i < m_brightnessSliders->size(); ++i) {
-        const struct BrightnessSet *bs = &m_brightnessSliders->at(i);
-        float value = Solid::Control::PowerManager::brightness(bs->device);
+    if (m_brightnessSlider->value() != (int)brightness) {
         m_ignoreBrightnessChange = true;
-        bs->slider->setValue(value);
+        m_brightnessSlider->setValue((int) brightness);
         m_ignoreBrightnessChange = false;
     }
 }
@@ -514,39 +505,25 @@
         m_extenderApplet->updateConstraints(Plasma::StartupCompletedConstraint);
         m_controlsLayout->addItem(m_extenderApplet, 1, 2, 2, 1);
 
-
-
-        m_brightnessSliders = new QList<BrightnessSet>;
-        Solid::Control::PowerManager::BrightnessControlsList controls = Solid::Control::PowerManager::brightnessControlsAvailable();
-        foreach (const QString &device, controls.keys()) {
-            struct BrightnessSet brightnessSet;
-
-            /* Device name */
-            brightnessSet.device = device;
-
-            /* Label */
-            brightnessSet.label = new Plasma::Label(m_controls);
-            brightnessSet.label = createBuddyLabel(m_controls);
+        m_brightnessLabel = createBuddyLabel(m_controls);
 #if KDE_IS_VERSION(4, 5, 60)
-            brightnessSet.label->setText(i18n("Screen Brightness:"));
+        m_brightnessLabel->setText(i18n("Screen Brightness:"));
 #else
-            brightnessSet.label->setText(i18n("Screen Brightness") + ':');
+        m_brightnessLabel->setText(i18n("Screen Brightness") + ':');
 #endif
-            m_controlsLayout->addItem(brightnessSet.label, row, 0);
 
-            /* Slider */
-            brightnessSet.slider = new Plasma::Slider(m_controls);
-            brightnessSet.slider->setRange(0, 100);
-            brightnessSet.slider->nativeWidget()->setTickInterval(10);
-            brightnessSet.slider->setOrientation(Qt::Horizontal);
-            connect(brightnessSet.slider, SIGNAL(valueChanged(int)),
+        m_controlsLayout->addItem(m_brightnessLabel, row, 0);
+
+        m_brightnessSlider = new Plasma::Slider(m_controls);
+        m_brightnessSlider->setRange(0, 100);
+        updateSlider(Solid::Control::PowerManager::brightness());
+        m_brightnessSlider->nativeWidget()->setTickInterval(10);
+        m_brightnessSlider->setOrientation(Qt::Horizontal);
+        connect(m_brightnessSlider, SIGNAL(valueChanged(int)),
                     this, SLOT(brightnessChanged(int)));
-            m_controlsLayout->addItem(brightnessSet.slider, row, 1, 1, 2);
 
-            m_brightnessSliders->append(brightnessSet);
+        m_controlsLayout->addItem(m_brightnessSlider, row, 1, 1, 2);
             row++;
-        }
-        updateSliders();
 
         m_profileLabel = createBuddyLabel(m_controls);
         m_profileLabel->setText(i18n("Power Profile:"));
@@ -629,9 +606,7 @@
 {
     if (m_batteryLabelLabel) {
         QFont infoFont = KGlobalSettings::generalFont();
-        for (int i = 0; i < m_brightnessSliders->size(); ++i) {
-            m_brightnessSliders->at(i).label->setFont(infoFont);
-        }
+        m_brightnessLabel->setFont(infoFont);
         m_profileLabel->setFont(infoFont);
 
         QFont boldFont = infoFont;
@@ -744,8 +719,10 @@
         }
     }
 
-    updateSliders();
+    if (m_brightnessSlider) {
+        updateSlider(Solid::Control::PowerManager::brightness());
 }
+}
 
 void Battery::openConfig()
 {
@@ -1092,8 +1069,8 @@
         int posY = rect.y() + 4 * rect.height() / 5;
         m_brightnessOSD->setGeometry(posX, posY, size.width(), size.height());
 
-        if (m_extenderVisible) {
-            updateSliders();
+        if (m_extenderVisible && m_brightnessSlider) {
+            updateSlider(brightness);
         }
     }
 }
--- branches/KDE/4.5/kdebase/workspace/plasma/generic/applets/battery/battery.h #1158799:1158800
@@ -39,12 +39,6 @@
     class Slider;
 }
 
-struct BrightnessSet {
-    QString device;
-    Plasma::Label *label;
-    Plasma::Slider *slider;
-};
-
 class BrightnessOSDWidget;
 
 class Battery : public Plasma::PopupApplet
@@ -93,7 +87,7 @@
         void sourceAdded(const QString &source);
         void sourceRemoved(const QString &source);
         void brightnessChanged(const int brightness);
-        void updateSliders();
+        void updateSlider(const float brightness);
         void openConfig();
         void setProfile(const QString &profile);
         void suspend();
@@ -141,9 +135,10 @@
         //QGraphicsGridLayout *m_brightnessLayout;
         Plasma::Label *m_statusLabel;
         //Plasma::Label *m_batteryLabel;
-        QList<struct BrightnessSet> *m_brightnessSliders;
+        Plasma::Label *m_brightnessLabel;
         Plasma::Label *m_profileLabel;
         Plasma::ComboBox *m_profileCombo;
+        Plasma::Slider *m_brightnessSlider;
         int m_inhibitCookie;
 
         /* Show multiple batteries with individual icons and charge info? */


More information about the release-team mailing list