Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 296544 | Differences between
and this patch

Collapse All | Expand All

(-)kdebase-workspace-4.3.4.orig/solid/hal/halpower.cpp (-21 / +42 lines)
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-416 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<int> 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
        brightness = deviceInterface.call("GetBrightness").arguments().at(0).toDouble();
410
397
        if(deviceInterface.lastError().isValid())
411
        QDBusReply<int> brightnessReply = deviceInterface.call("GetBrightness");
412
        if(!brightnessReply.isValid())
398
        {
413
        {
399
            return 0;
414
            return 0.0;
400
        }
415
        }
401
        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())
402
        {
421
        {
403
            QDBusInterface propertyInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device", QDBusConnection::systemBus());
422
            int levels = levelsReply;
404
            int levels = propertyInterface.call("GetProperty", "keyboard_backlight.num_levels").arguments().at(0).toInt();
405
            return (float)(100*(brightness/(levels-1)));
423
            return (float)(100*(brightness/(levels-1)));
406
        }
424
        }
407
    }
425
    }
408
    return 0;
426
    return 0.0;
409
}
427
}
410
428
411
bool HalPower::setBrightness(float brightness, const QString &device)
429
bool HalPower::setBrightness(float brightness, const QString &device)
412
{
430
{
413
    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))
414
    {
433
    {
415
        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());
416
        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 422-428 Link Here
422
            return true;
441
            return true;
423
        }
442
        }
424
    }
443
    }
425
    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))
426
    {
447
    {
427
        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());
428
        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();

Return to bug 296544