VolumeBarLogic::VolumeBarLogic(QObject *parent) :
    QObject(parent),
    volumeBarWindow(NULL),
    dbus_conn (NULL),
    currentvolume (0),
    currentmax (0)
#if (HAVE_LIBRESOURCEQT && HAVE_QMSYSTEM)
    ,hwkeys(new MeeGo::QmKeys(this))
#endif
{
    openConnection (true);

#if (HAVE_LIBRESOURCEQT && HAVE_QMSYSTEM)
    hwkeyResource = new ResourcePolicy::ResourceSet("event");
    hwkeyResource->setAlwaysReply();

    ResourcePolicy::ScaleButtonResource *volumeKeys = new ResourcePolicy::ScaleButtonResource;
    hwkeyResource->addResourceObject(volumeKeys);
    connect(hwkeyResource, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)), this, SLOT(hwKeyResourceAcquired()));
    connect(hwkeyResource, SIGNAL(lostResources()), this, SLOT(hwKeyResourceLost()));

    hwkeyResource->acquire();
#endif
}
VolumeBarLogic::VolumeBarLogic(QObject *parent) :
    QObject(parent),
    volumeBarWindow(NULL),
    currentvolume (0),
    currentmax (0),
    hwkeys(new keySniffer()),
    mHideTimer(new QTimer())  
{
    mHideTimer->setSingleShot(TRUE);
    openConnection();    

#if (HAVE_LIBRESOURCEQT)
    hwkeyResource = new ResourcePolicy::ResourceSet("event");
    hwkeyResource->setAlwaysReply();

    ResourcePolicy::ScaleButtonResource *volumeKeys = new ResourcePolicy::ScaleButtonResource;
    hwkeyResource->addResourceObject(volumeKeys);
    connect(hwkeyResource, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)), this, SLOT(hwKeyResourceAcquired()));
    connect(hwkeyResource, SIGNAL(lostResources()), this, SLOT(hwKeyResourceLost()));    

    hwkeyResource->acquire();
#endif
}
Ejemplo n.º 3
0
VolumeControl::VolumeControl(QObject *parent) :
    QObject(parent),
    window(0),
    pulseAudioControl(new PulseAudioControl(this)),
    hwKeyResource(new ResourcePolicy::ResourceSet("event")),
    hwKeysAcquired(false),
    volume_(0),
    maximumVolume_(0),
    audioWarning(new MGConfItem("/desktop/nemo/audiowarning", this)),
    safeVolume_(0),
    callActive_(false)
{
    hwKeyResource->setAlwaysReply();
    hwKeyResource->addResourceObject(new ResourcePolicy::ScaleButtonResource);
    connect(hwKeyResource, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)), this, SLOT(hwKeyResourceAcquired()));
    connect(hwKeyResource, SIGNAL(lostResources()), this, SLOT(hwKeyResourceLost()));

    // Set up key repeat: initial delay and per-repeat delay
    keyRepeatDelayTimer.setSingleShot(true);
    keyRepeatDelayTimer.setInterval(600);
    keyRepeatTimer.setInterval(75);
    connect(&keyRepeatDelayTimer, SIGNAL(timeout()), &keyRepeatTimer, SLOT(start()));
    connect(&keyRepeatTimer, SIGNAL(timeout()), this, SLOT(changeVolume()));

    connect(pulseAudioControl, SIGNAL(volumeChanged(int,int)), this, SLOT(setVolume(int,int)));
    connect(pulseAudioControl, SIGNAL(highVolume(int)), SLOT(handleHighVolume(int)));
    connect(pulseAudioControl, SIGNAL(longListeningTime(int)), SLOT(handleLongListeningTime(int)));
    connect(pulseAudioControl, SIGNAL(callActiveChanged(bool)), SLOT(handleCallActive(bool)));
    pulseAudioControl->update();

    qApp->installEventFilter(this);

    acquireKeys();
}