Plasma Media Center and state machines

Alessandro Diaferia alediaferia at gmail.com
Sun Apr 4 10:29:03 CEST 2010


Hey Christophe,

i've just had a look at your repo and you put PMC States libraries in a
different directory called states. The error you encounter is just because
you don't link against that new library. You can just add mediacenterstates
to the TARGET_LINK_LIBRARIES macro of the CMakeLists.txt of the
MediaContainment but I'd prefer you put the States stuff still under
libs/mediacenter because it is part of the MediaCenter API. So, please, move
the States API under libs/mediacenter and your code should compile fine.

2010/4/3 Christophe Olinger <olingerc at binarylooks.com>

> Hey guys,
>
> I think I am doing a stupid C++ mistake here: I get the follwing error:
>
> mediacontainment.cpp:76: undefined reference to
> 'MediaCenter::MediaCenter::State::MediaCenterState(QState*)
>
> The last line of this mail causes the error.
>
>
> Here is mediacenterstate.h
>
> #ifndef MEDIACENTERSTATE_H
> #define MEDIACENTERSTATE_H
>
> #include "libs/mediacenter/mediacenter.h"
> #include "libs/mediacenter/mediacenter_export.h"
>
> #include <QtCore/qabstractstate.h>
> #include <QGraphicsWidget>
>
> #include <Plasma/IconWidget>
>
> namespace MediaCenter {
>
> enum State {
>     PictureMode,
>     MusicMode,
>     VideoMode,
>     Home
> };
>
> enum MainSubComponent {
>     JumpToVideoState,
>     JumpToMusicState,
>     JumpToPictureState,
>     JumpToHome,
>     ToggleControlBarAutohide,
>     ToggleInfoBarAutohide
> };
>
> class MEDIACENTER_EXPORT MediaCenterState : public QAbstractState
> {
>     Q_OBJECT
> public:
>     MediaCenterState(QState *parent = 0);
>     virtual ~MediaCenterState();
>
>     QGraphicsWidget *subComponent(MainSubComponent c);
>
> protected:
>     void onExit(QEvent* event);
>     void onEntry(QEvent* event);
>
>     Plasma::IconWidget *m_jumpToHome;
> };
>
> } //namespace MediaCenter
> #endif // MEDIACENTERSTATE_H
>
> here is mediacenterstate.cpp
>
> #include "mediacenterstate.h"
>
> using namespace MediaCenter;
>
> MediaCenterState::MediaCenterState (QState *parent) :
> QAbstractState(parent),
>     m_jumpToHome(new Plasma::IconWidget())
> {
> }
>
> MediaCenterState::~MediaCenterState()
> {
> }
>
> void MediaCenterState::onExit(QEvent *event)
> {
>     Q_UNUSED(event);
> }
>
> void MediaCenterState::onEntry(QEvent *event)
> {
>     Q_UNUSED(event);
> }
>
> QGraphicsWidget
> *MediaCenterState::subComponent(MediaCenter::MainSubComponent c)
> {
>     if (c == MediaCenter::JumpToHome) {
>         m_jumpToHome->setIcon("User-Folder");
>         return m_jumpToHome;
>     }
> }
>
>
> here is mediacontainment.h
>
> #ifndef MEDIACONTAINMENT_H
> #define MEDIACONTAINMENT_H
>
> #include "mediacenter/mediacenter.h"
> #include "states/mediacenterstate.h"
>
> #include <Plasma/Containment>
> #include <QList>
>
> class QAction;
> class QPointF;
> namespace MediaCenter {
>     class Browser;
>     class PlaybackControl;
>     class Playlist;
>     class Player;
>     class PictureState;
>     class VideoState;
> }
>
> class MediaLayout;
>
> class MediaContainment : public Plasma::Containment
> {
>     Q_OBJECT
> public:
>     MediaContainment(QObject *parent, const QVariantList &args);
>     ~MediaContainment();
>
>     QList<QAction*> contextualActions();
>
>     MediaCenter::State currentState();
>     void setCurrentState(MediaCenter::State);
>
>     QList<QGraphicsWidget*> currentMainComponents();
>     void addCurrentMainComponent(QGraphicsWidget*);
>
>     QList<QGraphicsWidget*> currentSubComponents();
>     void addCurrentSubComponent(QGraphicsWidget*);
>
> protected:
>     void constraintsEvent(Plasma::Constraints constraints);
>
> private slots:
>     void slotAppletAdded(Plasma::Applet *applet, const QPointF &pos);
>     void slotAppletRemoved(Plasma::Applet *applet);
>     void switchState(MediaCenter::State);
>
>     void switchToPictureState();
>     void switchToVideoState();
>     void switchToMusicState();
>
> private:
>     MediaCenter::Browser *m_browser;
>     MediaCenter::PlaybackControl *m_control;
>     MediaCenter::Playlist *m_playlist;
>     MediaCenter::Player *m_player;
>
>     MediaCenter::State m_currentState;
>     MediaCenter::State m_previousState;
>
>     MediaCenter::MediaCenterState *m_mediaCenterState;
>     MediaCenter::VideoState *m_videoState;
>     MediaCenter::PictureState *m_pictureState;
>
>     QList<QGraphicsWidget*> m_currentMainComponents;
>     QList<QGraphicsWidget*> m_currentSubComponents;
>
>     bool m_musicIsPlaying;
>
>     MediaLayout *m_layout;
>
>     void addMediaApplet(Plasma::Applet *);
>
>     void initControls();
>     void connectControls(MediaCenter::State);
>
>     //we need these to give full control to the containment and avoid
> cycling signals with the controller
>     //the controller's buttons are connected to these
>     void controlBarToPictureState();
>     void controlBarToVideoState();
>     void controlBarToMusicState();
>
>     void startStateMachine();
> };
>
>
> and here the relevant part of mediacontainment.cpp
>
> #include "mediacontainment.h"
> #include "medianotificationwidget.h"
> #include "medialayout.h"
> #include "mediatoolbox.h"
>
> #include <mediacenter/browser.h>
> #include <mediacenter/playbackcontrol.h>
> #include <mediacenter/playlist.h>
> #include <mediacenter/player.h>
>
> #include <states/videostate.h>
> #include <states/picturestate.h>
>
> // Qt
> #include <QAction>
> #include <QStateMachine>
>
> // KDE
> #include <KDebug>
> #include <KNotification>
> #include <KLocale>
>
> static const int BROWSER_WIDTH = 300;
> static const int BROWSER_HEIGHT = 100;
>
>
> K_EXPORT_PLASMA_APPLET(mediacontainment, MediaContainment)
>
> MediaContainment::MediaContainment(QObject *parent, const QVariantList
> &args) : Plasma::Containment(parent, args),
> m_browser(0),
> m_control(0),
> m_playlist(0),
> m_player(0),
> m_pictureState(0),
> m_currentState(MediaCenter::PictureMode),
> m_previousState(MediaCenter::PictureMode),
> m_musicIsPlaying(false),
> m_layout(new MediaLayout(this))
> {
>     setContainmentType(Plasma::Containment::CustomContainment);
>     setHasConfigurationInterface(true);
>     setAcceptHoverEvents(true);
>     setToolBox(new MediaToolBox(this));
>
>     connect (toolBox(), SIGNAL(toggled()), m_layout,
> SLOT(toggleShowAllMediaApplets()));
> }
>
> MediaContainment::~MediaContainment()
> {}
>
> void MediaContainment::startStateMachine()
> {
>     //Prepare StateMachine
>     QStateMachine machine; //this is not a pointer
>
>     //Set up all possible states
>     m_mediaCenterState = new MediaCenter::MediaCenterState(); //these are
> pointers
>
>>
>>
>
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel at kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>
>


-- 
Alessandro Diaferia
KDE Developer
KDE e.V. member
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/plasma-devel/attachments/20100404/bc68f136/attachment.htm 


More information about the Plasma-devel mailing list