|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
1 |
diff -Nur kdebase-workspace-4.4.1.orig/libs/solid/control/powermanager.cpp kdebase-workspace-4.4.1/libs/solid/control/powermanager.cpp
|
2 |
--- kdebase-workspace-4.4.1.orig/libs/solid/control/powermanager.cpp 2010-01-06 18:00:01.000000000 +0100
|
|
3 |
+++ kdebase-workspace-4.4.1/libs/solid/control/powermanager.cpp 2010-03-20 14:26:05.000000000 +0100
|
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
4 |
@@ -25,6 +25,8 @@
|
5 |
#include "ifaces/powermanager.h" |
|
6 |
#include <kdebug.h> |
|
7 |
#include <kglobal.h> |
|
8 |
+#include <QDBusInterface>
|
|
9 |
+#include <QDBusPendingCall>
|
|
10 |
#include <QX11Info> |
|
11 |
||
12 |
K_GLOBAL_STATIC(Solid::Control::PowerManagerPrivate, globalPowerManager) |
|
13 |
@@ -160,7 +162,8 @@
|
|
14 |
#ifdef Q_WS_WIN |
|
15 |
return false; |
|
16 |
#else |
|
17 |
- return ( xrandr_brightlight( QX11Info::display(), brightness ) >= 0 );
|
|
18 |
+ if ( xrandr_brightlight( QX11Info::display(), brightness ) < 0 )
|
|
19 |
+ return false;
|
|
20 |
#endif |
|
21 |
} |
|
22 |
else |
|
23 |
@@ -170,8 +173,12 @@
|
|
24 |
SOLID_CALL(Ifaces::PowerManager *, globalPowerManager->managerBackend(), setBrightness(brightness, device)); |
|
25 |
} |
|
26 |
//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. |
|
27 |
- return true;
|
|
28 |
} |
|
29 |
+
|
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
30 |
+ QDBusInterface iface("org.kde.kded", "/modules/powerdevil", "org.kde.PowerDevil", QDBusConnection::sessionBus());
|
31 |
+ if (iface.isValid())
|
|
32 |
+ iface.asyncCall("notifyOfBrightnessChange", (int) Solid::Control::PowerManager::brightness());
|
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
33 |
+ return true;
|
34 |
} |
|
35 |
else |
|
36 |
{
|
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
37 |
diff -Nur kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/battery.cpp kdebase-workspace-4.4.1/plasma/generic/applets/battery/battery.cpp
|
38 |
--- kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/battery.cpp 2010-02-04 10:28:44.000000000 +0100
|
|
39 |
+++ kdebase-workspace-4.4.1/plasma/generic/applets/battery/battery.cpp 2010-03-20 20:51:36.000000000 +0100
|
|
40 |
@@ -24,6 +24,7 @@
|
|
41 |
#include <QApplication> |
|
42 |
#include <QDBusConnection> |
|
43 |
#include <QDBusInterface> |
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
44 |
+#include <QDesktopWidget>
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
45 |
#include <QPainter> |
46 |
#include <QStyleOptionGraphicsItem> |
|
47 |
#include <QFont> |
|
48 |
@@ -34,6 +35,7 @@
|
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
49 |
#include <QLabel> |
50 |
#include <QPropertyAnimation> |
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
51 |
|
52 |
+#include <KApplication>
|
|
53 |
#include <KDebug> |
|
54 |
#include <KIcon> |
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
55 |
#include <KSharedConfig> |
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
56 |
@@ -62,6 +64,8 @@
|
57 |
#include <Plasma/ComboBox> |
|
58 |
#include <Plasma/IconWidget> |
|
59 |
||
60 |
+#include "brightnessosdwidget.h"
|
|
61 |
+
|
|
62 |
||
63 |
Battery::Battery(QObject *parent, const QVariantList &args) |
|
64 |
: Plasma::PopupApplet(parent, args), |
|
65 |
@@ -315,6 +319,7 @@
|
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
66 |
|
67 |
Battery::~Battery() |
|
68 |
{
|
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
69 |
+ delete m_brightnessOSD;
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
70 |
} |
71 |
||
72 |
void Battery::suspend() |
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
73 |
@@ -335,13 +340,17 @@
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
74 |
|
75 |
void Battery::brightnessChanged(const int brightness) |
|
76 |
{
|
|
77 |
- Solid::Control::PowerManager::setBrightness(brightness);
|
|
78 |
+ if (!m_ignoreBrightnessChange) {
|
|
79 |
+ Solid::Control::PowerManager::setBrightness(brightness);
|
|
80 |
+ }
|
|
81 |
} |
|
82 |
||
83 |
-void Battery::updateSlider(const float brightness)
|
|
84 |
+void Battery::updateSlider(int brightness)
|
|
85 |
{
|
|
86 |
- if (m_brightnessSlider->value() != (int)brightness) {
|
|
87 |
- m_brightnessSlider->setValue((int) brightness);
|
|
88 |
+ if (m_brightnessSlider->value() != brightness) {
|
|
89 |
+ m_ignoreBrightnessChange = true;
|
|
90 |
+ m_brightnessSlider->setValue(brightness);
|
|
91 |
+ m_ignoreBrightnessChange = false;
|
|
92 |
} |
|
93 |
} |
|
94 |
||
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
95 |
@@ -364,6 +373,7 @@
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
96 |
// as the battery applet is also embedded into the battery's extender. |
97 |
if (!m_isEmbedded && item->name() == "powermanagement") {
|
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
98 |
int row = 0; |
99 |
+ m_ignoreBrightnessChange = false;
|
|
100 |
||
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
101 |
m_controls = new QGraphicsWidget(item); |
102 |
m_controls->setMinimumWidth(360); |
|
103 |
@@ -428,16 +438,12 @@
|
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
104 |
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
105 |
m_brightnessSlider = new Plasma::Slider(m_controls); |
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
106 |
m_brightnessSlider->setRange(0, 100); |
107 |
- m_brightnessSlider->setValue(Solid::Control::PowerManager::brightness());
|
|
108 |
+ updateSlider(Solid::Control::PowerManager::brightness());
|
|
109 |
m_brightnessSlider->nativeWidget()->setTickInterval(10); |
|
110 |
m_brightnessSlider->setOrientation(Qt::Horizontal); |
|
111 |
connect(m_brightnessSlider, SIGNAL(valueChanged(int)), |
|
112 |
this, SLOT(brightnessChanged(int))); |
|
113 |
||
114 |
- Solid::Control::PowerManager::Notifier *notifier = Solid::Control::PowerManager::notifier();
|
|
115 |
-
|
|
116 |
- connect(notifier, SIGNAL(brightnessChanged(float)),
|
|
117 |
- this, SLOT(updateSlider(float)));
|
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
118 |
m_controlsLayout->addItem(m_brightnessSlider, row, 1); |
119 |
row++; |
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
120 |
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
121 |
@@ -528,6 +534,10 @@
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
122 |
item->setTitle(i18n("Power Management"));
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
123 |
|
124 |
setupFonts(); |
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
125 |
+
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
126 |
+ m_brightnessOSD = new BrightnessOSDWidget();
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
127 |
+ QDBusConnection::sessionBus().connect("org.kde.kded", "/modules/powerdevil", "org.kde.PowerDevil",
|
128 |
+ "brightnessChanged", this, SLOT(showBrightnessOSD(int,bool)));
|
|
129 |
} |
|
130 |
} |
|
131 |
||
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
132 |
@@ -652,7 +662,7 @@
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
133 |
} |
134 |
||
135 |
if (m_brightnessSlider) {
|
|
136 |
- m_brightnessSlider->setValue(Solid::Control::PowerManager::brightness());
|
|
137 |
+ updateSlider(Solid::Control::PowerManager::brightness());
|
|
138 |
} |
|
|
242
by Jonathan Thomas (The man)
* New upstream release candidate: |
139 |
} |
140 |
||
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
141 |
@@ -990,4 +1000,24 @@
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
142 |
return m_acAlpha; |
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
143 |
} |
144 |
||
145 |
+void Battery::showBrightnessOSD(int brightness, bool byFnKey)
|
|
146 |
+{
|
|
147 |
+ if (byFnKey) {
|
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
148 |
+ m_brightnessOSD->setCurrentBrightness(brightness);
|
149 |
+ m_brightnessOSD->show();
|
|
150 |
+ m_brightnessOSD->activateOSD(); //Enable the hide timer
|
|
151 |
+
|
|
152 |
+ //Center the OSD
|
|
153 |
+ QRect rect = KApplication::kApplication()->desktop()->screenGeometry(QCursor::pos());
|
|
154 |
+ QSize size = m_brightnessOSD->sizeHint();
|
|
155 |
+ int posX = rect.x() + (rect.width() - size.width()) / 2;
|
|
156 |
+ int posY = rect.y() + 4 * rect.height() / 5;
|
|
157 |
+ m_brightnessOSD->setGeometry(posX, posY, size.width(), size.height());
|
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
158 |
+
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
159 |
+ if (m_extenderVisible && m_brightnessSlider) {
|
160 |
+ updateSlider(brightness);
|
|
161 |
+ }
|
|
162 |
+ }
|
|
163 |
+}
|
|
164 |
+
|
|
165 |
#include "battery.moc" |
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
166 |
diff -Nur kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/battery.h kdebase-workspace-4.4.1/plasma/generic/applets/battery/battery.h
|
167 |
--- kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/battery.h 2010-01-20 00:19:14.000000000 +0100
|
|
168 |
+++ kdebase-workspace-4.4.1/plasma/generic/applets/battery/battery.h 2010-03-20 20:24:29.000000000 +0100
|
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
169 |
@@ -39,6 +39,8 @@
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
170 |
class Slider; |
171 |
} |
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
172 |
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
173 |
+class BrightnessOSDWidget;
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
174 |
+
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
175 |
class Battery : public Plasma::PopupApplet |
176 |
{
|
|
177 |
Q_OBJECT |
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
178 |
@@ -83,7 +85,7 @@
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
179 |
void sourceAdded(const QString &source); |
180 |
void sourceRemoved(const QString &source); |
|
181 |
void brightnessChanged(const int brightness); |
|
182 |
- void updateSlider(const float brightness);
|
|
183 |
+ void updateSlider(int brightness);
|
|
184 |
void setFullBrightness(); |
|
185 |
void openConfig(); |
|
186 |
void setProfile(const QString &profile); |
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
187 |
@@ -91,6 +93,7 @@
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
188 |
void hibernate(); |
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
189 |
void updateBattery(); |
190 |
void setupFonts(); |
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
191 |
+ void showBrightnessOSD(int brightness, bool byFnKey);
|
192 |
||
193 |
private: |
|
194 |
void connectSources(); |
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
195 |
@@ -172,6 +175,9 @@
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
196 |
QPropertyAnimation *m_labelAnimation; |
197 |
qreal m_acAlpha; |
|
198 |
QPropertyAnimation *m_acAnimation; |
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
199 |
+
|
200 |
+ bool m_ignoreBrightnessChange;
|
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
201 |
+ BrightnessOSDWidget* m_brightnessOSD;
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
202 |
}; |
203 |
||
204 |
K_EXPORT_PLASMA_APPLET(battery, Battery) |
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
205 |
diff -Nur kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/brightnessosdwidget.cpp kdebase-workspace-4.4.1/plasma/generic/applets/battery/brightnessosdwidget.cpp
|
206 |
--- kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/brightnessosdwidget.cpp 1970-01-01 01:00:00.000000000 +0100
|
|
207 |
+++ kdebase-workspace-4.4.1/plasma/generic/applets/battery/brightnessosdwidget.cpp 2010-03-20 22:03:21.000000000 +0100
|
|
208 |
@@ -0,0 +1,141 @@
|
|
209 |
+/*******************************************************************
|
|
210 |
+* osdwidget.cpp
|
|
211 |
+* Copyright 2009 Aurélien Gâteau <agateau@kde.org>
|
|
212 |
+* Copyright 2009 Dario Andres Rodriguez <andresbajotierra@gmail.com>
|
|
213 |
+* Copyright 2009 Christian Esken <christian.esken@arcor.de>
|
|
214 |
+*
|
|
215 |
+* This program is free software; you can redistribute it and/or
|
|
216 |
+* modify it under the terms of the GNU General Public License as
|
|
217 |
+* published by the Free Software Foundation; either version 2 of
|
|
218 |
+* the License, or (at your option) any later version.
|
|
219 |
+*
|
|
220 |
+* This program is distributed in the hope that it will be useful,
|
|
221 |
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
222 |
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
223 |
+* GNU General Public License for more details.
|
|
224 |
+*
|
|
225 |
+* You should have received a copy of the GNU General Public License
|
|
226 |
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
227 |
+*
|
|
228 |
+******************************************************************/
|
|
229 |
+
|
|
230 |
+#include "brightnessosdwidget.h"
|
|
231 |
+
|
|
232 |
+// Qt
|
|
233 |
+#include <QGraphicsLinearLayout>
|
|
234 |
+#include <QPainter>
|
|
235 |
+#include <QTimer>
|
|
236 |
+#include <QLabel>
|
|
237 |
+
|
|
238 |
+// KDE
|
|
239 |
+#include <KIcon>
|
|
240 |
+#include <KDialog>
|
|
241 |
+#include <Plasma/FrameSvg>
|
|
242 |
+#include <Plasma/Label>
|
|
243 |
+#include <Plasma/Meter>
|
|
244 |
+
|
|
245 |
+BrightnessOSDWidget::BrightnessOSDWidget(QWidget * parent)
|
|
246 |
+ : QGraphicsView(parent),
|
|
247 |
+ m_background(new Plasma::FrameSvg(this)),
|
|
248 |
+ m_scene(new QGraphicsScene(this)),
|
|
249 |
+ m_container(new QGraphicsWidget),
|
|
250 |
+ m_iconLabel(new Plasma::Label),
|
|
251 |
+ m_volumeLabel(new Plasma::Label),
|
|
252 |
+ m_meter(new Plasma::Meter),
|
|
253 |
+ m_hideTimer(new QTimer(this))
|
|
254 |
+{
|
|
255 |
+ //Setup the window properties
|
|
256 |
+ setWindowFlags(Qt::X11BypassWindowManagerHint);
|
|
257 |
+ setFrameStyle(QFrame::NoFrame);
|
|
258 |
+ viewport()->setAutoFillBackground(false);
|
|
259 |
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
260 |
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
261 |
+ setAttribute(Qt::WA_TranslucentBackground);
|
|
262 |
+
|
|
263 |
+ //Cache the icon pixmaps
|
|
264 |
+ QSize iconSize = QSize(KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium);
|
|
265 |
+ m_brightnessPixmap = KIcon("video-display").pixmap(iconSize);
|
|
266 |
+ /*m_volumeHighPixmap = KIcon("audio-volume-high").pixmap(iconSize);
|
|
267 |
+ m_volumeMediumPixmap = KIcon("audio-volume-medium").pixmap(iconSize);
|
|
268 |
+ m_volumeLowPixmap = KIcon("audio-volume-low").pixmap(iconSize);*/
|
|
269 |
+
|
|
270 |
+ //Setup the widgets
|
|
271 |
+ m_background->setImagePath("widgets/tooltip");
|
|
272 |
+
|
|
273 |
+ m_iconLabel->nativeWidget()->setPixmap(m_brightnessPixmap);
|
|
274 |
+ m_iconLabel->nativeWidget()->setFixedSize(iconSize);
|
|
275 |
+ m_iconLabel->setMinimumSize(iconSize);
|
|
276 |
+ m_iconLabel->setMaximumSize(iconSize);
|
|
277 |
+
|
|
278 |
+ m_meter->setMeterType(Plasma::Meter::BarMeterHorizontal);
|
|
279 |
+ m_meter->setMaximum(100);
|
|
280 |
+ m_meter->setMaximumHeight(iconSize.height());
|
|
281 |
+
|
|
282 |
+ m_volumeLabel->setAlignment(Qt::AlignCenter);
|
|
283 |
+
|
|
284 |
+ //Setup the auto-hide timer
|
|
285 |
+ m_hideTimer->setInterval(2000);
|
|
286 |
+ m_hideTimer->setSingleShot(true);
|
|
287 |
+ connect(m_hideTimer, SIGNAL(timeout()), this, SLOT(hide()));
|
|
288 |
+
|
|
289 |
+ //Setup the OSD layout
|
|
290 |
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(m_container);
|
|
291 |
+ layout->addItem(m_iconLabel);
|
|
292 |
+ layout->addItem(m_meter);
|
|
293 |
+
|
|
294 |
+ m_scene->addItem(m_container);
|
|
295 |
+ setScene(m_scene);
|
|
296 |
+}
|
|
297 |
+
|
|
298 |
+void BrightnessOSDWidget::activateOSD()
|
|
299 |
+{
|
|
300 |
+ m_hideTimer->start();
|
|
301 |
+}
|
|
302 |
+
|
|
303 |
+void BrightnessOSDWidget::setCurrentBrightness(int brightnessLevel)
|
|
304 |
+{
|
|
305 |
+ m_meter->setValue(brightnessLevel);
|
|
306 |
+
|
|
307 |
+ /*if (volumeLevel < 25) {
|
|
308 |
+ m_iconLabel->nativeWidget()->setPixmap(m_volumeLowPixmap);
|
|
309 |
+ } else if (volumeLevel < 75) {
|
|
310 |
+ m_iconLabel->nativeWidget()->setPixmap(m_volumeMediumPixmap);
|
|
311 |
+ } else {
|
|
312 |
+ m_iconLabel->nativeWidget()->setPixmap(m_volumeHighPixmap);
|
|
313 |
+ }*/
|
|
314 |
+
|
|
315 |
+ //Show the volume %
|
|
316 |
+ //m_meter->setLabel(0, QString::number(volumeLevel) + " %");
|
|
317 |
+}
|
|
318 |
+
|
|
319 |
+void BrightnessOSDWidget::drawBackground(QPainter *painter, const QRectF &/*rectF*/)
|
|
320 |
+{
|
|
321 |
+ painter->save();
|
|
322 |
+ painter->setCompositionMode(QPainter::CompositionMode_Source);
|
|
323 |
+ m_background->paintFrame(painter);
|
|
324 |
+ painter->restore();
|
|
325 |
+}
|
|
326 |
+
|
|
327 |
+QSize BrightnessOSDWidget::sizeHint() const
|
|
328 |
+{
|
|
329 |
+ int iconSize = m_iconLabel->nativeWidget()->pixmap()->height();
|
|
330 |
+ int meterHeight = iconSize;
|
|
331 |
+ int meterWidth = iconSize * 12;
|
|
332 |
+ qreal left, top, right, bottom;
|
|
333 |
+ m_background->getMargins(left, top, right, bottom);
|
|
334 |
+ return QSize(meterWidth + iconSize + left + right, meterHeight + top + bottom);
|
|
335 |
+}
|
|
336 |
+
|
|
337 |
+void BrightnessOSDWidget::resizeEvent(QResizeEvent*)
|
|
338 |
+{
|
|
339 |
+ m_background->resizeFrame(size());
|
|
340 |
+ m_container->setGeometry(0, 0, width(), height());
|
|
341 |
+ qreal left, top, right, bottom;
|
|
342 |
+ m_background->getMargins(left, top, right, bottom);
|
|
343 |
+ m_container->layout()->setContentsMargins(left, top, right, bottom);
|
|
344 |
+
|
|
345 |
+ m_scene->setSceneRect(0, 0, width(), height());
|
|
346 |
+ setMask(m_background->mask());
|
|
347 |
+}
|
|
348 |
+
|
|
349 |
+#include "brightnessosdwidget.moc"
|
|
350 |
diff -Nur kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/brightnessosdwidget.h kdebase-workspace-4.4.1/plasma/generic/applets/battery/brightnessosdwidget.h
|
|
351 |
--- kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/brightnessosdwidget.h 1970-01-01 01:00:00.000000000 +0100
|
|
352 |
+++ kdebase-workspace-4.4.1/plasma/generic/applets/battery/brightnessosdwidget.h 2010-03-20 19:24:37.000000000 +0100
|
|
353 |
@@ -0,0 +1,69 @@
|
|
354 |
+/*******************************************************************
|
|
355 |
+* osdwidget.h
|
|
356 |
+* Copyright 2009 Aurélien Gâteau <agateau@kde.org>
|
|
357 |
+* Copyright 2009 Dario Andres Rodriguez <andresbajotierra@gmail.com>
|
|
358 |
+* Copyright 2009 Christian Esken <christian.esken@arcor.de>
|
|
359 |
+*
|
|
360 |
+* This program is free software; you can redistribute it and/or
|
|
361 |
+* modify it under the terms of the GNU General Public License as
|
|
362 |
+* published by the Free Software Foundation; either version 2 of
|
|
363 |
+* the License, or (at your option) any later version.
|
|
364 |
+*
|
|
365 |
+* This program is distributed in the hope that it will be useful,
|
|
366 |
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
367 |
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
368 |
+* GNU General Public License for more details.
|
|
369 |
+*
|
|
370 |
+* You should have received a copy of the GNU General Public License
|
|
371 |
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
372 |
+*
|
|
373 |
+******************************************************************/
|
|
374 |
+
|
|
375 |
+#ifndef BRIGHTNESSOSDWIDGET__H
|
|
376 |
+#define BRIGHTNESSOSDWIDGET__H
|
|
377 |
+
|
|
378 |
+#include <QGraphicsView>
|
|
379 |
+
|
|
380 |
+#include <QPixmap>
|
|
381 |
+
|
|
382 |
+class QTimer;
|
|
383 |
+class QGraphicsWidget;
|
|
384 |
+
|
|
385 |
+namespace Plasma
|
|
386 |
+{
|
|
387 |
+class FrameSvg;
|
|
388 |
+class Label;
|
|
389 |
+class Meter;
|
|
390 |
+}
|
|
391 |
+
|
|
392 |
+class BrightnessOSDWidget : public QGraphicsView
|
|
393 |
+{
|
|
394 |
+Q_OBJECT
|
|
395 |
+public:
|
|
396 |
+ BrightnessOSDWidget(QWidget * parent = 0);
|
|
397 |
+
|
|
398 |
+ void setCurrentBrightness(int brightnessLevel);
|
|
399 |
+ void activateOSD();
|
|
400 |
+
|
|
401 |
+ virtual QSize sizeHint() const;
|
|
402 |
+
|
|
403 |
+protected:
|
|
404 |
+ virtual void drawBackground(QPainter *painter, const QRectF &rectF);
|
|
405 |
+ virtual void resizeEvent(QResizeEvent *);
|
|
406 |
+
|
|
407 |
+private:
|
|
408 |
+ Plasma::FrameSvg *m_background;
|
|
409 |
+ QGraphicsScene *m_scene;
|
|
410 |
+ QGraphicsWidget *m_container;
|
|
411 |
+ Plasma::Label *m_iconLabel;
|
|
412 |
+ Plasma::Label *m_volumeLabel;
|
|
413 |
+ Plasma::Meter *m_meter;
|
|
414 |
+ QTimer *m_hideTimer;
|
|
415 |
+
|
|
416 |
+ QPixmap m_brightnessPixmap;
|
|
417 |
+ /*QPixmap m_volumeHighPixmap;
|
|
418 |
+ QPixmap m_volumeMediumPixmap;
|
|
419 |
+ QPixmap m_volumeLowPixmap;*/
|
|
420 |
+};
|
|
421 |
+
|
|
422 |
+#endif
|
|
423 |
diff -Nur kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/CMakeLists.txt kdebase-workspace-4.4.1/plasma/generic/applets/battery/CMakeLists.txt
|
|
424 |
--- kdebase-workspace-4.4.1.orig/plasma/generic/applets/battery/CMakeLists.txt 2009-09-16 13:40:55.000000000 +0200
|
|
425 |
+++ kdebase-workspace-4.4.1/plasma/generic/applets/battery/CMakeLists.txt 2010-03-20 19:27:09.000000000 +0100
|
|
426 |
@@ -1,7 +1,8 @@
|
|
427 |
project(plasma-battery) |
|
428 |
||
429 |
set(battery_SRCS |
|
430 |
- battery.cpp)
|
|
431 |
+ battery.cpp
|
|
432 |
+ brightnessosdwidget.cpp)
|
|
433 |
||
434 |
kde4_add_ui_files(battery_SRCS batteryConfig.ui ) |
|
435 |
kde4_add_plugin(plasma_applet_battery ${battery_SRCS})
|
|
436 |
diff -Nur kdebase-workspace-4.4.1.orig/powerdevil/daemon/org.kde.PowerDevil.xml kdebase-workspace-4.4.1/powerdevil/daemon/org.kde.PowerDevil.xml
|
|
437 |
--- kdebase-workspace-4.4.1.orig/powerdevil/daemon/org.kde.PowerDevil.xml 2009-09-04 13:30:55.000000000 +0200
|
|
438 |
+++ kdebase-workspace-4.4.1/powerdevil/daemon/org.kde.PowerDevil.xml 2010-03-20 14:26:05.000000000 +0100
|
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
439 |
@@ -42,6 +42,10 @@
|
440 |
<arg type="as" direction="out" /> |
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
441 |
</method> |
442 |
||
443 |
+ <method name="notifyOfBrightnessChange">
|
|
444 |
+ <arg type="i" direction="in" />
|
|
445 |
+ </method>
|
|
446 |
+
|
|
447 |
<signal name="lidClosed"> |
|
448 |
<arg type="i" direction="out" /> |
|
449 |
<arg type="s" direction="out" /> |
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
450 |
@@ -56,5 +60,9 @@
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
451 |
</signal> |
452 |
<signal name="DPMSconfigUpdated"> |
|
453 |
</signal> |
|
454 |
+ <signal name="brightnessChanged">
|
|
455 |
+ <arg type="i" direction="out" />
|
|
456 |
+ <arg type="b" direction="out" />
|
|
457 |
+ </signal>
|
|
458 |
</interface> |
|
459 |
</node> |
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
460 |
diff -Nur kdebase-workspace-4.4.1.orig/powerdevil/daemon/PowerDevilDaemon.cpp kdebase-workspace-4.4.1/powerdevil/daemon/PowerDevilDaemon.cpp
|
461 |
--- kdebase-workspace-4.4.1.orig/powerdevil/daemon/PowerDevilDaemon.cpp 2009-12-11 00:14:04.000000000 +0100
|
|
462 |
+++ kdebase-workspace-4.4.1/powerdevil/daemon/PowerDevilDaemon.cpp 2010-03-20 19:43:18.000000000 +0100
|
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
463 |
@@ -26,6 +26,8 @@
|
464 |
||
465 |
#include <kdemacros.h> |
|
466 |
#include <KAboutData> |
|
467 |
+#include <KAction>
|
|
468 |
+#include <KActionCollection>
|
|
469 |
#include <KPluginFactory> |
|
470 |
#include <KNotification> |
|
471 |
#include <KIcon> |
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
472 |
@@ -93,6 +95,7 @@
|
473 |
: notifier(Solid::Control::PowerManager::notifier()) |
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
474 |
, currentConfig(0) |
475 |
, status(PowerDevilDaemon::NoAction) |
|
476 |
+ , brightnessInHardware(false)
|
|
477 |
, ckSessionInterface(0) {}
|
|
478 |
||
479 |
Solid::Control::PowerManager::Notifier *notifier; |
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
480 |
@@ -119,6 +122,8 @@
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
481 |
|
482 |
int batteryPercent; |
|
483 |
int brightness; |
|
484 |
+ int cachedBrightness;
|
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
485 |
+ bool brightnessInHardware;
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
486 |
bool isPlugged; |
487 |
||
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
488 |
// ConsoleKit stuff |
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
489 |
@@ -174,6 +179,18 @@
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
490 |
d->ksmServerIface = new OrgKdeKSMServerInterfaceInterface("org.kde.ksmserver", "/KSMServer",
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
491 |
QDBusConnection::sessionBus(), this); |
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
492 |
|
493 |
+ QDBusInterface halManager("org.freedesktop.Hal",
|
|
494 |
+ "/org/freedesktop/Hal/Manager", "org.freedesktop.Hal.Manager",
|
|
495 |
+ QDBusConnection::systemBus());
|
|
496 |
+ QStringList panelDevices = halManager.call("FindDeviceByCapability",
|
|
497 |
+ "laptop_panel").arguments().at(0).toStringList();
|
|
498 |
+ if (!panelDevices.empty()) {
|
|
499 |
+ QDBusInterface deviceInterface("org.freedesktop.Hal", panelDevices.at(0), "org.freedesktop.Hal.Device",
|
|
500 |
+ QDBusConnection::systemBus());
|
|
501 |
+ d->brightnessInHardware = deviceInterface.call("GetPropertyBoolean",
|
|
502 |
+ "laptop_panel.brightness_in_hardware").arguments().at(0).toBool();
|
|
503 |
+ }
|
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
504 |
+
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
505 |
/* Not needed anymore; I am not sure if we will need that in a future, so I leave it here |
506 |
* just in case. |
|
507 |
* |
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
508 |
@@ -198,6 +215,17 @@
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
509 |
QDBusConnection::sessionBus().registerService("org.kde.powerdevil");
|
510 |
// All systems up Houston, let's go! |
|
511 |
refreshStatus(); |
|
512 |
+
|
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
513 |
+ d->cachedBrightness = (int) Solid::Control::PowerManager::brightness();
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
514 |
+ KActionCollection* actionCollection = new KActionCollection( this );
|
515 |
+
|
|
516 |
+ KAction* globalAction = static_cast< KAction* >( actionCollection->addAction( "Increase Screen Brightness" ));
|
|
517 |
+ globalAction->setGlobalShortcut(KShortcut(Qt::Key_MonBrightnessUp));
|
|
518 |
+ connect(globalAction, SIGNAL(triggered(bool)), SLOT(increaseBrightness()));
|
|
519 |
+
|
|
520 |
+ globalAction = static_cast< KAction* >( actionCollection->addAction( "Decrease Screen Brightness" ));
|
|
521 |
+ globalAction->setGlobalShortcut(KShortcut(Qt::Key_MonBrightnessDown));
|
|
522 |
+ connect(globalAction, SIGNAL(triggered(bool)), SLOT(decreaseBrightness()));
|
|
523 |
} |
|
524 |
||
525 |
PowerDevilDaemon::~PowerDevilDaemon() |
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
526 |
@@ -661,24 +689,43 @@
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
527 |
} |
528 |
} |
|
529 |
||
530 |
-void PowerDevilDaemon::decreaseBrightness()
|
|
531 |
+void PowerDevilDaemon::incDecBrightness(bool increase)
|
|
532 |
{
|
|
533 |
if (!checkIfCurrentSessionActive()) {
|
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
534 |
return; |
535 |
} |
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
536 |
+
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
537 |
+ int currentBrightness = (int) Solid::Control::PowerManager::brightness();
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
538 |
+
|
539 |
+ if (currentBrightness == -1) {
|
|
540 |
+ return; // we are not able to determine the brightness level
|
|
541 |
+ }
|
|
542 |
||
543 |
- int currentBrightness = qMax(0, (int)(Solid::Control::PowerManager::brightness() - 10));
|
|
544 |
- Solid::Control::PowerManager::setBrightness(currentBrightness);
|
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
545 |
+ if ((currentBrightness == d->cachedBrightness) && !d->brightnessInHardware)
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
546 |
+ {
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
547 |
+ int newBrightness;
|
548 |
+ if (increase) {
|
|
549 |
+ newBrightness = qMin(100, currentBrightness + 10);
|
|
550 |
+ }
|
|
551 |
+ else {
|
|
552 |
+ newBrightness = qMax(0, currentBrightness - 10);
|
|
553 |
+ }
|
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
554 |
+
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
555 |
+ Solid::Control::PowerManager::setBrightness(newBrightness);
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
556 |
+ currentBrightness = (int) Solid::Control::PowerManager::brightness();
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
557 |
+ }
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
558 |
+
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
559 |
+ emitBrightnessChanged(currentBrightness, true);
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
560 |
} |
561 |
||
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
562 |
-void PowerDevilDaemon::increaseBrightness()
|
563 |
+void PowerDevilDaemon::decreaseBrightness()
|
|
564 |
{
|
|
565 |
- if (!checkIfCurrentSessionActive()) {
|
|
566 |
- return;
|
|
567 |
- }
|
|
568 |
+ incDecBrightness(false);
|
|
569 |
+}
|
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
570 |
|
571 |
- int currentBrightness = qMin(100, (int)(Solid::Control::PowerManager::brightness() + 10));
|
|
572 |
- Solid::Control::PowerManager::setBrightness(currentBrightness);
|
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
573 |
+void PowerDevilDaemon::increaseBrightness()
|
574 |
+{
|
|
575 |
+ incDecBrightness(true);
|
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
576 |
} |
577 |
||
578 |
void PowerDevilDaemon::shutdownNotification(bool automated) |
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
579 |
@@ -1463,4 +1510,17 @@
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
580 |
SLOT(refreshStatus())); |
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
581 |
} |
582 |
||
583 |
+void PowerDevilDaemon::notifyOfBrightnessChange(int brightness)
|
|
584 |
+{
|
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
585 |
+ emitBrightnessChanged(brightness, false);
|
586 |
+}
|
|
587 |
+
|
|
588 |
+void PowerDevilDaemon::emitBrightnessChanged(int brightness, bool byFnKey)
|
|
589 |
+{
|
|
590 |
+ if ((d->cachedBrightness != brightness) || byFnKey) {
|
|
591 |
+ d->cachedBrightness = brightness;
|
|
592 |
+ emit brightnessChanged(brightness, byFnKey);
|
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
593 |
+ }
|
594 |
+}
|
|
595 |
+
|
|
596 |
#include "PowerDevilDaemon.moc" |
|
|
299
by Felix Geyer
Update the brightness OSD patch to make it work even if the |
597 |
diff -Nur kdebase-workspace-4.4.1.orig/powerdevil/daemon/PowerDevilDaemon.h kdebase-workspace-4.4.1/powerdevil/daemon/PowerDevilDaemon.h
|
598 |
--- kdebase-workspace-4.4.1.orig/powerdevil/daemon/PowerDevilDaemon.h 2009-12-01 01:30:27.000000000 +0100
|
|
599 |
+++ kdebase-workspace-4.4.1/powerdevil/daemon/PowerDevilDaemon.h 2010-03-20 14:26:05.000000000 +0100
|
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
600 |
@@ -61,10 +61,13 @@
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
601 |
|
602 |
SuspensionLockHandler *lockHandler(); |
|
603 |
||
604 |
+ void notifyOfBrightnessChange(int brightness);
|
|
605 |
+
|
|
606 |
private Q_SLOTS: |
|
607 |
void acAdapterStateChanged(int state, bool forced = false); |
|
608 |
void batteryChargePercentChanged(int percent, const QString &udi); |
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
609 |
|
610 |
+ void incDecBrightness(bool increase);
|
|
611 |
void decreaseBrightness(); |
|
612 |
void increaseBrightness(); |
|
613 |
||
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
614 |
@@ -106,6 +109,7 @@
|
|
207
by Jonathan Riddell
Add kubuntu_101_brightness_fn_keys_and_osd.diff to enable brightness |
615 |
void stateChanged(int, bool); |
616 |
void profileChanged(const QString &, const QStringList &); |
|
617 |
void DPMSconfigUpdated(); |
|
618 |
+ void brightnessChanged(int brightness, bool byFnKey);
|
|
619 |
||
620 |
private: |
|
621 |
void lockScreen(); |
|
|
222
by Jonathan Riddell
Refresh kubuntu_101_brightness_fn_keys_and_osd.diff from debfx |
622 |
@@ -127,6 +131,8 @@
|
|
208
by Scott Kitterman
kdebase-workspace (4:4.3.2-0ubuntu7) karmic; urgency=low |
623 |
|
624 |
bool checkIfCurrentSessionActive(); |
|
625 |
||
626 |
+ void emitBrightnessChanged(int brightness, bool byFnKey);
|
|
627 |
+
|
|
628 |
public: |
|
629 |
enum IdleAction {
|
|
630 |
None = 0, |