~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/generic/dataengines/nowplaying/playercontrol.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2008  Alex Merry <alex.merry@kdemail.net>
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2.1 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor,
 
17
 * Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
#include "playercontrol.h"
 
21
#include "playeractionjob.h"
 
22
 
 
23
#include <kdebug.h>
 
24
 
 
25
PlayerControl::PlayerControl(QObject* parent, Player::Ptr player)
 
26
    : Plasma::Service(parent),
 
27
      m_player(player)
 
28
{
 
29
    setObjectName( QLatin1String("nowplaying controller" ));
 
30
    setName("nowplaying");
 
31
    if (m_player) {
 
32
        setDestination(m_player->name());
 
33
        setObjectName( QLatin1String("nowplaying controller for" ) + m_player->name());
 
34
        kDebug() << "Created a player control for" << m_player->name();
 
35
    } else {
 
36
        kDebug() << "Created a dead player control";
 
37
    }
 
38
    updateEnabledOperations();
 
39
}
 
40
 
 
41
void PlayerControl::updateEnabledOperations()
 
42
{
 
43
    if (m_player) {
 
44
        /*
 
45
        kDebug() << "Updating operations:"
 
46
                 << "\n    Play:" << m_player->canPlay()
 
47
                 << "\n    Pause:" << m_player->canPause()
 
48
                 << "\n    Stop:" << m_player->canStop()
 
49
                 << "\n    Next:" << m_player->canGoNext()
 
50
                 << "\n    Previous:" << m_player->canGoPrevious()
 
51
                 << "\n    Volume:" << m_player->canSetVolume()
 
52
                 << "\n    Seek:" << m_player->canSeek();
 
53
                 */
 
54
        setOperationEnabled("play", m_player->canPlay());
 
55
        setOperationEnabled("pause", m_player->canPause());
 
56
        setOperationEnabled("stop", m_player->canStop());
 
57
        setOperationEnabled("next", m_player->canGoNext());
 
58
        setOperationEnabled("previous", m_player->canGoPrevious());
 
59
        setOperationEnabled("volume", m_player->canSetVolume());
 
60
        setOperationEnabled("seek", m_player->canSeek());
 
61
    } else {
 
62
        kDebug() << "No player";
 
63
    }
 
64
}
 
65
 
 
66
Plasma::ServiceJob* PlayerControl::createJob(const QString& operation,
 
67
                                             QMap<QString,QVariant>& parameters)
 
68
{
 
69
    kDebug() << "Job" << operation << "with arguments" << parameters << "requested";
 
70
    return new PlayerActionJob(m_player, operation, parameters, this);
 
71
}
 
72
 
 
73
#include "playercontrol.moc"
 
74
 
 
75
// vim: sw=4 sts=4 et tw=100