1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
|
/*
* noatun.cpp
*
* Copyright (C) 1999 Charles Samuels <[email protected]>
*/
#include "userinterface.h"
#include <noatun/playlist.h>
#include <noatun/stdaction.h>
#include <noatun/app.h>
#include <noatun/player.h>
#include <noatun/controls.h>
#include <noatun/effects.h>
#include <tqpushbutton.h>
#include <tqdragobject.h>
#include <tqlayout.h>
#include <tqtooltip.h>
#include <tqobjectlist.h>
#include <tqobjectdict.h>
#include <kpopupmenu.h>
#include <kstatusbar.h>
#include <kglobal.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kurldrag.h>
#include <kfiledialog.h>
#include <kconfig.h>
MilkChocolate::MilkChocolate() : TQWidget(0,"NoatunUI"), UserInterface()
{
setAcceptDrops(true);
static const int buttonSize=32;
{ // The buttons
mBack=new TQPushButton(this);
mBack->setFixedSize(buttonSize,buttonSize);
mBack->setPixmap(BarIcon("noatunback"));
connect(mBack, TQT_SIGNAL(clicked()), napp->player(), TQT_SLOT(back()));
TQToolTip::add(mBack,i18n("Back"));
mStop=new TQPushButton(this);
mStop->setFixedSize(buttonSize,buttonSize);
mStop->setPixmap(BarIcon("noatunstop"));
connect(mStop, TQT_SIGNAL(clicked()), napp->player(), TQT_SLOT(stop()));
TQToolTip::add(mStop, i18n("Stop"));
mPlay=new TQPushButton(this);
mPlay->setToggleButton(true);
mPlay->setFixedSize(buttonSize,buttonSize);
mPlay->setPixmap(BarIcon("noatunplay"));
connect(mPlay, TQT_SIGNAL(clicked()), napp->player(), TQT_SLOT(playpause()));
TQToolTip::add(mPlay, i18n("Play"));
mForward=new TQPushButton(this);
mForward->setFixedSize(buttonSize,buttonSize);
mForward->setPixmap(BarIcon("noatunforward"));
connect(mForward, TQT_SIGNAL(clicked()), napp->player(), TQT_SLOT(forward()));
TQToolTip::add(mForward, i18n("Forward"));
mPlaylist=new TQPushButton(this);
mPlaylist->setToggleButton(true);
mPlaylist->setFixedSize(buttonSize,buttonSize);
mPlaylist->setPixmap(BarIcon("noatunplaylist"));
connect(mPlaylist, TQT_SIGNAL(clicked()), napp->player(), TQT_SLOT(toggleListView()));
TQToolTip::add(mPlaylist, i18n("Playlist"));
mLoop=new TQPushButton(this);
mLoop->setFixedSize(buttonSize,buttonSize);
mLoop->setPixmap(BarIcon("noatunloopnone"));
connect(mLoop, TQT_SIGNAL(clicked()), napp->player(), TQT_SLOT(loop()));
TQToolTip::add(mLoop, i18n("Change loop style"));
mPopup=new TQPushButton(this);
mPopup->setFixedSize(buttonSize,buttonSize);
mPopup->setPixmap(BarIcon("noatun"));
connect(mPopup, TQT_SIGNAL(clicked()), TQT_SLOT(popup()));
// TQToolTip::add(mRemoveCurrent, i18n("Remove current file from playlist"));
}
mVolume=new L33tSlider(0,100,10,0,Qt::Horizontal, this);
mVolume->setValue(napp->player()->volume());
mSeeker=new L33tSlider(0,1000,10,0,Qt::Horizontal, this);
mStatusBar=new KStatusBar(this);
TQGridLayout *l=new TQGridLayout(this);
l->addWidget(mBack,0,0);
l->addWidget(mStop,0,1);
l->addWidget(mPlay,0,2);
l->addWidget(mForward,0,3);
l->addWidget(mPlaylist,0,4, TQt::AlignLeft);
l->addWidget(mLoop,0,5);
l->addWidget(mPopup,0,6);
l->addColSpacing(4, buttonSize+8);
l->addMultiCellWidget(mVolume,1,1,0,6);
l->addMultiCellWidget(mSeeker,2,2,0,6);
l->addMultiCellWidget(mStatusBar,3,3,0,6);
statusBar()->message(i18n("No File Loaded"));
statusBar()->insertItem("--:--/--:--", 1, 0, true);
connect(napp, TQT_SIGNAL(hideYourself()), this, TQT_SLOT(hide()) );
connect(napp, TQT_SIGNAL(showYourself()), this, TQT_SLOT(show()) );
connect(napp->player(), TQT_SIGNAL(playing()), this, TQT_SLOT(slotPlaying()));
connect(napp->player(), TQT_SIGNAL(stopped()), this, TQT_SLOT(slotStopped()));
connect(napp->player(), TQT_SIGNAL(paused()), this, TQT_SLOT(slotPaused()));
napp->player()->handleButtons();
connect(napp->player(), TQT_SIGNAL(timeout()), this, TQT_SLOT(slotTimeout()));
connect(napp->player(), TQT_SIGNAL(loopTypeChange(int)), this, TQT_SLOT(changeLoopType(int)));
// if(seeker())
{
/* This skipToWrapper is needed to pass milliseconds to Player() as everybody
* below the GUI is based on milliseconds instead of some unprecise thingy
* like seconds or mille */
connect(seeker(), TQT_SIGNAL(userChanged(int)), this, TQT_SLOT(skipToWrapper(int)));
connect(this, TQT_SIGNAL(skipTo(int)), napp->player(), TQT_SLOT(skipTo(int)));
connect(seeker(), TQT_SIGNAL(sliderMoved(int)), TQT_SLOT(sliderMoved(int)));
}
connect(mVolume, TQT_SIGNAL(sliderMoved(int)), napp->player(), TQT_SLOT(setVolume(int)));
connect(mVolume, TQT_SIGNAL(userChanged(int)), napp->player(), TQT_SLOT(setVolume(int)));
connect(napp->player(), TQT_SIGNAL(playlistShown()), TQT_SLOT(playlistShown()));
connect(napp->player(), TQT_SIGNAL(playlistHidden()), TQT_SLOT(playlistHidden()));
// Event Filter for the RMB
for (TQPtrListIterator<TQObject> i(childrenListObject()); i.current(); ++i)
(*i)->installEventFilter(this);
setCaption("Noatun");
setIcon(BarIcon("noatun"));
show();
// What it is now, stay, stay.. roll over, good boy!
setFixedSize(tqminimumSize());
}
MilkChocolate::~MilkChocolate()
{
// If cfg dialog is still open, delete it so it saves it's position
// if(prefDlgExist)
// delete prefDlg;
}
void MilkChocolate::closeEvent(TQCloseEvent*)
{
unload();
}
void MilkChocolate::showEvent(TQShowEvent*e)
{
TQWidget::showEvent(e);
}
void MilkChocolate::dragEnterEvent(TQDragEnterEvent *event)
{
// accept uri drops only
event->accept(KURLDrag::canDecode(event));
}
void MilkChocolate::dropEvent(TQDropEvent *event)
{
KURL::List uri;
if (KURLDrag::decode(event, uri))
{
for (KURL::List::Iterator i = uri.begin(); i != uri.end(); ++i)
napp->player()->openFile(*i, false);
}
}
void MilkChocolate::mouseReleaseEvent(TQMouseEvent *e)
{
TQWidget::mouseReleaseEvent(e);
if (e->button()!=Qt::RightButton) return;
NoatunStdAction::ContextMenu::showContextMenu();
}
void MilkChocolate::changeStatusbar(const TQString& text, const TQString &text2)
{
if (!text2.isNull())
statusBar()->changeItem(text2, 1);
statusBar()->message(!text.isNull() ? text : napp->player()->current().title());
}
void MilkChocolate::changeCaption(const TQString& text)
{
setCaption(text);
}
void MilkChocolate::popup()
{
NoatunStdAction::ContextMenu::showContextMenu(
mapToGlobal(mPopup->tqgeometry().bottomLeft())
);
}
void MilkChocolate::slotPlaying()
{
// connect(twinmodule, TQT_SIGNAL(windowAdded(WId)), view, TQT_SLOT(attemptReparent(WId)));
changeStatusbar(napp->player()->current().title(), napp->player()->lengthString());
mPlay->setOn(true);
mStop->setEnabled(true);
mPlay->setPixmap(BarIcon("noatunpause"));
}
void MilkChocolate::slotStopped()
{
if (!napp->player()->current()) return;
changeStatusbar(i18n("No File Loaded"), napp->player()->lengthString());
mStop->setEnabled(false);
mPlay->setOn(false);
seeker()->setValue(0);
mPlay->setPixmap(BarIcon("noatunplay"));
}
void MilkChocolate::slotPaused()
{
mStop->setEnabled(true);
mPlay->setOn(false);
mPlay->setPixmap(BarIcon("noatunplay"));
}
void MilkChocolate::slotTimeout()
{
mVolume->setValue(napp->player()->volume());
if (!napp->player()->current()) return;
if (static_cast<L33tSlider*>(seeker())->currentlyPressed()) return;
if (seeker())
{
seeker()->setRange ( 0, (int)napp->player()->getLength()/1000 );
seeker()->setValue ( (int)napp->player()->getTime()/1000 );
}
changeStatusbar(0, napp->player()->lengthString());
}
void MilkChocolate::sliderMoved(int seconds)
{
if (napp->player()->current())
changeStatusbar(0, napp->player()->lengthString(seconds*1000));
}
void MilkChocolate::skipToWrapper(int second)
{
emit skipTo((long)(second*1000));
}
void MilkChocolate::changeLoopType(int t)
{
static const int time=2000;
switch (t)
{
case(Player::None):
statusBar()->message(i18n("No looping"), time);
mLoop->setPixmap(BarIcon("noatunloopnone"));
break;
case(Player::Song):
statusBar()->message(i18n("Song looping"), time);
mLoop->setPixmap(BarIcon("noatunloopsong"));
break;
case(Player::Playlist):
statusBar()->message(i18n("Playlist looping"), time);
mLoop->setPixmap(BarIcon("noatunloopplaylist"));
break;
case(Player::Random):
statusBar()->message(i18n("Random play"), time);
mLoop->setPixmap(BarIcon("noatunlooprandom"));
}
}
bool MilkChocolate::eventFilter(TQObject *o, TQEvent *e)
{
if ((e->type() == TQEvent::MouseButtonRelease)
&& ((TQT_TQMOUSEEVENT(e))->button()==Qt::RightButton))
{
mouseReleaseEvent(TQT_TQMOUSEEVENT(e));
return true;
}
if (e->type() == TQEvent::Wheel)
{
wheelEvent(TQT_TQWHEELEVENT(e));
return true;
}
return TQWidget::eventFilter(o, e);
}
void MilkChocolate::playlistShown()
{
mPlaylist->setOn(true);
}
void MilkChocolate::playlistHidden()
{
mPlaylist->setOn(false);
}
void MilkChocolate::wheelEvent(TQWheelEvent *e)
{
int delta=e->delta();
mVolume->setValue(mVolume->value()+(delta/120));
napp->player()->setVolume(mVolume->value()+(delta/120));
}
#include "userinterface.moc"
|