1
// =============================================================================
3
// Copyright (C) 1999-2000 Szymon Stefanek
5
// This program is FREE software. You can redistribute it and/or
6
// modify it under the terms of the GNU General Public License
7
// as published by the Free Software Foundation; either version 2
8
// of the License, or (at your opinion) any later version.
10
// This program is distributed in the HOPE that it will be USEFUL,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
// See the GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program. If not, write to the Free Software Foundation,
17
// Inc, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
// =============================================================================
21
#define _KVI_DEBUG_CHECK_RANGE_
22
#define _KVI_DEBUG_CLASS_NAME_ "KviXmmsWidget"
26
#define __KVIRC_PLUGIN__
28
#include "kvi_process.h"
30
#include "kvi_xmms_widget.h"
31
#include "kvirc_plugin.h"
33
KviXmmsWidget::KviXmmsWidget(void *handle, KviStatusBar *parent, KviFrame *frame)
34
: KviDockableWidget(handle, parent)
42
setBackgroundMode(NoBackground);
43
m_timer = startTimer(KVI_XMMS_UPDATE_TIME);
46
KviXmmsWidget::~KviXmmsWidget()
51
void KviXmmsWidget::processExited(KviProcess *proc)
53
if( proc ) delete proc;
56
void KviXmmsWidget::mousePressEvent(QMouseEvent *e)
58
m_mousePressX = e->pos().x();
59
if( !libxmms_remote_is_running(0) ) {
60
KviProcess *proc = new KviProcess();
61
connect(proc, SIGNAL(processExited(KviProcess *)), this, SLOT(processExited(KviProcess *)));
62
if( !proc->run("xmms") )
65
if( m_mousePressX > 50 ) {
66
if( m_mousePressX < 66 ) {
67
libxmms_remote_playlist_prev(0);
69
} else if( m_mousePressX < 82 ) {
70
libxmms_remote_play(0);
72
} else if( m_mousePressX < 98 ) {
73
libxmms_remote_pause(0);
74
} else if( m_mousePressX < 114 ) {
75
libxmms_remote_stop(0);
76
} else if( m_mousePressX < 130 ) {
77
libxmms_remote_playlist_next(0);
80
libxmms_remote_eject(0);
83
if( libxmms_remote_is_playing(0) )
86
kvirc_plugin_statusbar_message(m_pFrm, "[XMMS]: stopped", 5000);
91
void KviXmmsWidget::sayWhatIsPlayed()
93
const char *song = libxmms_remote_get_playlist_title(0, libxmms_remote_get_playlist_pos(0));
94
KviStr tmp(KviStr::Format, "[XMMS]: playing \"%s\"", song);
95
kvirc_plugin_statusbar_message(m_pFrm, tmp.ptr(), 5000);
98
void KviXmmsWidget::mouseReleaseEvent(QMouseEvent *e)
104
void KviXmmsWidget::paintEvent(QPaintEvent *)
106
m_bIsPlaying = libxmms_remote_is_playing(0);
107
m_bIsRunning = libxmms_remote_is_running(0);
108
m_iPlaylistPos = libxmms_remote_get_playlist_pos(0);
109
m_iPlaylistLen = libxmms_remote_get_playlist_length(0);
112
p.drawPixmap(0, 0, *g_pXmmsLogo, 0, 0, 50, 16);
113
QColor clr(140, 120, 255);
116
QFont f = KviConfig::getFixedFont();
121
KviStr tmp(KviStr::Format, "%d of %d", m_iPlaylistPos + 1, m_iPlaylistLen);
122
p.drawText(1, 1, 48, 14, AlignCenter, tmp.ptr());
125
KviStr tmp(KviStr::Format, "0 of %d", m_iPlaylistLen);
126
p.drawText(1, 1, 48, 14, AlignCenter, tmp.ptr());
128
p.drawText(1, 1, 48, 14, AlignCenter, "---");
131
p.drawPixmap(50, 0, ((m_mousePressX >= 50) && (m_mousePressX < 66)) ?
132
*g_pXmmsButtonsPressed : *g_pXmmsButtonsNormal, 0, 0, 16, 16);
134
p.drawPixmap(66, 0, ((m_mousePressX >= 66) && (m_mousePressX < 82)) ?
135
*g_pXmmsButtonsPressed : (m_bIsPlaying ? *g_pXmmsButtonsActive : *g_pXmmsButtonsNormal), 16, 0, 16, 16);
137
p.drawPixmap(82, 0, ((m_mousePressX >= 82) && (m_mousePressX < 98)) ?
138
*g_pXmmsButtonsPressed : (libxmms_remote_is_paused(0) ? *g_pXmmsButtonsActive : *g_pXmmsButtonsNormal), 32, 0, 16, 16);
140
p.drawPixmap(98, 0, ((m_mousePressX >= 98) && (m_mousePressX < 114)) ?
141
*g_pXmmsButtonsPressed : ((m_bIsPlaying || (!m_bIsRunning)) ? *g_pXmmsButtonsNormal : *g_pXmmsButtonsActive), 48, 0, 16, 16);
143
p.drawPixmap(114, 0, ((m_mousePressX >= 114) && (m_mousePressX < 130)) ?
144
*g_pXmmsButtonsPressed : *g_pXmmsButtonsNormal, 64, 0, 16, 16);
146
p.drawPixmap(130, 0, ((m_mousePressX >= 130) && (m_mousePressX < 146)) ?
147
*g_pXmmsButtonsPressed : *g_pXmmsButtonsNormal, 80, 0, 16, 16);
150
void KviXmmsWidget::timerEvent(QTimerEvent *e)
152
if( e->timerId() == m_timer ) {
153
if( m_bIsRunning != libxmms_remote_is_running(0) ) repaint();
154
else if( m_bIsPlaying != libxmms_remote_is_playing(0) ) repaint();
155
else if( m_iPlaylistPos != libxmms_remote_get_playlist_pos(0) ) repaint();
156
else if( m_iPlaylistLen != libxmms_remote_get_playlist_length(0) ) repaint();
158
KviDockableWidget::timerEvent(e);
161
#include "m_kvi_xmms_widget.moc"