Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

nowplaying.h 3.28 KB
Newer Older
1
/***************************************************************************
2 3 4
    begin                : Tue Nov 9 2004
    copyright            : (C) 2004 by Scott Wheeler
    email                : wheeler@kde.org
5 6 7 8 9 10 11 12 13 14 15 16 17 18
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef NOWPLAYING_H
#define NOWPLAYING_H

19
#include <kactivelabel.h>
20

21 22
#include <qhbox.h>
#include <qlabel.h>
23

24 25 26
#include "filehandle.h"

class NowPlayingItem;
27
class PlaylistCollection;
28 29 30 31 32 33 34

/**
 * This is the widget that holds all of the other items and handles updating them
 * when the playing item changes.
 */

class NowPlaying : public QHBox
35 36 37 38
{
    Q_OBJECT

public:
39 40
    NowPlaying(QWidget *parent, PlaylistCollection *collection,
               const char *name = 0);
41
    void addItem(NowPlayingItem *item);
42
    PlaylistCollection *collection() const;
43 44 45

private slots:
    void slotUpdate();    
46 47

private:
48
    PlaylistCollection *m_collection;
49 50
    QValueList<NowPlayingItem *> m_items;
};
51

52 53 54
/**
 * Abstract base for the other NowPlaying items.
 */
55

56 57 58 59
class NowPlayingItem
{
public:
    virtual void update(const FileHandle &file) = 0;
60
    NowPlaying *parent() const { return m_parent; }
61
protected:
62 63 64
    NowPlayingItem(NowPlaying *parent) : m_parent(parent) { parent->addItem(this); }
private:
    NowPlaying *m_parent;
65 66 67 68 69 70 71 72 73 74 75 76
};

/**
 * Displays the cover of the currently playing file if available, or hides
 * itself if not.
 */

class CoverItem : public QLabel, public NowPlayingItem
{
public:
    CoverItem(NowPlaying *parent);
    virtual void update(const FileHandle &file);
77
    virtual void mouseReleaseEvent(QMouseEvent *event);
78

79 80 81 82
protected:
    virtual void dragEnterEvent(QDragEnterEvent *e);
    virtual void dropEvent(QDropEvent *e);

83 84
private:
    FileHandle m_file;
85 86
};

87 88 89 90 91 92 93 94 95 96 97
/**
 * A link label that doesn't automatically open Konqueror.
 */

class LinkLabel : public KActiveLabel
{
public:
    LinkLabel(QWidget *parent, const char *name = 0) : KActiveLabel(parent, name) {}
    virtual void openLink(const QString &) {}
};

98 99 100 101 102 103 104
/**
 * Show the text information on the current track and provides links to the
 * album and artist of the currently playing item.
 */

class TrackItem : public QWidget, public NowPlayingItem
{
105 106
    Q_OBJECT

107 108 109 110
public:
    TrackItem(NowPlaying *parent);
    virtual void update(const FileHandle &file);

111 112 113
private slots:
    void slotOpenLink(const QString &link);

114
private:
115
    FileHandle m_file;
116
    LinkLabel *m_label;
117 118 119 120 121 122
};

/**
 * Shows up to 10 items of history and links to those items.
 */

123
class HistoryItem : public LinkLabel, public NowPlayingItem
124 125 126 127
{
public:
    HistoryItem(NowPlaying *parent);
    virtual void update(const FileHandle &file);
128 129

private:
130
    FileHandleList m_history;
131
    LinkLabel *m_label;
132 133 134
};

#endif