[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Re: Plasma Media Center and state machines
From:       Alessandro Diaferia <alediaferia () gmail ! com>
Date:       2010-04-04 8:29:03
Message-ID: l2h65627f3a1004040129m84f6d4f6k2bed7dd653778e4b () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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@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@kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>
>


-- 
Alessandro Diaferia
KDE Developer
KDE e.V. member

[Attachment #5 (text/html)]

Hey Christophe,<div><br></div><div>i&#39;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&#39;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&#39;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.<br> <br><div \
class="gmail_quote">2010/4/3 Christophe Olinger <span dir="ltr">&lt;<a \
href="mailto:olingerc@binarylooks.com">olingerc@binarylooks.com</a>&gt;</span><br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex;"> Hey guys,<div><br></div><div>I think I am doing a stupid \
C++ mistake here: I get the follwing \
error:</div><div><br></div><div>mediacontainment.cpp:76: undefined reference to \
&#39;MediaCenter::MediaCenter::State::MediaCenterState(QState*)</div>

<div><br></div><div>The last line of this mail causes the \
error.</div><div><br></div><div><br></div><div>Here is \
mediacenterstate.h</div><div><br></div><div><div>#ifndef \
MEDIACENTERSTATE_H</div><div>#define MEDIACENTERSTATE_H</div>

<div><br></div><div>#include \
&quot;libs/mediacenter/mediacenter.h&quot;</div><div>#include \
&quot;libs/mediacenter/mediacenter_export.h&quot;</div><div><br></div><div>#include \
&lt;QtCore/qabstractstate.h&gt;</div><div>#include &lt;QGraphicsWidget&gt;</div>

<div><br></div><div>#include \
&lt;Plasma/IconWidget&gt;</div><div><br></div><div>namespace MediaCenter {</div><div> \
</div><div>enum State {</div><div>       PictureMode,</div><div>       \
MusicMode,</div><div>       VideoMode,</div>

<div>       Home</div><div>};</div><div><br></div><div>enum MainSubComponent \
{</div><div>       JumpToVideoState,</div><div>       JumpToMusicState,</div><div>    \
JumpToPictureState,</div><div>       JumpToHome,</div><div>       \
ToggleControlBarAutohide,</div>

<div>       ToggleInfoBarAutohide</div><div>};</div><div>    </div><div>class \
MEDIACENTER_EXPORT MediaCenterState : public QAbstractState</div><div>{</div><div>    \
Q_OBJECT</div><div>public:</div><div>       MediaCenterState(QState *parent = \
0);</div>

<div>       virtual ~MediaCenterState();</div><div><br></div><div>       \
QGraphicsWidget *subComponent(MainSubComponent \
c);</div><div><br></div><div>protected:</div><div>       void onExit(QEvent* \
event);</div><div>       void onEntry(QEvent* event);</div>

<div><br></div><div>       Plasma::IconWidget \
*m_jumpToHome;</div><div>};</div><div><br></div><div>} //namespace \
MediaCenter</div><div>#endif // MEDIACENTERSTATE_H</div><div><br><div \
class="gmail_quote">here is mediacenterstate.cpp</div>

<div class="gmail_quote"><br></div><div class="gmail_quote"><div \
class="gmail_quote">#include &quot;mediacenterstate.h&quot;</div><div \
class="gmail_quote"><br></div><div class="gmail_quote">using namespace \
MediaCenter;</div>

<div class="gmail_quote"><br></div><div \
class="gmail_quote">MediaCenterState::MediaCenterState (QState *parent) : \
QAbstractState(parent),</div><div class="gmail_quote">       m_jumpToHome(new \
Plasma::IconWidget())</div><div class="gmail_quote">

{</div><div class="gmail_quote">}</div><div class="gmail_quote"><br></div><div \
class="gmail_quote">MediaCenterState::~MediaCenterState()</div><div \
class="gmail_quote">{</div><div class="gmail_quote">}</div><div class="gmail_quote">

<br></div><div class="gmail_quote">void MediaCenterState::onExit(QEvent \
*event)</div><div class="gmail_quote">{</div><div class="gmail_quote">       \
Q_UNUSED(event);</div><div class="gmail_quote">}</div><div class="gmail_quote">

<br></div><div class="gmail_quote">void MediaCenterState::onEntry(QEvent \
*event)</div><div class="gmail_quote">{</div><div class="gmail_quote">       \
Q_UNUSED(event);</div><div class="gmail_quote">}</div><div class="gmail_quote">

<br></div><div class="gmail_quote">QGraphicsWidget \
*MediaCenterState::subComponent(MediaCenter::MainSubComponent c)</div><div \
class="gmail_quote">{</div><div class="gmail_quote">       if (c == \
MediaCenter::JumpToHome) {</div>

<div class="gmail_quote">             \
m_jumpToHome-&gt;setIcon(&quot;User-Folder&quot;);</div><div class="gmail_quote">     \
return m_jumpToHome;</div><div class="gmail_quote">       }</div><div \
class="gmail_quote">}</div><div>

<br></div><div><br></div><div>here is \
mediacontainment.h</div><div><br></div><div><div>#ifndef \
MEDIACONTAINMENT_H</div><div>#define \
MEDIACONTAINMENT_H</div><div><br></div><div>#include \
&quot;mediacenter/mediacenter.h&quot;</div>

<div>#include &quot;states/mediacenterstate.h&quot;</div><div><br></div><div>#include \
&lt;Plasma/Containment&gt;</div><div>#include \
&lt;QList&gt;</div><div><br></div><div>class QAction;</div><div>class \
QPointF;</div><div>

namespace MediaCenter {</div><div>       class Browser;</div><div>       class \
PlaybackControl;</div><div>       class Playlist;</div><div>       class \
Player;</div><div>       class PictureState;</div><div>       class \
VideoState;</div><div>

}</div><div><br></div><div>class MediaLayout;</div><div><br></div><div>class \
MediaContainment : public Plasma::Containment</div><div>{</div><div>       \
Q_OBJECT</div><div>public:</div><div>       MediaContainment(QObject *parent, const \
QVariantList &amp;args);</div>

<div>       ~MediaContainment();</div><div><br></div><div>       \
QList&lt;QAction*&gt; contextualActions();</div><div><br></div><div>       \
MediaCenter::State currentState();</div><div>       void \
setCurrentState(MediaCenter::State);</div>

<div><br></div><div>       QList&lt;QGraphicsWidget*&gt; \
currentMainComponents();</div><div>       void \
addCurrentMainComponent(QGraphicsWidget*);</div><div><br></div><div>       \
QList&lt;QGraphicsWidget*&gt; currentSubComponents();</div>

<div>       void addCurrentSubComponent(QGraphicsWidget*);</div><div><br></div><div>protected:</div><div> \
void constraintsEvent(Plasma::Constraints \
constraints);</div><div><br></div><div>private slots:</div><div>       void \
slotAppletAdded(Plasma::Applet *applet, const QPointF &amp;pos);</div>

<div>       void slotAppletRemoved(Plasma::Applet *applet);</div><div>       void \
switchState(MediaCenter::State);</div><div><br></div><div>       void \
switchToPictureState();</div><div>       void switchToVideoState();</div><div>       \
void switchToMusicState();</div>

<div><br></div><div>private:</div><div>       MediaCenter::Browser \
*m_browser;</div><div>       MediaCenter::PlaybackControl *m_control;</div><div>      \
MediaCenter::Playlist *m_playlist;</div><div>       MediaCenter::Player \
*m_player;</div>

<div><br></div><div>       MediaCenter::State m_currentState;</div><div>       \
MediaCenter::State m_previousState;</div><div><br></div><div>       \
MediaCenter::MediaCenterState *m_mediaCenterState;</div><div>       \
MediaCenter::VideoState *m_videoState;</div>

<div>       MediaCenter::PictureState *m_pictureState;</div><div><br></div><div>      \
QList&lt;QGraphicsWidget*&gt; m_currentMainComponents;</div><div>       \
QList&lt;QGraphicsWidget*&gt; m_currentSubComponents;</div><div><br></div>

<div>       bool m_musicIsPlaying;</div><div><br></div><div>       MediaLayout \
*m_layout;</div><div><br></div><div>       void addMediaApplet(Plasma::Applet \
*);</div><div><br></div><div>       void initControls();</div><div>       void \
connectControls(MediaCenter::State);</div>

<div><br></div><div>       //we need these to give full control to the containment \
and avoid cycling signals with the controller</div><div>       //the controller&#39;s \
buttons are connected to these</div><div>       void \
controlBarToPictureState();</div>

<div>       void controlBarToVideoState();</div><div>       void \
controlBarToMusicState();</div><div><br></div><div>       void \
startStateMachine();</div><div>};</div><div><br></div><div><br></div><div>and here \
the relevant part of mediacontainment.cpp</div>

<div><br></div><div><div>#include &quot;mediacontainment.h&quot;</div><div>#include \
&quot;medianotificationwidget.h&quot;</div><div>#include \
&quot;medialayout.h&quot;</div><div>#include &quot;mediatoolbox.h&quot;</div><div>

<br></div><div>#include &lt;mediacenter/browser.h&gt;</div><div>#include \
&lt;mediacenter/playbackcontrol.h&gt;</div><div>#include \
&lt;mediacenter/playlist.h&gt;</div><div>#include \
&lt;mediacenter/player.h&gt;</div><div><br>

</div><div>#include &lt;states/videostate.h&gt;</div><div>#include \
&lt;states/picturestate.h&gt;</div><div><br></div><div>// Qt</div><div>#include \
&lt;QAction&gt;</div><div>#include &lt;QStateMachine&gt;</div><div><br></div>

<div>// KDE</div><div>#include &lt;KDebug&gt;</div><div>#include \
&lt;KNotification&gt;</div><div>#include \
&lt;KLocale&gt;</div><div><br></div><div>static const int BROWSER_WIDTH = \
300;</div><div>static const int BROWSER_HEIGHT = 100;</div>

<div><br></div><div><br></div><div>K_EXPORT_PLASMA_APPLET(mediacontainment, \
MediaContainment)</div><div><br></div><div>MediaContainment::MediaContainment(QObject \
*parent, const QVariantList &amp;args) : Plasma::Containment(parent, args),</div>

<div>m_browser(0),</div><div>m_control(0),</div><div>m_playlist(0),</div><div>m_player \
(0),</div><div>m_pictureState(0),</div><div>m_currentState(MediaCenter::PictureMode),</div><div>m_previousState(MediaCenter::PictureMode),</div>


<div>m_musicIsPlaying(false),</div><div>m_layout(new \
MediaLayout(this))</div><div>{</div><div>       \
setContainmentType(Plasma::Containment::CustomContainment);</div><div>       \
setHasConfigurationInterface(true);</div><div>       \
setAcceptHoverEvents(true);</div>

<div>       setToolBox(new MediaToolBox(this));</div><div><br></div><div>       \
connect (toolBox(), SIGNAL(toggled()), m_layout, \
SLOT(toggleShowAllMediaApplets()));</div><div>}</div><div><br></div><div>MediaContainment::~MediaContainment()</div>


<div>{}</div><div><br></div><div>void \
MediaContainment::startStateMachine()</div><div>{</div><div>       //Prepare \
StateMachine</div><div>       QStateMachine machine; //this is not a \
pointer</div><div class="im"><div><br></div> <div>       //Set up all possible \
states</div> </div><div>       m_mediaCenterState = new \
MediaCenter::MediaCenterState(); //these are pointers</div></div></div></div><div \
class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div><br>
</div></div></blockquote></div><br></div></div>
<br>_______________________________________________<br>
Plasma-devel mailing list<br>
<a href="mailto:Plasma-devel@kde.org">Plasma-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/plasma-devel" \
target="_blank">https://mail.kde.org/mailman/listinfo/plasma-devel</a><br> \
<br></blockquote></div><br><br clear="all"><br>-- <br>Alessandro Diaferia<br>KDE \
Developer<br>KDE e.V. member<br><br> </div>



_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic