View | Details | Raw Unified | Return to bug 606195
Collapse All | Expand All

(-)kdebase-workspace-4.4.1.orig/libs/solid/control/powermanager.cpp (-2 / +9 lines)
Lines 25-30 Link Here
25
#include "ifaces/powermanager.h"
25
#include "ifaces/powermanager.h"
26
#include <kdebug.h>
26
#include <kdebug.h>
27
#include <kglobal.h>
27
#include <kglobal.h>
28
#include <QDBusInterface>
29
#include <QDBusPendingCall>
28
#include <QX11Info>
30
#include <QX11Info>
29
31
30
K_GLOBAL_STATIC(Solid::Control::PowerManagerPrivate, globalPowerManager)
32
K_GLOBAL_STATIC(Solid::Control::PowerManagerPrivate, globalPowerManager)
Lines 160-166 Link Here
160
#ifdef Q_WS_WIN
162
#ifdef Q_WS_WIN
161
            return false;
163
            return false;
162
#else
164
#else
163
            return ( xrandr_brightlight( QX11Info::display(), brightness ) >= 0 );
165
            if ( xrandr_brightlight( QX11Info::display(), brightness ) < 0 )
166
                return false;
164
#endif
167
#endif
165
        }
168
        }
166
        else
169
        else
Lines 170-177 Link Here
170
                SOLID_CALL(Ifaces::PowerManager *, globalPowerManager->managerBackend(), setBrightness(brightness, device));
173
                SOLID_CALL(Ifaces::PowerManager *, globalPowerManager->managerBackend(), setBrightness(brightness, device));
171
            }
174
            }
172
            //TODO - This should be done better, it will return true even if one of the calls returns false. SOLID_CALL does not allow us to get the return value.
175
            //TODO - This should be done better, it will return true even if one of the calls returns false. SOLID_CALL does not allow us to get the return value.
173
            return true;
174
        }
176
        }
177
178
        QDBusInterface iface("org.kde.kded", "/modules/powerdevil", "org.kde.PowerDevil", QDBusConnection::sessionBus());
179
        if (iface.isValid())
180
            iface.asyncCall("notifyOfBrightnessChange", (int) Solid::Control::PowerManager::brightness());
181
        return true;
175
    }
182
    }
176
    else
183
    else
177
    {
184
    {
(-)kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/battery.cpp (-10 / +40 lines)
Lines 24-29 Link Here
24
#include <QApplication>
24
#include <QApplication>
25
#include <QDBusConnection>
25
#include <QDBusConnection>
26
#include <QDBusInterface>
26
#include <QDBusInterface>
27
#include <QDesktopWidget>
27
#include <QPainter>
28
#include <QPainter>
28
#include <QStyleOptionGraphicsItem>
29
#include <QStyleOptionGraphicsItem>
29
#include <QFont>
30
#include <QFont>
Lines 34-39 Link Here
34
#include <QLabel>
35
#include <QLabel>
35
#include <QPropertyAnimation>
36
#include <QPropertyAnimation>
36
37
38
#include <KApplication>
37
#include <KDebug>
39
#include <KDebug>
38
#include <KIcon>
40
#include <KIcon>
39
#include <KSharedConfig>
41
#include <KSharedConfig>
Lines 62-67 Link Here
62
#include <Plasma/ComboBox>
64
#include <Plasma/ComboBox>
63
#include <Plasma/IconWidget>
65
#include <Plasma/IconWidget>
64
66
67
#include "brightnessosdwidget.h"
68
65
69
66
Battery::Battery(QObject *parent, const QVariantList &args)
70
Battery::Battery(QObject *parent, const QVariantList &args)
67
    : Plasma::PopupApplet(parent, args),
71
    : Plasma::PopupApplet(parent, args),
Lines 315-320 Link Here
315
319
316
Battery::~Battery()
320
Battery::~Battery()
317
{
321
{
322
    delete m_brightnessOSD;
318
}
323
}
319
324
320
void Battery::suspend()
325
void Battery::suspend()
Lines 335-347 Link Here
335
340
336
void Battery::brightnessChanged(const int brightness)
341
void Battery::brightnessChanged(const int brightness)
337
{
342
{
338
    Solid::Control::PowerManager::setBrightness(brightness);
343
    if (!m_ignoreBrightnessChange) {
344
        Solid::Control::PowerManager::setBrightness(brightness);
345
    }
339
}
346
}
340
347
341
void Battery::updateSlider(const float brightness)
348
void Battery::updateSlider(int brightness)
342
{
349
{
343
    if (m_brightnessSlider->value() != (int)brightness) {
350
    if (m_brightnessSlider->value() != brightness) {
344
        m_brightnessSlider->setValue((int) brightness);
351
        m_ignoreBrightnessChange = true;
352
        m_brightnessSlider->setValue(brightness);
353
        m_ignoreBrightnessChange = false;
345
    }
354
    }
346
}
355
}
347
356
Lines 364-369 Link Here
364
    // as the battery applet is also embedded into the battery's extender.
373
    // as the battery applet is also embedded into the battery's extender.
365
    if (!m_isEmbedded && item->name() == "powermanagement") {
374
    if (!m_isEmbedded && item->name() == "powermanagement") {
366
        int row = 0;
375
        int row = 0;
376
        m_ignoreBrightnessChange = false;
367
377
368
        m_controls = new QGraphicsWidget(item);
378
        m_controls = new QGraphicsWidget(item);
369
        m_controls->setMinimumWidth(360);
379
        m_controls->setMinimumWidth(360);
Lines 428-443 Link Here
428
438
429
        m_brightnessSlider = new Plasma::Slider(m_controls);
439
        m_brightnessSlider = new Plasma::Slider(m_controls);
430
        m_brightnessSlider->setRange(0, 100);
440
        m_brightnessSlider->setRange(0, 100);
431
        m_brightnessSlider->setValue(Solid::Control::PowerManager::brightness());
441
        updateSlider(Solid::Control::PowerManager::brightness());
432
        m_brightnessSlider->nativeWidget()->setTickInterval(10);
442
        m_brightnessSlider->nativeWidget()->setTickInterval(10);
433
        m_brightnessSlider->setOrientation(Qt::Horizontal);
443
        m_brightnessSlider->setOrientation(Qt::Horizontal);
434
        connect(m_brightnessSlider, SIGNAL(valueChanged(int)),
444
        connect(m_brightnessSlider, SIGNAL(valueChanged(int)),
435
                this, SLOT(brightnessChanged(int)));
445
                this, SLOT(brightnessChanged(int)));
436
446
437
        Solid::Control::PowerManager::Notifier *notifier = Solid::Control::PowerManager::notifier();
438
439
        connect(notifier, SIGNAL(brightnessChanged(float)),
440
                this, SLOT(updateSlider(float)));
441
        m_controlsLayout->addItem(m_brightnessSlider, row, 1);
447
        m_controlsLayout->addItem(m_brightnessSlider, row, 1);
442
        row++;
448
        row++;
443
449
Lines 528-533 Link Here
528
        item->setTitle(i18n("Power Management"));
534
        item->setTitle(i18n("Power Management"));
529
535
530
        setupFonts();
536
        setupFonts();
537
538
        m_brightnessOSD = new BrightnessOSDWidget();
539
        QDBusConnection::sessionBus().connect("org.kde.kded", "/modules/powerdevil", "org.kde.PowerDevil",
540
                                              "brightnessChanged", this, SLOT(showBrightnessOSD(int,bool)));
531
    }
541
    }
532
}
542
}
533
543
Lines 652-658 Link Here
652
    }
662
    }
653
663
654
    if (m_brightnessSlider) {
664
    if (m_brightnessSlider) {
655
        m_brightnessSlider->setValue(Solid::Control::PowerManager::brightness());
665
        updateSlider(Solid::Control::PowerManager::brightness());
656
    }
666
    }
657
}
667
}
658
668
Lines 990-993 Link Here
990
    return m_acAlpha;
1000
    return m_acAlpha;
991
}
1001
}
992
1002
1003
void Battery::showBrightnessOSD(int brightness, bool byFnKey)
1004
{
1005
    if (byFnKey) {
1006
        m_brightnessOSD->setCurrentBrightness(brightness);
1007
        m_brightnessOSD->show();
1008
        m_brightnessOSD->activateOSD(); //Enable the hide timer
1009
1010
        //Center the OSD
1011
        QRect rect = KApplication::kApplication()->desktop()->screenGeometry(QCursor::pos());
1012
        QSize size = m_brightnessOSD->sizeHint();
1013
        int posX = rect.x() + (rect.width() - size.width()) / 2;
1014
        int posY = rect.y() + 4 * rect.height() / 5;
1015
        m_brightnessOSD->setGeometry(posX, posY, size.width(), size.height());
1016
1017
        if (m_extenderVisible && m_brightnessSlider) {
1018
            updateSlider(brightness);
1019
        }
1020
    }
1021
}
1022
993
#include "battery.moc"
1023
#include "battery.moc"
(-)kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/battery.h (-1 / +7 lines)
Lines 39-44 Link Here
39
    class Slider;
39
    class Slider;
40
}
40
}
41
41
42
class BrightnessOSDWidget;
43
42
class Battery : public Plasma::PopupApplet
44
class Battery : public Plasma::PopupApplet
43
{
45
{
44
    Q_OBJECT
46
    Q_OBJECT
Lines 83-89 Link Here
83
        void sourceAdded(const QString &source);
85
        void sourceAdded(const QString &source);
84
        void sourceRemoved(const QString &source);
86
        void sourceRemoved(const QString &source);
85
        void brightnessChanged(const int brightness);
87
        void brightnessChanged(const int brightness);
86
        void updateSlider(const float brightness);
88
        void updateSlider(int brightness);
87
        void setFullBrightness();
89
        void setFullBrightness();
88
        void openConfig();
90
        void openConfig();
89
        void setProfile(const QString &profile);
91
        void setProfile(const QString &profile);
Lines 91-96 Link Here
91
        void hibernate();
93
        void hibernate();
92
        void updateBattery();
94
        void updateBattery();
93
        void setupFonts();
95
        void setupFonts();
96
        void showBrightnessOSD(int brightness, bool byFnKey);
94
97
95
    private:
98
    private:
96
        void connectSources();
99
        void connectSources();
Lines 172-177 Link Here
172
        QPropertyAnimation *m_labelAnimation;
175
        QPropertyAnimation *m_labelAnimation;
173
        qreal m_acAlpha;
176
        qreal m_acAlpha;
174
        QPropertyAnimation *m_acAnimation;
177
        QPropertyAnimation *m_acAnimation;
178
179
        bool m_ignoreBrightnessChange;
180
        BrightnessOSDWidget* m_brightnessOSD;
175
};
181
};
176
182
177
K_EXPORT_PLASMA_APPLET(battery, Battery)
183
K_EXPORT_PLASMA_APPLET(battery, Battery)
(-)kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/brightnessosdwidget.cpp (+141 lines)
Line 0 Link Here
1
/*******************************************************************
2
* osdwidget.cpp
3
* Copyright  2009    Aurélien Gâteau <agateau@kde.org>
4
* Copyright  2009    Dario Andres Rodriguez <andresbajotierra@gmail.com>
5
* Copyright  2009    Christian Esken <christian.esken@arcor.de>   
6
*
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License as
9
* published by the Free Software Foundation; either version 2 of
10
* the License, or (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
*
20
******************************************************************/
21
22
#include "brightnessosdwidget.h"
23
24
// Qt
25
#include <QGraphicsLinearLayout>
26
#include <QPainter>
27
#include <QTimer>
28
#include <QLabel>
29
30
// KDE
31
#include <KIcon>
32
#include <KDialog>
33
#include <Plasma/FrameSvg>
34
#include <Plasma/Label>
35
#include <Plasma/Meter>
36
37
BrightnessOSDWidget::BrightnessOSDWidget(QWidget * parent)
38
    : QGraphicsView(parent),
39
    m_background(new Plasma::FrameSvg(this)),
40
    m_scene(new QGraphicsScene(this)),
41
    m_container(new QGraphicsWidget),
42
    m_iconLabel(new Plasma::Label),
43
    m_volumeLabel(new Plasma::Label),
44
    m_meter(new Plasma::Meter),
45
    m_hideTimer(new QTimer(this))
46
{
47
    //Setup the window properties
48
    setWindowFlags(Qt::X11BypassWindowManagerHint);
49
    setFrameStyle(QFrame::NoFrame);
50
    viewport()->setAutoFillBackground(false);
51
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
52
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
53
    setAttribute(Qt::WA_TranslucentBackground);
54
55
    //Cache the icon pixmaps
56
    QSize iconSize = QSize(KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium);
57
    m_brightnessPixmap = KIcon("video-display").pixmap(iconSize);
58
    /*m_volumeHighPixmap = KIcon("audio-volume-high").pixmap(iconSize);
59
    m_volumeMediumPixmap = KIcon("audio-volume-medium").pixmap(iconSize);
60
    m_volumeLowPixmap = KIcon("audio-volume-low").pixmap(iconSize);*/
61
62
    //Setup the widgets
63
    m_background->setImagePath("widgets/tooltip");
64
65
    m_iconLabel->nativeWidget()->setPixmap(m_brightnessPixmap);
66
    m_iconLabel->nativeWidget()->setFixedSize(iconSize);
67
    m_iconLabel->setMinimumSize(iconSize);
68
    m_iconLabel->setMaximumSize(iconSize);
69
70
    m_meter->setMeterType(Plasma::Meter::BarMeterHorizontal);
71
    m_meter->setMaximum(100);
72
    m_meter->setMaximumHeight(iconSize.height());
73
74
    m_volumeLabel->setAlignment(Qt::AlignCenter);
75
76
    //Setup the auto-hide timer
77
    m_hideTimer->setInterval(2000);
78
    m_hideTimer->setSingleShot(true);
79
    connect(m_hideTimer, SIGNAL(timeout()), this, SLOT(hide()));
80
81
    //Setup the OSD layout
82
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(m_container);
83
    layout->addItem(m_iconLabel);
84
    layout->addItem(m_meter);
85
86
    m_scene->addItem(m_container);
87
    setScene(m_scene);
88
}
89
90
void BrightnessOSDWidget::activateOSD()
91
{
92
    m_hideTimer->start();
93
}
94
95
void BrightnessOSDWidget::setCurrentBrightness(int brightnessLevel)
96
{
97
    m_meter->setValue(brightnessLevel);
98
99
    /*if (volumeLevel < 25) {
100
        m_iconLabel->nativeWidget()->setPixmap(m_volumeLowPixmap);
101
    } else if (volumeLevel < 75) {
102
        m_iconLabel->nativeWidget()->setPixmap(m_volumeMediumPixmap);
103
    } else {
104
        m_iconLabel->nativeWidget()->setPixmap(m_volumeHighPixmap);
105
    }*/
106
107
    //Show the volume %
108
    //m_meter->setLabel(0, QString::number(volumeLevel) + " %");
109
}
110
111
void BrightnessOSDWidget::drawBackground(QPainter *painter, const QRectF &/*rectF*/)
112
{
113
    painter->save();
114
    painter->setCompositionMode(QPainter::CompositionMode_Source);
115
    m_background->paintFrame(painter);
116
    painter->restore();
117
}
118
119
QSize BrightnessOSDWidget::sizeHint() const
120
{
121
    int iconSize = m_iconLabel->nativeWidget()->pixmap()->height();
122
    int meterHeight = iconSize;
123
    int meterWidth = iconSize * 12;
124
    qreal left, top, right, bottom;
125
    m_background->getMargins(left, top, right, bottom);
126
    return QSize(meterWidth + iconSize + left + right, meterHeight + top + bottom);
127
}
128
129
void BrightnessOSDWidget::resizeEvent(QResizeEvent*)
130
{
131
    m_background->resizeFrame(size());
132
    m_container->setGeometry(0, 0, width(), height());
133
    qreal left, top, right, bottom;
134
    m_background->getMargins(left, top, right, bottom);
135
    m_container->layout()->setContentsMargins(left, top, right, bottom);
136
137
    m_scene->setSceneRect(0, 0, width(), height());
138
    setMask(m_background->mask());
139
}
140
141
#include "brightnessosdwidget.moc"
(-)kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/brightnessosdwidget.h (+69 lines)
Line 0 Link Here
1
/*******************************************************************
2
* osdwidget.h
3
* Copyright  2009    Aurélien Gâteau <agateau@kde.org>
4
* Copyright  2009    Dario Andres Rodriguez <andresbajotierra@gmail.com>
5
* Copyright  2009    Christian Esken <christian.esken@arcor.de>
6
*
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License as
9
* published by the Free Software Foundation; either version 2 of
10
* the License, or (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
*
20
******************************************************************/
21
22
#ifndef BRIGHTNESSOSDWIDGET__H
23
#define BRIGHTNESSOSDWIDGET__H
24
25
#include <QGraphicsView>
26
27
#include <QPixmap>
28
29
class QTimer;
30
class QGraphicsWidget;
31
32
namespace Plasma
33
{
34
class FrameSvg;
35
class Label;
36
class Meter;
37
}
38
39
class BrightnessOSDWidget : public QGraphicsView
40
{
41
Q_OBJECT
42
public:
43
    BrightnessOSDWidget(QWidget * parent = 0);
44
45
    void setCurrentBrightness(int brightnessLevel);
46
    void activateOSD();
47
48
    virtual QSize sizeHint() const;
49
50
protected:
51
    virtual void drawBackground(QPainter *painter, const QRectF &rectF);
52
    virtual void resizeEvent(QResizeEvent *);
53
54
private:
55
    Plasma::FrameSvg *m_background;
56
    QGraphicsScene *m_scene;
57
    QGraphicsWidget *m_container;
58
    Plasma::Label *m_iconLabel;
59
    Plasma::Label *m_volumeLabel;
60
    Plasma::Meter *m_meter;
61
    QTimer *m_hideTimer;
62
63
    QPixmap m_brightnessPixmap;
64
    /*QPixmap m_volumeHighPixmap;
65
    QPixmap m_volumeMediumPixmap;
66
    QPixmap m_volumeLowPixmap;*/
67
};
68
69
#endif
(-)kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/CMakeLists.txt (-1 / +2 lines)
Lines 1-7 Link Here
1
project(plasma-battery)
1
project(plasma-battery)
2
2
3
set(battery_SRCS
3
set(battery_SRCS
4
    battery.cpp)
4
    battery.cpp
5
    brightnessosdwidget.cpp)
5
6
6
kde4_add_ui_files(battery_SRCS batteryConfig.ui )
7
kde4_add_ui_files(battery_SRCS batteryConfig.ui )
7
kde4_add_plugin(plasma_applet_battery ${battery_SRCS})
8
kde4_add_plugin(plasma_applet_battery ${battery_SRCS})
(-)kdebase-workspace-4.4.1.orig/powerdevil/daemon/org.kde.PowerDevil.xml (+8 lines)
Lines 42-47 Link Here
42
      <arg type="as" direction="out" />
42
      <arg type="as" direction="out" />
43
    </method>
43
    </method>
44
    
44
    
45
    <method name="notifyOfBrightnessChange">
46
      <arg type="i" direction="in" />
47
    </method>
48
    
45
    <signal name="lidClosed">
49
    <signal name="lidClosed">
46
      <arg type="i" direction="out" />
50
      <arg type="i" direction="out" />
47
      <arg type="s" direction="out" />
51
      <arg type="s" direction="out" />
Lines 56-60 Link Here
56
    </signal>
60
    </signal>
57
     <signal name="DPMSconfigUpdated">
61
     <signal name="DPMSconfigUpdated">
58
    </signal>
62
    </signal>
63
    <signal name="brightnessChanged">
64
      <arg type="i" direction="out" />
65
      <arg type="b" direction="out" />
66
    </signal>
59
  </interface>
67
  </interface>
60
</node>
68
</node>
(-)kdebase-workspace-4.4.1.orig/powerdevil/daemon/PowerDevilDaemon.cpp (-9 / +69 lines)
Lines 26-31 Link Here
26
26
27
#include <kdemacros.h>
27
#include <kdemacros.h>
28
#include <KAboutData>
28
#include <KAboutData>
29
#include <KAction>
30
#include <KActionCollection>
29
#include <KPluginFactory>
31
#include <KPluginFactory>
30
#include <KNotification>
32
#include <KNotification>
31
#include <KIcon>
33
#include <KIcon>
Lines 93-98 Link Here
93
            : notifier(Solid::Control::PowerManager::notifier())
95
            : notifier(Solid::Control::PowerManager::notifier())
94
            , currentConfig(0)
96
            , currentConfig(0)
95
            , status(PowerDevilDaemon::NoAction)
97
            , status(PowerDevilDaemon::NoAction)
98
            , brightnessInHardware(false)
96
            , ckSessionInterface(0) {}
99
            , ckSessionInterface(0) {}
97
100
98
    Solid::Control::PowerManager::Notifier *notifier;
101
    Solid::Control::PowerManager::Notifier *notifier;
Lines 119-124 Link Here
119
122
120
    int batteryPercent;
123
    int batteryPercent;
121
    int brightness;
124
    int brightness;
125
    int cachedBrightness;
126
    bool brightnessInHardware;
122
    bool isPlugged;
127
    bool isPlugged;
123
128
124
    // ConsoleKit stuff
129
    // ConsoleKit stuff
Lines 174-179 Link Here
174
    d->ksmServerIface = new OrgKdeKSMServerInterfaceInterface("org.kde.ksmserver", "/KSMServer",
179
    d->ksmServerIface = new OrgKdeKSMServerInterfaceInterface("org.kde.ksmserver", "/KSMServer",
175
                                                              QDBusConnection::sessionBus(), this);
180
                                                              QDBusConnection::sessionBus(), this);
176
181
182
    QDBusInterface halManager("org.freedesktop.Hal",
183
            "/org/freedesktop/Hal/Manager", "org.freedesktop.Hal.Manager",
184
            QDBusConnection::systemBus());
185
    QStringList panelDevices = halManager.call("FindDeviceByCapability",
186
             "laptop_panel").arguments().at(0).toStringList();
187
    if (!panelDevices.empty()) {
188
        QDBusInterface deviceInterface("org.freedesktop.Hal", panelDevices.at(0), "org.freedesktop.Hal.Device",
189
                QDBusConnection::systemBus());
190
        d->brightnessInHardware = deviceInterface.call("GetPropertyBoolean",
191
                "laptop_panel.brightness_in_hardware").arguments().at(0).toBool();
192
    }
193
177
    /*  Not needed anymore; I am not sure if we will need that in a future, so I leave it here
194
    /*  Not needed anymore; I am not sure if we will need that in a future, so I leave it here
178
     *  just in case.
195
     *  just in case.
179
     *
196
     *
Lines 198-203 Link Here
198
    QDBusConnection::sessionBus().registerService("org.kde.powerdevil");
215
    QDBusConnection::sessionBus().registerService("org.kde.powerdevil");
199
    // All systems up Houston, let's go!
216
    // All systems up Houston, let's go!
200
    refreshStatus();
217
    refreshStatus();
218
219
    d->cachedBrightness = (int) Solid::Control::PowerManager::brightness();
220
    KActionCollection* actionCollection = new KActionCollection( this );
221
222
    KAction* globalAction = static_cast< KAction* >( actionCollection->addAction( "Increase Screen Brightness" ));
223
    globalAction->setGlobalShortcut(KShortcut(Qt::Key_MonBrightnessUp));
224
    connect(globalAction, SIGNAL(triggered(bool)), SLOT(increaseBrightness()));
225
226
    globalAction = static_cast< KAction* >( actionCollection->addAction( "Decrease Screen Brightness" ));
227
    globalAction->setGlobalShortcut(KShortcut(Qt::Key_MonBrightnessDown));
228
    connect(globalAction, SIGNAL(triggered(bool)), SLOT(decreaseBrightness()));
201
}
229
}
202
230
203
PowerDevilDaemon::~PowerDevilDaemon()
231
PowerDevilDaemon::~PowerDevilDaemon()
Lines 661-684 Link Here
661
    }
689
    }
662
}
690
}
663
691
664
void PowerDevilDaemon::decreaseBrightness()
692
void PowerDevilDaemon::incDecBrightness(bool increase)
665
{
693
{
666
    if (!checkIfCurrentSessionActive()) {
694
    if (!checkIfCurrentSessionActive()) {
667
        return;
695
        return;
668
    }
696
    }
697
 
698
    int currentBrightness = (int) Solid::Control::PowerManager::brightness();
699
700
    if (currentBrightness == -1) {
701
        return; // we are not able to determine the brightness level
702
    }
669
703
670
    int currentBrightness = qMax(0, (int)(Solid::Control::PowerManager::brightness() - 10));
704
    if ((currentBrightness == d->cachedBrightness) && !d->brightnessInHardware)
671
    Solid::Control::PowerManager::setBrightness(currentBrightness);
705
    {
706
        int newBrightness;
707
        if (increase) {
708
            newBrightness = qMin(100, currentBrightness + 10);
709
        }
710
        else {
711
            newBrightness = qMax(0, currentBrightness - 10);
712
        }
713
714
        Solid::Control::PowerManager::setBrightness(newBrightness);
715
        currentBrightness = (int) Solid::Control::PowerManager::brightness();
716
    }
717
718
    emitBrightnessChanged(currentBrightness, true);
672
}
719
}
673
720
674
void PowerDevilDaemon::increaseBrightness()
721
void PowerDevilDaemon::decreaseBrightness()
675
{
722
{
676
    if (!checkIfCurrentSessionActive()) {
723
    incDecBrightness(false);
677
        return;
724
}
678
    }
679
725
680
    int currentBrightness = qMin(100, (int)(Solid::Control::PowerManager::brightness() + 10));
726
void PowerDevilDaemon::increaseBrightness()
681
    Solid::Control::PowerManager::setBrightness(currentBrightness);
727
{
728
    incDecBrightness(true);
682
}
729
}
683
730
684
void PowerDevilDaemon::shutdownNotification(bool automated)
731
void PowerDevilDaemon::shutdownNotification(bool automated)
Lines 1463-1466 Link Here
1463
                                         SLOT(refreshStatus()));
1510
                                         SLOT(refreshStatus()));
1464
}
1511
}
1465
1512
1513
void PowerDevilDaemon::notifyOfBrightnessChange(int brightness)
1514
{
1515
    emitBrightnessChanged(brightness, false);
1516
}
1517
1518
void PowerDevilDaemon::emitBrightnessChanged(int brightness, bool byFnKey)
1519
{
1520
    if ((d->cachedBrightness != brightness) || byFnKey) {
1521
        d->cachedBrightness = brightness;
1522
        emit brightnessChanged(brightness, byFnKey);
1523
    }
1524
}
1525
1466
#include "PowerDevilDaemon.moc"
1526
#include "PowerDevilDaemon.moc"
(-)kdebase-workspace-4.4.1.orig/powerdevil/daemon/PowerDevilDaemon.h (+6 lines)
Lines 61-70 Link Here
61
61
62
    SuspensionLockHandler *lockHandler();
62
    SuspensionLockHandler *lockHandler();
63
63
64
    void notifyOfBrightnessChange(int brightness);
65
64
private Q_SLOTS:
66
private Q_SLOTS:
65
    void acAdapterStateChanged(int state, bool forced = false);
67
    void acAdapterStateChanged(int state, bool forced = false);
66
    void batteryChargePercentChanged(int percent, const QString &udi);
68
    void batteryChargePercentChanged(int percent, const QString &udi);
67
69
70
    void incDecBrightness(bool increase);
68
    void decreaseBrightness();
71
    void decreaseBrightness();
69
    void increaseBrightness();
72
    void increaseBrightness();
70
73
Lines 106-111 Link Here
106
    void stateChanged(int, bool);
109
    void stateChanged(int, bool);
107
    void profileChanged(const QString &, const QStringList &);
110
    void profileChanged(const QString &, const QStringList &);
108
    void DPMSconfigUpdated();
111
    void DPMSconfigUpdated();
112
    void brightnessChanged(int brightness, bool byFnKey);
109
113
110
private:
114
private:
111
    void lockScreen();
115
    void lockScreen();
Lines 127-132 Link Here
127
131
128
    bool checkIfCurrentSessionActive();
132
    bool checkIfCurrentSessionActive();
129
133
134
    void emitBrightnessChanged(int brightness, bool byFnKey);
135
130
public:
136
public:
131
    enum IdleAction {
137
    enum IdleAction {
132
        None = 0,
138
        None = 0,

Return to bug 606195