mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
knotify: simplify idle players cleanup
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
513dbc7b53
commit
f7f25c5f7c
2 changed files with 5 additions and 20 deletions
|
@ -60,7 +60,6 @@ NotifyBySound::NotifyBySound(QObject *parent) : KNotifyPlugin(parent),d(new Priv
|
|||
connect(d->signalmapper, SIGNAL(mapped(int)), this, SLOT(slotSoundFinished(int)));
|
||||
|
||||
d->currentPlayer = new KAudioPlayer(this);
|
||||
startTimer(1000);
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
|
@ -133,28 +132,17 @@ void NotifyBySound::notify( int eventId, KNotifyConfig * config )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void NotifyBySound::timerEvent(QTimerEvent *e)
|
||||
{
|
||||
QMutableMapIterator<int,KAudioPlayer*> iter(d->playerObjects);
|
||||
while (iter.hasNext()) {
|
||||
iter.next();
|
||||
KAudioPlayer *player = iter.value();
|
||||
if (player != d->currentPlayer && !player->isPlaying()) {
|
||||
kDebug() << "destroying idle player";
|
||||
d->playerObjects.remove(d->playerObjects.key(player));
|
||||
player->deleteLater();
|
||||
}
|
||||
}
|
||||
KNotifyPlugin::timerEvent(e);
|
||||
}
|
||||
|
||||
void NotifyBySound::slotSoundFinished(int id)
|
||||
{
|
||||
kDebug() << id;
|
||||
if (d->playerObjects.contains(id)) {
|
||||
KAudioPlayer *player=d->playerObjects.value(id);
|
||||
disconnect(player, SIGNAL(finished()), d->signalmapper, SLOT(map()));
|
||||
if (player != d->currentPlayer) {
|
||||
kDebug() << "destroying idle player";
|
||||
d->playerObjects.remove(id);
|
||||
player->deleteLater();
|
||||
}
|
||||
}
|
||||
finish(id);
|
||||
}
|
||||
|
|
|
@ -44,9 +44,6 @@ class NotifyBySound : public KNotifyPlugin
|
|||
public:
|
||||
void setVolume( int v );
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotSoundFinished(int id);
|
||||
void closeNow();
|
||||
|
|
Loading…
Add table
Reference in a new issue