nowplaying.h 2.67 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 27 28 29 30 31 32 33
#include "filehandle.h"

class NowPlayingItem;

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

class NowPlaying : public QHBox
34 35 36 37
{
    Q_OBJECT

public:
38 39 40 41 42
    NowPlaying(QWidget *parent, const char *name = 0);
    void addItem(NowPlayingItem *item);

private slots:
    void slotUpdate();    
43 44

private:
45 46
    QValueList<NowPlayingItem *> m_items;
};
47

48 49 50
/**
 * Abstract base for the other NowPlaying items.
 */
51

52 53 54 55
class NowPlayingItem
{
public:
    virtual void update(const FileHandle &file) = 0;
56 57

protected:
58 59 60 61 62 63 64 65 66 67 68 69 70
    NowPlayingItem(NowPlaying *parent) { parent->addItem(this); }
};

/**
 * 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);
71 72 73 74 75 76
    virtual void mousePressEvent(QMouseEvent *event);
    virtual bool eventFilter(QObject *object, QEvent *event);

private:
    FileHandle m_file;
    QWidget *m_popup;
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
};

/**
 * 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
{
public:
    TrackItem(NowPlaying *parent);
    virtual void update(const FileHandle &file);

private:
    KActiveLabel *m_label;
};

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

class HistoryItem : public KActiveLabel, public NowPlayingItem
{
public:
    HistoryItem(NowPlaying *parent);
    virtual void update(const FileHandle &file);
103 104

private:
105 106
    FileHandleList m_history;
    KActiveLabel *m_label;
107 108 109
};

#endif