mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-24 02:42:50 +00:00
generic: misc cleanups
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
427f66443e
commit
801410d5d1
16 changed files with 100 additions and 102 deletions
|
@ -39,6 +39,7 @@
|
||||||
#include <kconfiggroup.h>
|
#include <kconfiggroup.h>
|
||||||
#include <kstandarddirs.h>
|
#include <kstandarddirs.h>
|
||||||
#include <kprocess.h>
|
#include <kprocess.h>
|
||||||
|
#include <kauthhelpersupport.h>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#ifndef CLOCK_HELPER_H
|
#ifndef CLOCK_HELPER_H
|
||||||
#define CLOCK_HELPER_H
|
#define CLOCK_HELPER_H
|
||||||
|
|
||||||
#include <kauth.h>
|
#include <kauthactionreply.h>
|
||||||
|
|
||||||
using namespace KAuth;
|
using namespace KAuth;
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <KConfig>
|
#include <KConfig>
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
|
#include <kauthhelpersupport.h>
|
||||||
|
|
||||||
bool secureCopy(const QString &from, const QString &to)
|
bool secureCopy(const QString &from, const QString &to)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#ifndef KDM_HELPER_H
|
#ifndef KDM_HELPER_H
|
||||||
#define KDM_HELPER_H
|
#define KDM_HELPER_H
|
||||||
|
|
||||||
#include <kauth.h>
|
#include <kauthactionreply.h>
|
||||||
|
|
||||||
using namespace KAuth;
|
using namespace KAuth;
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <KIO/Job>
|
#include <KIO/Job>
|
||||||
#include <KIO/DeleteJob>
|
#include <KIO/DeleteJob>
|
||||||
#include <KIO/NetAccess>
|
#include <KIO/NetAccess>
|
||||||
|
#include <KAuth/Action>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
#include <KStandardGuiItem>
|
#include <KStandardGuiItem>
|
||||||
#include <KIO/NetAccess>
|
#include <KIO/NetAccess>
|
||||||
|
#include <KAuth/Action>
|
||||||
|
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <kconfig.h>
|
#include <kconfig.h>
|
||||||
#include <kpluginfactory.h>
|
#include <kpluginfactory.h>
|
||||||
#include <kpluginloader.h>
|
#include <kpluginloader.h>
|
||||||
|
#include <kauthaction.h>
|
||||||
|
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "notifybysound.h"
|
#include "notifybysound.h"
|
||||||
|
|
||||||
// QT headers
|
// QT headers
|
||||||
#include <QHash>
|
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
#include <QtCore/QQueue>
|
#include <QtCore/QQueue>
|
||||||
#include <QtCore/qcoreevent.h>
|
#include <QtCore/qcoreevent.h>
|
||||||
|
@ -47,43 +46,38 @@
|
||||||
|
|
||||||
class NotifyBySound::Private
|
class NotifyBySound::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum { NoSound, UseMediaPlayer } playerMode;
|
bool noSound;
|
||||||
|
QMap<int, KAudioPlayer*> playerObjects;
|
||||||
QHash<int, KAudioPlayer*> playerObjects;
|
QSignalMapper *signalmapper;
|
||||||
QSignalMapper *signalmapper;
|
KAudioPlayer *currentPlayer;
|
||||||
KAudioPlayer *currentPlayer;
|
QQueue<int> closeQueue;
|
||||||
QQueue<int> closeQueue;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NotifyBySound::NotifyBySound(QObject *parent) : KNotifyPlugin(parent),d(new Private)
|
NotifyBySound::NotifyBySound(QObject *parent) : KNotifyPlugin(parent),d(new Private)
|
||||||
{
|
{
|
||||||
d->signalmapper = new QSignalMapper(this);
|
d->signalmapper = new QSignalMapper(this);
|
||||||
connect(d->signalmapper, SIGNAL(mapped(int)), this, SLOT(slotSoundFinished(int)));
|
connect(d->signalmapper, SIGNAL(mapped(int)), this, SLOT(slotSoundFinished(int)));
|
||||||
|
|
||||||
d->currentPlayer = new KAudioPlayer(this);
|
d->currentPlayer = new KAudioPlayer(this);
|
||||||
startTimer(1000);
|
startTimer(1000);
|
||||||
loadConfig();
|
loadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NotifyBySound::~NotifyBySound()
|
NotifyBySound::~NotifyBySound()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NotifyBySound::loadConfig()
|
void NotifyBySound::loadConfig()
|
||||||
{
|
{
|
||||||
// load player settings
|
// load player settings
|
||||||
KSharedConfig::Ptr kc = KGlobal::config();
|
KSharedConfig::Ptr kc = KGlobal::config();
|
||||||
KConfigGroup cg(kc, "Sounds");
|
KConfigGroup cg(kc, "Sounds");
|
||||||
|
|
||||||
d->playerMode = Private::UseMediaPlayer;
|
d->noSound = cg.readEntry( "No sound" , false );
|
||||||
if(cg.readEntry( "No sound" , false ))
|
|
||||||
{
|
|
||||||
d->playerMode = Private::NoSound;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,103 +85,95 @@ void NotifyBySound::loadConfig()
|
||||||
|
|
||||||
void NotifyBySound::notify( int eventId, KNotifyConfig * config )
|
void NotifyBySound::notify( int eventId, KNotifyConfig * config )
|
||||||
{
|
{
|
||||||
if(d->playerMode == Private::NoSound)
|
if (d->noSound) {
|
||||||
{
|
finish( eventId );
|
||||||
finish( eventId );
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(d->playerObjects.contains(eventId))
|
if (d->playerObjects.contains(eventId)) {
|
||||||
{
|
//a sound is already playing for this notification, we don't support playing two sounds.
|
||||||
//a sound is already playing for this notification, we don't support playing two sounds.
|
finish( eventId );
|
||||||
finish( eventId );
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
KUrl soundFileURL = config->readEntry( "Sound" , true );
|
KUrl soundFileURL = config->readEntry( "Sound" , true );
|
||||||
QString soundFile = soundFileURL.toLocalFile();
|
QString soundFile = soundFileURL.toLocalFile();
|
||||||
|
|
||||||
if (soundFile.isEmpty())
|
if (soundFile.isEmpty()) {
|
||||||
{
|
finish( eventId );
|
||||||
finish( eventId );
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// get file name
|
// get file name
|
||||||
if ( KUrl::isRelativeUrl(soundFile) )
|
if (KUrl::isRelativeUrl(soundFile)) {
|
||||||
{
|
QString search = QString("%1/sounds/%2").arg(config->appname).arg(soundFile);
|
||||||
QString search = QString("%1/sounds/%2").arg(config->appname).arg(soundFile);
|
search = KGlobal::mainComponent().dirs()->findResource("data", search);
|
||||||
search = KGlobal::mainComponent().dirs()->findResource("data", search);
|
if ( search.isEmpty() ) {
|
||||||
if ( search.isEmpty() )
|
soundFile = KStandardDirs::locate( "sound", soundFile );
|
||||||
soundFile = KStandardDirs::locate( "sound", soundFile );
|
} else {
|
||||||
else
|
soundFile = search;
|
||||||
soundFile = search;
|
}
|
||||||
}
|
}
|
||||||
if ( soundFile.isEmpty() )
|
if ( soundFile.isEmpty() ) {
|
||||||
{
|
finish( eventId );
|
||||||
finish( eventId );
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
kDebug() << " going to play " << soundFile;
|
kDebug() << " going to play " << soundFile;
|
||||||
|
if (!d->noSound) {
|
||||||
if(d->playerMode == Private::UseMediaPlayer)
|
KAudioPlayer *player = d->currentPlayer;
|
||||||
{
|
if (d->currentPlayer && d->currentPlayer->isPlaying()) {
|
||||||
KAudioPlayer *player = d->currentPlayer;
|
kDebug() << "creating new player";
|
||||||
if (d->currentPlayer && d->currentPlayer->isPlaying()) {
|
player = new KAudioPlayer(this);
|
||||||
kDebug() << "creating new player";
|
}
|
||||||
player = new KAudioPlayer(this);
|
connect(player, SIGNAL(finished()), d->signalmapper, SLOT(map()));
|
||||||
}
|
d->signalmapper->setMapping(player, eventId);
|
||||||
connect(player, SIGNAL(finished()), d->signalmapper, SLOT(map()));
|
player->load(soundFile);
|
||||||
d->signalmapper->setMapping(player, eventId);
|
d->playerObjects.insert(eventId, player);
|
||||||
player->load(soundFile);
|
}
|
||||||
d->playerObjects.insert(eventId, player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NotifyBySound::timerEvent(QTimerEvent *e)
|
void NotifyBySound::timerEvent(QTimerEvent *e)
|
||||||
{
|
{
|
||||||
QMutableHashIterator<int,KAudioPlayer*> iter(d->playerObjects);
|
QMutableMapIterator<int,KAudioPlayer*> iter(d->playerObjects);
|
||||||
while(iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
iter.next();
|
iter.next();
|
||||||
KAudioPlayer *player = iter.value();
|
KAudioPlayer *player = iter.value();
|
||||||
if (player != d->currentPlayer && !player->isPlaying()) {
|
if (player != d->currentPlayer && !player->isPlaying()) {
|
||||||
kDebug() << "destroying idle player";
|
kDebug() << "destroying idle player";
|
||||||
d->playerObjects.remove(iter.key());
|
d->playerObjects.remove(d->playerObjects.key(player));
|
||||||
delete player;
|
player->deleteLater();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
KNotifyPlugin::timerEvent(e);
|
}
|
||||||
|
KNotifyPlugin::timerEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyBySound::slotSoundFinished(int id)
|
void NotifyBySound::slotSoundFinished(int id)
|
||||||
{
|
{
|
||||||
kDebug() << id;
|
kDebug() << id;
|
||||||
if(d->playerObjects.contains(id))
|
if (d->playerObjects.contains(id)) {
|
||||||
{
|
KAudioPlayer *player=d->playerObjects.value(id);
|
||||||
KAudioPlayer *player=d->playerObjects.value(id);
|
disconnect(player, SIGNAL(finished()), d->signalmapper, SLOT(map()));
|
||||||
disconnect(player, SIGNAL(finished()), d->signalmapper, SLOT(map()));
|
}
|
||||||
}
|
finish(id);
|
||||||
finish(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyBySound::close(int id)
|
void NotifyBySound::close(int id)
|
||||||
{
|
{
|
||||||
// close in 1 min - ugly workaround for sounds getting cut off because the close call in kdelibs
|
// close in 1 min - ugly workaround for sounds getting cut off because the close call in kdelibs
|
||||||
// is hardcoded to 6 seconds
|
// is hardcoded to 6 seconds
|
||||||
d->closeQueue.enqueue(id);
|
d->closeQueue.enqueue(id);
|
||||||
QTimer::singleShot(60000, this, SLOT(closeNow()));
|
QTimer::singleShot(60000, this, SLOT(closeNow()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyBySound::closeNow()
|
void NotifyBySound::closeNow()
|
||||||
{
|
{
|
||||||
const int id = d->closeQueue.dequeue();
|
const int id = d->closeQueue.dequeue();
|
||||||
if(d->playerObjects.contains(id))
|
if (d->playerObjects.contains(id)) {
|
||||||
{
|
KAudioPlayer *player = d->playerObjects.value(id);
|
||||||
KAudioPlayer *player = d->playerObjects.value(id);
|
player->stop();
|
||||||
player->stop();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_notifybysound.cpp"
|
#include "moc_notifybysound.cpp"
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "savehelper.h"
|
#include "savehelper.h"
|
||||||
|
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
|
#include <kauthhelpersupport.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
ActionReply SaveHelper::save(QVariantMap args)
|
ActionReply SaveHelper::save(QVariantMap args)
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef _SAVEHELPER_H_
|
#ifndef _SAVEHELPER_H_
|
||||||
#define _SAVEHELPER_H_
|
#define _SAVEHELPER_H_
|
||||||
|
|
||||||
#include <kauth.h>
|
#include <kauthactionreply.h>
|
||||||
|
|
||||||
using namespace KAuth;
|
using namespace KAuth;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ DEALINGS IN THE SOFTWARE.
|
||||||
#include <kmessagebox.h>
|
#include <kmessagebox.h>
|
||||||
#include <KIcon>
|
#include <KIcon>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <kauth.h>
|
#include <kauthaction.h>
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
#include "processes_local_p.h"
|
#include "processes_local_p.h"
|
||||||
|
|
||||||
|
#include <kauthhelpersupport.h>
|
||||||
|
|
||||||
KSysGuardProcessListHelper::KSysGuardProcessListHelper()
|
KSysGuardProcessListHelper::KSysGuardProcessListHelper()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<QList<long long> >();
|
qRegisterMetaType<QList<long long> >();
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <kauth.h>
|
#include <kauthactionreply.h>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
using namespace KAuth;
|
using namespace KAuth;
|
||||||
|
|
|
@ -47,7 +47,9 @@
|
||||||
|
|
||||||
#include <signal.h> //For SIGTERM
|
#include <signal.h> //For SIGTERM
|
||||||
|
|
||||||
#include <kauth.h>
|
#include <kauthaction.h>
|
||||||
|
#include <kauthactionreply.h>
|
||||||
|
#include <kauthhelpersupport.h>
|
||||||
#include <kaction.h>
|
#include <kaction.h>
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <kmessagebox.h>
|
#include <kmessagebox.h>
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "backlighthelper.h"
|
#include "backlighthelper.h"
|
||||||
|
|
||||||
|
#include <kauthhelpersupport.h>
|
||||||
|
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#define BACKLIGHTHELPER_H
|
#define BACKLIGHTHELPER_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <kauth.h>
|
#include <kauthactionreply.h>
|
||||||
|
|
||||||
using namespace KAuth;
|
using namespace KAuth;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue