Lines 361-373
Link Here
|
361 |
Solid::Control::PowerManager::BrightnessControlsList HalPower::brightnessControlsAvailable() |
361 |
Solid::Control::PowerManager::BrightnessControlsList HalPower::brightnessControlsAvailable() |
362 |
{ |
362 |
{ |
363 |
Solid::Control::PowerManager::BrightnessControlsList deviceList; |
363 |
Solid::Control::PowerManager::BrightnessControlsList deviceList; |
364 |
foreach(const QString &name, m_halManager.call("FindDeviceByCapability", "laptop_panel").arguments().at(0).toStringList()) |
364 |
QDBusReply<QStringList> reply = m_halManager.call("FindDeviceByCapability", "laptop_panel"); |
|
|
365 |
if (reply.isValid()) |
365 |
{ |
366 |
{ |
366 |
deviceList.insert(name, Solid::Control::PowerManager::Screen); |
367 |
foreach(const QString &name, reply.value()) |
|
|
368 |
{ |
369 |
deviceList.insert(name, Solid::Control::PowerManager::Screen); |
370 |
} |
367 |
} |
371 |
} |
368 |
foreach(const QString &name, m_halManager.call("FindDeviceByCapability", "keyboard_backlight").arguments().at(0).toStringList()) |
372 |
reply = m_halManager.call("FindDeviceByCapability", "keyboard_backlight"); |
|
|
373 |
if (reply.isValid()) |
369 |
{ |
374 |
{ |
370 |
deviceList.insert(name, Solid::Control::PowerManager::Keyboard); |
375 |
foreach(const QString &name, reply.value()) |
|
|
376 |
{ |
377 |
deviceList.insert(name, Solid::Control::PowerManager::Keyboard); |
378 |
} |
371 |
} |
379 |
} |
372 |
return deviceList; |
380 |
return deviceList; |
373 |
} |
381 |
} |
Lines 375-420
Link Here
|
375 |
float HalPower::brightness(const QString &device) |
383 |
float HalPower::brightness(const QString &device) |
376 |
{ |
384 |
{ |
377 |
float brightness; |
385 |
float brightness; |
378 |
if(m_halManager.call("FindDeviceByCapability", "laptop_panel").arguments().at(0).toStringList().contains(device)) |
386 |
QDBusReply<QStringList> reply = m_halManager.call("FindDeviceByCapability", "laptop_panel"); |
|
|
387 |
if(reply.isValid() && reply.value().contains(device)) |
379 |
{ |
388 |
{ |
380 |
QDBusInterface deviceInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device.LaptopPanel", QDBusConnection::systemBus()); |
389 |
QDBusInterface deviceInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device.LaptopPanel", QDBusConnection::systemBus()); |
381 |
brightness = deviceInterface.call("GetBrightness").arguments().at(0).toDouble(); |
390 |
QDBusReply<double> brightnessReply = deviceInterface.call("GetBrightness"); |
382 |
if(deviceInterface.lastError().isValid()) |
391 |
if(!brightnessReply.isValid()) |
383 |
{ |
392 |
{ |
384 |
return 0; |
393 |
return 0.0; |
385 |
} |
394 |
} |
386 |
else |
395 |
brightness = brightnessReply; |
|
|
396 |
|
397 |
QDBusInterface propertyInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device", QDBusConnection::systemBus()); |
398 |
QDBusReply<int> levelsReply = propertyInterface.call("GetProperty", "laptop_panel.num_levels"); |
399 |
if (levelsReply.isValid()) |
387 |
{ |
400 |
{ |
388 |
QDBusInterface propertyInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device", QDBusConnection::systemBus()); |
401 |
int levels = levelsReply; |
389 |
int levels = propertyInterface.call("GetProperty", "laptop_panel.num_levels").arguments().at(0).toInt(); |
|
|
390 |
return (float)(100*(brightness/(levels-1))); |
402 |
return (float)(100*(brightness/(levels-1))); |
391 |
} |
403 |
} |
392 |
} |
404 |
} |
393 |
if(m_halManager.call("FindDeviceByCapability", "keyboard_backlight").arguments().at(0).toStringList().contains(device)) |
405 |
|
|
|
406 |
reply = m_halManager.call("FindDeviceByCapability", "keyboard_backlight"); |
407 |
if(reply.isValid() && reply.value().contains(device)) |
394 |
{ |
408 |
{ |
395 |
QDBusInterface deviceInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device.KeyboardBacklight", QDBusConnection::systemBus()); //TODO - I do not have a backlight enabled keyboard, so I'm guessing a bit here. Could someone please check this. |
409 |
QDBusInterface deviceInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device.KeyboardBacklight", QDBusConnection::systemBus()); //TODO - I do not have a backlight enabled keyboard, so I'm guessing a bit here. Could someone please check this. |
396 |
|
410 |
|
397 |
QDBusMessage getBrightnessDBusMessage = deviceInterface.call("GetBrightness"); |
411 |
QDBusReply<double> brightnessReply = deviceInterface.call("GetBrightness"); |
398 |
if(!deviceInterface.lastError().isValid()) |
412 |
if(!brightnessReply.isValid()) |
399 |
brightness = getBrightnessDBusMessage.arguments().at(0).toDouble(); |
|
|
400 |
|
401 |
if(deviceInterface.lastError().isValid()) |
402 |
{ |
413 |
{ |
403 |
return 0; |
414 |
return 0.0; |
404 |
} |
415 |
} |
405 |
else |
416 |
brightness = brightnessReply; |
|
|
417 |
|
418 |
QDBusInterface propertyInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device", QDBusConnection::systemBus()); |
419 |
QDBusReply<int> levelsReply = propertyInterface.call("GetProperty", "keyboard_backlight.num_levels"); |
420 |
if (levelsReply.isValid()) |
406 |
{ |
421 |
{ |
407 |
QDBusInterface propertyInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device", QDBusConnection::systemBus()); |
422 |
int levels = levelsReply; |
408 |
int levels = propertyInterface.call("GetProperty", "keyboard_backlight.num_levels").arguments().at(0).toInt(); |
|
|
409 |
return (float)(100*(brightness/(levels-1))); |
423 |
return (float)(100*(brightness/(levels-1))); |
410 |
} |
424 |
} |
411 |
} |
425 |
} |
412 |
return 0; |
426 |
return 0.0; |
413 |
} |
427 |
} |
414 |
|
428 |
|
415 |
bool HalPower::setBrightness(float brightness, const QString &device) |
429 |
bool HalPower::setBrightness(float brightness, const QString &device) |
416 |
{ |
430 |
{ |
417 |
if(m_halManager.call("FindDeviceByCapability", "laptop_panel").arguments().at(0).toStringList().contains(device)) |
431 |
QDBusReply<QStringList> reply = m_halManager.call("FindDeviceByCapability", "laptop_panel"); |
|
|
432 |
if(reply.isValid() && reply.value().contains(device)) |
418 |
{ |
433 |
{ |
419 |
QDBusInterface propertyInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device", QDBusConnection::systemBus()); |
434 |
QDBusInterface propertyInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device", QDBusConnection::systemBus()); |
420 |
int levels = propertyInterface.call("GetProperty", "laptop_panel.num_levels").arguments().at(0).toInt(); |
435 |
int levels = propertyInterface.call("GetProperty", "laptop_panel.num_levels").arguments().at(0).toInt(); |
Lines 426-432
Link Here
|
426 |
return true; |
441 |
return true; |
427 |
} |
442 |
} |
428 |
} |
443 |
} |
429 |
if(m_halManager.call("FindDeviceByCapability", "keyboard_backlight").arguments().at(0).toStringList().contains(device)) |
444 |
|
|
|
445 |
reply = m_halManager.call("FindDeviceByCapability", "keyboard_backlight"); |
446 |
if(reply.isValid() && reply.value().contains(device)) |
430 |
{ |
447 |
{ |
431 |
QDBusInterface propertyInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device", QDBusConnection::systemBus()); |
448 |
QDBusInterface propertyInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device", QDBusConnection::systemBus()); |
432 |
int levels = propertyInterface.call("GetProperty", "keyboard_backlight.num_levels").arguments().at(0).toInt(); |
449 |
int levels = propertyInterface.call("GetProperty", "keyboard_backlight.num_levels").arguments().at(0).toInt(); |