• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Plasma

playercontainer.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2008  Alex Merry <alex.merry@kdemail.net>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin St, Fifth Floor,
00017  * Boston, MA  02110-1301  USA
00018  */
00019 
00020 #include "playercontainer.h"
00021 
00022 #include "playercontrol.h"
00023 
00024 PlayerContainer::PlayerContainer(Player::Ptr m_player, QObject* parent)
00025     : DataContainer(parent)
00026     , m_player(m_player)
00027     , m_controller(0)
00028 {
00029     Q_ASSERT(m_player);
00030 
00031     setObjectName(m_player->name());
00032 
00033     connect(this, SIGNAL(updateRequested(DataContainer*)),
00034             this, SLOT(updateInfo()));
00035 }
00036 
00037 Plasma::Service* PlayerContainer::service(QObject* parent)
00038 {
00039     if (!m_controller) {
00040         kDebug() << "Creating controller";
00041         m_controller = new PlayerControl(parent, m_player);
00042         connect(this, SIGNAL(updateRequested(DataContainer*)),
00043                 m_controller, SLOT(updateEnabledOperations()));
00044     }
00045     return m_controller;
00046 }
00047 
00048 void PlayerContainer::updateInfo()
00049 {
00050     if (!m_player->isRunning()) {
00051         kDebug() << objectName() << "isn't running";
00052         return;
00053     }
00054 
00055     switch(m_player->state()) {
00056         case Player::Playing:
00057             setData("State", "playing");
00058             break;
00059         case Player::Paused:
00060             setData("State", "paused");
00061             break;
00062         case Player::Stopped:
00063             setData("State", "stopped");
00064             break;
00065     }
00066 
00067     setData("Artist", m_player->artist());
00068     setData("Album", m_player->album());
00069     setData("Title", m_player->title());
00070     setData("Track number", m_player->trackNumber());
00071     setData("Comment", m_player->comment());
00072     setData("Genre", m_player->genre());
00073     setData("Length", m_player->length());
00074     setData("Position", m_player->position());
00075     setData("Volume", m_player->volume());
00076     setData("Artwork", m_player->artwork());
00077 
00078     // propagate changes
00079     checkForUpdate();
00080 }
00081 
00082 #include "playercontainer.moc"

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal