Commit 6ae41e83 authored by Scott Wheeler's avatar Scott Wheeler

This isn't going anywhere for the moment -- if it gets brought back at some

point that's fine, but I doubt it.

svn path=/trunk/kdemultimedia/juk/; revision=357313
parent 29993549
bin_PROGRAMS = juk-applet
INCLUDES = $(all_includes)
juk_applet_SOURCES = main.cpp juk_applet_base.ui juk_applet.cpp \
playlistitem.cpp
juk_applet_LDADD = $(LIB_KDECORE)
juk_applet_LDFLAGS = $(all_libraries) $(KDE_RPATH)
METASOURCES = AUTO
POFILES = AUTO
#include <qheader.h>
#include <qlistview.h>
#include <kglobalsettings.h>
#include <klocale.h>
#include "juk_applet.h"
#include "playlistitem.h"
JukApplet::JukApplet (QWidget * parent, const char * name)
: JukAppletBase (parent, name)
{
PlayListItem *pli[5];
// adjust - use a (very ...) small font:
QFont std = KGlobalSettings::generalFont();
std.setPointSize ( (int) ( 0.75 * std.pointSize ()) );
setFont (std);
// dummies for testing:
for (int i = 0; i < 5; ++i)
{
pli[i]= new PlayListItem ( m_playList,
i18n ("Track Name"),
i18n ("Artist"), i18n ("Album"),
i18n ("Track"), i18n ("Genre"),
i18n ("5:13"), i18n ("1989"),
i18n("Comment Comment Comment"),
i18n ("filename-filename.ogg") );
}
}
JukApplet::~JukApplet ()
{
}
void JukApplet::refreshItems ( int noOfItems )
{
const int ItemRange = 20; // how many items up and down do we query?
// playingItem is supposed to be up to date!
// find the interval of items we need, make sure the interval is larger
// than or equal to zero :
int min = QMAX ( 0, playingItem - ItemRange);
int max = QMIN (playingItem + ItemRange, noOfItems);
items.clear();
for (int current = min; current < max; ++current)
{
TrackInfo ti;
if (queryItem (current, ti ) )
{
items.insert (current, ti);
}
}
}
void JukApplet::setPlayingItem (int)
{
}
bool JukApplet::queryItem (int /* index */, TrackInfo&)
{
// query the information from JuK...
return false;
}
void JukApplet::invalidateItems( int noOfItems )
{
refreshItems ( noOfItems );
}
#include "juk_applet.moc"
#ifndef JUK_APPLET_H
#define JUK_APPLET_H
#include <qvaluelist.h>
#include <qmap.h>
#include "juk_applet_base.h"
class TrackInfo
{
public:
QString trackname;
QString artist;
QString album;
QString track;
QString genre;
QString length;
QString year;
QString comment;
QString filename;
TrackInfo () {}
TrackInfo (QString trackname_, QString artist_, QString album_,
QString track_, QString genre_, QString length_, QString year_,
QString comment_, QString filename_)
: trackname (trackname_),
artist (artist_),
album (album_),
track (track_),
genre (genre_),
length (length_),
year (year_),
comment (comment_),
filename (filename_)
{}
};
class JukApplet : public JukAppletBase
{
Q_OBJECT
public:
JukApplet (QWidget * parent = 0, const char * name = 0);
~JukApplet ();
signals:
void itemSkipFirst ();
void itemSkipBack ();
void itemPlayPause ();
void itemSkipNext ();
void itemSkipLast ();
public slots:
/** This method is supposedly called by JuK to announce a new playing
track. */
void setPlayingItem (int index);
/** This method is supposedly called by JuK to announce change in the
playlist. This will be a DCOP slot. */
void invalidateItems( int noOfItems );
protected:
/** Refresh the information about tracks stored in currentItems. */
void refreshItems ( int noOfItems );
// basically, the following are stubs to be connected with DCOP:
/** This method is supposed to query information about the track
denominated by index from JuK. */
bool queryItem (int index, TrackInfo&);
/** Store a couple of items, preferably with the active item somewhere in
the middle. */
QMap<int, TrackInfo> items;
int playingItem;
};
#endif // JUK_APPLET_H
<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
<class>JukAppletBase</class>
<widget class="QWidget">
<property name="name">
<cstring>JukAppletBase</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>128</width>
<height>257</height>
</rect>
</property>
<property name="caption">
<string>JuK Applet</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>2</number>
</property>
<property name="spacing">
<number>2</number>
</property>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout1</cstring>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QToolButton" row="0" column="4">
<property name="name">
<cstring>toolButton5</cstring>
</property>
<property name="font">
<font>
</font>
</property>
<property name="text">
<string>&gt;</string>
</property>
</widget>
<widget class="QToolButton" row="0" column="1">
<property name="name">
<cstring>toolButton3</cstring>
</property>
<property name="font">
<font>
</font>
</property>
<property name="text">
<string>&lt;</string>
</property>
</widget>
<widget class="QToolButton" row="0" column="0">
<property name="name">
<cstring>toolButton2</cstring>
</property>
<property name="font">
<font>
</font>
</property>
<property name="text">
<string>|&lt;</string>
</property>
</widget>
<widget class="QToolButton" row="0" column="2" rowspan="1" colspan="2">
<property name="name">
<cstring>toolButton4</cstring>
</property>
<property name="font">
<font>
</font>
</property>
<property name="text">
<string>|&gt;</string>
</property>
</widget>
<widget class="QToolButton" row="0" column="5">
<property name="name">
<cstring>toolButton6</cstring>
</property>
<property name="font">
<font>
</font>
</property>
<property name="text">
<string>&gt;|</string>
</property>
</widget>
</grid>
</widget>
<widget class="QListBox">
<property name="name">
<cstring>m_playList</cstring>
</property>
</widget>
</vbox>
</widget>
<connections>
<connection>
<sender>toolButton2</sender>
<signal>clicked()</signal>
<receiver>JukAppletBase</receiver>
<slot>slotSkipFirst()</slot>
</connection>
<connection>
<sender>toolButton3</sender>
<signal>clicked()</signal>
<receiver>JukAppletBase</receiver>
<slot>slotSkipBack()</slot>
</connection>
<connection>
<sender>toolButton4</sender>
<signal>clicked()</signal>
<receiver>JukAppletBase</receiver>
<slot>slotPlayPause()</slot>
</connection>
<connection>
<sender>toolButton5</sender>
<signal>clicked()</signal>
<receiver>JukAppletBase</receiver>
<slot>slotSkipForward()</slot>
</connection>
<connection>
<sender>toolButton6</sender>
<signal>clicked()</signal>
<receiver>JukAppletBase</receiver>
<slot>slotSkipLast()</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in implementation">juk_applet_base.ui.h</include>
</includes>
<slots>
<slot>slotSkipFirst()</slot>
<slot>slotSkipBack()</slot>
<slot>slotPlayPause()</slot>
<slot>slotSkipForward()</slot>
<slot>slotSkipLast()</slot>
<slot>slotToggleShuffle( bool )</slot>
<slot>slotToggleRepeat( bool )</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void JukAppletBase::slotSkipFirst()
{
}
void JukAppletBase::slotSkipBack()
{
}
void JukAppletBase::slotPlayPause()
{
}
void JukAppletBase::slotSkipForward()
{
}
void JukAppletBase::slotSkipLast()
{
}
void JukAppletBase::slotToggleShuffle( bool )
{
}
void JukAppletBase::slotToggleRepeat( bool )
{
}
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include "juk_applet.h"
int main(int argc, char *argv[])
{
KAboutData aboutData("juk-applet", I18N_NOOP("JuK Applet"),
"0.1", "JuK Kicker Applet - Draft", KAboutData::License_GPL,
"(c) 2003, Mirko Boehm", 0, "http://www.hackerbuero.org");
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication a(argc, argv);
JukApplet applet;
a.setMainWidget (&applet); applet.show();
return a.exec ();
}
#include <qpainter.h>
#include <qstring.h>
#include <qtextstream.h>
#include <qfontmetrics.h>
#include <kglobalsettings.h>
#include <kdebug.h>
#include "playlistitem.h"
PlayListItem::PlayListItem ( QListBox *parent, QString trackname_,
QString artist_, QString album_, QString track_,
QString genre_, QString length_, QString year_,
QString comment_, QString filename_ )
: QListBoxItem (parent), trackname (trackname_),
artist (artist_), album (album_), track (track_),
genre (genre_), year (year_),
length (length_), comment (comment_),
filename (filename_)
{
QFont std = KGlobalSettings::generalFont();
std.setPointSize ( (int) ( 0.75 * std.pointSizeFloat ()) );
QFontMetrics metrics (std);
m_height = 2 * metrics.height() + 4;
}
int PlayListItem::height( const QListBox* ) const
{
return m_height;
}
int PlayListItem::width ( const QListBox *lb) const
{
return lb->width();
}
void PlayListItem::paint ( QPainter * p )
{
QFont std = KGlobalSettings::generalFont();
QColor bgColor = Qt::darkBlue;
QColor separatorColor = Qt::blue;
QRect br, viewport;
QString line1;
QTextStream stream1 (line1, IO_WriteOnly);
QString line2;
QTextStream stream2 (line2, IO_WriteOnly);
std.setPointSize ( (int) ( 0.75 * std.pointSizeFloat ()) );
QFontMetrics metrics (std);
stream1 << artist << " - " << track;
stream2 << year << " - " << length;
viewport = p->viewport ();
int width = viewport.width ();
int height = viewport.height ();
// paint the background:
p->setBrush (bgColor);
p->setPen (bgColor);
p->drawRect (0, 0, width, height );
p->setBrush (separatorColor);
p->setPen (separatorColor);
p->drawRect (0, height - 1, width, height );
// draw the title
p->setPen (Qt::white);
p->setFont (std);
p->drawText ( 2, 2, width -4 , height -4 , Qt::AlignLeft, line1, -1, &br);
p->drawText ( 2, 2 + metrics.height() , width - 4, height - metrics.height() - 4, Qt::AlignLeft, line2, -1, &br);
}
#ifndef PLAYLISTITEM_H
#define PLAYLISTITEM_H
#include <qlistbox.h>
class PlayListItem : public QListBoxItem
{
public:
PlayListItem (QListBox *parent, QString trackname, QString artist, QString album,
QString track, QString genre, QString length, QString year,
QString comment, QString filename);
virtual ~PlayListItem() {}
int height (const QListBox * ) const ;
int width (const QListBox *) const ;
protected:
void paint (QPainter * p);
private:
QString trackname, artist, album, track, genre, year, length, comment, filename;
int m_height;
};
#endif // PLAYLISTITEM_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment