8
#include <kstdaction.h>
10
#include <kpopupmenu.h>
14
#include <kfiledialog.h>
20
#include <knotifyclient.h>
23
#include "equalizer.h"
24
#include <qdragobject.h>
27
#include <noatunstdaction.h>
31
class KJToolTip : public QToolTip
34
KJToolTip(KJLoader *parent)
35
: QToolTip(parent), mParent(parent)
39
virtual void maybeTip(const QPoint &p)
41
QList<KJWidget> things=mParent->widgetsAt(p);
42
for (KJWidget *i=things.first(); i!=0; i=things.next())
44
QString string=i->tip();
47
tip(i->rect(), string);
58
static int grayRgb(QRgb r)
60
return qGray(qRed(r), qGreen(r), qBlue(r));
63
static int isGray(QRgb r)
65
return (qRed(r)==qGreen(r)) &&
66
(qRed(r) == qBlue(r));
69
KJLoader *KJLoader::kjofol=0;
72
: QWidget(0,"KJLoader", WType_TopLevel | WStyle_NoBorder |WRepaintNoErase),
73
UserInterface(), moving(false), mClickedIn(0), mText(0), mNumbers(0)
77
mTooltips=new KJToolTip(this);
80
subwidgets.setAutoDelete(true);
82
KConfig *config=KGlobal::config();
83
config->setGroup("KJofol-Skins");
84
QString skin=config->readEntry("SkinResource", locate("data", "noatun/kjskins/kjofol/kjofol.rc"));
85
if (QFile(skin).exists())
91
KNotifyClient::event("warning",
92
i18n("There was trouble loading skin %1. Please select another skin file.").arg(skin));
96
setIcon(BarIcon("noatun"));
99
mHelpMenu =new KHelpMenu(this, kapp->aboutData());
100
connect( napp->player(), SIGNAL(timeout()), this, SLOT(timeUpdate()));
101
connect( napp->player(), SIGNAL(newSong()), this, SLOT(newSong()));
102
connect( napp->player(), SIGNAL(hideYourself()), this, SLOT(hide()) );
103
connect( napp->player(), SIGNAL(showYourself()), this, SLOT(show()) );
106
QApplication::restoreOverrideCursor();
110
QList<KJWidget> KJLoader::widgetsAt(const QPoint &pt) const
112
QList<KJWidget> things;
113
for (QListIterator<KJWidget> i(subwidgets); i.current(); ++i)
114
if ((*i)->rect().contains(pt))
120
void KJLoader::removeChild(KJWidget *c)
122
if (mClickedIn==c) mClickedIn=0;
123
if (subwidgets.findRef(c) != -1)
127
void KJLoader::addChild(KJWidget *c)
129
subwidgets.append(c);
132
// GAMMA CORRECTION SUCKS!!! ROT IN HELL QIMAGEIO!!!
134
// just like gamma correction, this function is a stupid hack
135
bool KJLoader::cleanSkin(const QString &dir)
137
// try to guess the current filetype:
143
QStringList files=d.entryList();
144
if (files.grep("png", false).count())
147
if (files.grep("bmp", false).count())
149
if (files.grep("jpeg", false).count())
151
if (files.grep("jpg", false).count())
154
if (::access(dir.latin1(), W_OK)!=0) return false;
156
QString command="/bin/sh "+::locate("exe", "noatun_kjofol_fixskin.sh");
157
command+=" '"+dir+"' "+ext;
158
::system(command.latin1());
162
QString KJLoader::guessRcFile(const QString &dir)
165
if (path[path.length()-1]=='/')
166
path=path.left(path.length()-1);
168
QString tests=path+"/";
169
QString possible=path.mid(path.findRev("/")+1);
170
tests+=possible+".rc";
171
tests=filenameNoCase(tests);
175
QDir d(path, "*.rc");
177
if (d.count()) return path+"/"+d[0];
182
void KJLoader::loadSkin(const QString &file)
184
if (file==mCurrentSkin) return;
188
if (!cleanSkin(file.left(file.findRev("/"))))
190
KNotifyClient::event("warning",
191
i18n("There was trouble loading skin %1. Please select another skin file.").arg(file));
196
Parser::open(filenameNoCase(file));
199
mText = new KJFont("Font", this);
200
mNumbers = new KJFont("TimeFont", this);
202
subwidgets.append(new Background(this));
204
if (exist("VolumeControlButton"))
205
subwidgets.append(new KJVolumeBMP(item("VolumeControlButton"), this));
206
if (exist("FilenameWindow"))
207
subwidgets.append(new KJFilename(item("FilenameWindow"), this));
208
if (exist("MP3TimeWindow"))
209
subwidgets.append(new KJTime(item("MP3TimeWindow"), this));
210
if (exist("AnalyzerWindow"))
211
subwidgets.append(new KJVis(item("AnalyzerWindow"), this));
212
QTimer::singleShot(0, this, SLOT(loadSeeker()));
213
// subwidgets.append(new KJScope(item("AnalyzerWindow"), this));
214
// subwidgets.append(new KJEqualizer(item("EqualizerWindow"), this));
216
// all the regular buttons
217
for (QDictIterator<QStringList> i(*this); i.current(); ++i)
219
QString d=i.currentKey();
220
if(d.contains("Button") && (*i).count()==7)
221
subwidgets.append(new KJButton(*i, this));
227
// if (napp->player()->isPlaying())
231
void KJLoader::loadSeeker()
233
subwidgets.append(new KJSeeker(item("SeekRegion"), this));
236
void KJLoader::unloadSkin()
243
void KJLoader::minimize()
245
// setWFlags(WType_TopLevel);
249
void KJLoader::closeEvent(QCloseEvent*)
254
void KJLoader::dragEnterEvent(QDragEnterEvent *event)
256
// accept uri drops only
257
event->accept(QUriDrag::canDecode(event));
260
void KJLoader::dropEvent(QDropEvent *event)
263
if (QUriDrag::decode(event, uri))
265
for (char *file=uri.first(); file != 0; file=uri.next() )
266
napp->player()->openFile(KURL(file), false);
270
void KJLoader::wheelEvent(QWheelEvent *e)
272
int delta=e->delta();
273
napp->player()->setVolume(napp->player()->volume()+(delta/60));
276
KJLoader::~KJLoader()
282
void KJLoader::paintEvent(QPaintEvent *e)
285
for (KJWidget* i=subwidgets.first(); i!=0; i=subwidgets.next())
286
if (i->rect().intersects(e->rect()))
287
i->paint(&p, e->rect().intersect(i->rect()));
288
// QWidget::paintEvent(e);
291
void KJLoader::mouseMoveEvent(QMouseEvent *e)
294
move(QCursor::pos()-mMousePoint);
295
QWidget::mouseMoveEvent(e);
297
if (!moving && mClickedIn && subwidgets.findRef(mClickedIn)!=-1)
298
mClickedIn->mouseMove(e->pos()-mClickedIn->rect().topLeft(),
299
mClickedIn->rect().contains(
300
mapFromGlobal(QCursor::pos())));
303
void KJLoader::mousePressEvent(QMouseEvent *e)
305
QWidget::mousePressEvent(e);
309
if (e->button()==RightButton)
310
NoatunStdAction::ContextMenu::showContextMenu();
314
mMousePoint=mapFromGlobal(QCursor::pos());
315
// try to find a KJWidget that is here
316
for (KJWidget* i=subwidgets.first(); i!=0; i=subwidgets.next())
317
if (i->rect().contains(mMousePoint))
319
if (i->mousePress(mMousePoint-i->rect().topLeft()))
326
// can't find it, so move the window
331
void KJLoader::mouseReleaseEvent(QMouseEvent *e)
333
QWidget::mouseReleaseEvent(e);
335
if (!moving && mClickedIn && subwidgets.findRef(mClickedIn)!=-1)
337
mClickedIn->mouseRelease(mapFromGlobal(QCursor::pos())-
338
mClickedIn->rect().topLeft(),
339
mClickedIn->rect().contains(
340
mapFromGlobal(QCursor::pos())));
347
void KJLoader::timeUpdate()
349
for (KJWidget* i=subwidgets.first(); i!=0; i=subwidgets.next())
350
i->timeUpdate(napp->player()->getTime()/1000); // pass seconds to all Widgets
353
void KJLoader::newSong()
355
if (!napp->player()->current()) return;
356
for (KJWidget* i=subwidgets.first(); i!=0; i=subwidgets.next())
361
/*******************************************
363
*******************************************/
365
KJWidget::KJWidget(KJLoader *p) : mParent(p)
369
// only works little endian
370
inline void setPixel1BPP(QImage &image, int x, int y, bool value)
373
*(image.scanLine(y) + (x >> 3)) |= 1 << (x & 7);
375
*(image.scanLine(y) + (x >> 3)) &= ~(1 << (x & 7));
379
QBitmap KJWidget::getMask(const QImage &_rect, register QRgb transparent)
382
QImage result(_rect.width(), _rect.height(), 1,2, QImage::LittleEndian);
383
result.setColor(0, qRgb(0,0,0));
384
result.setColor(1, qRgb(255,255,255));
386
for (int height=0;height<_rect.height(); height++)
388
for (int width=0; width<_rect.width(); width++)
389
setPixel1BPP(result, width, height,
390
_rect.pixel(width, height)!=transparent);
394
bm.convertFromImage(result);
398
register QRgb magenta=QColor(255,0,255).rgb();
399
QImage rect=_rect.convertDepth(32);
400
register int width=rect.width();
401
register int height=rect.height();
403
QImage result(width, height, 1,2, QImage::LittleEndian);
404
result.setColor(0, qRgb(0,0,0));
405
result.setColor(1, qRgb(255,255,255));
407
for (register int cheight=height; cheight!=0; --cheight)
409
register QRgb *srcline=(QRgb*)rect.scanLine(cheight);
410
register QRgb *resline=(QRgb*)result.scanLine(cheight);
411
for (register int cwidth=width; cwidth!=0; --cwidth)
412
setPixel1BPP(result, cwidth, cheight,srcline[cwidth]==magenta);
416
bm.convertFromImage(result);
421
void KJWidget::repaint(bool me, const QRect &r, bool clear)
423
QPainter p(parent());
425
paint(&p, r.isValid() ? r : rect());
427
parent()->repaint(r.isValid() ? r : rect(), clear);
430
QString KJWidget::backgroundPressed(const QString &bmp)
432
return parser()["BackgroundImagePressed"+QString::number(bmp.mid(3).toInt())][1];
435
/*******************************************
437
*******************************************/
439
Background::Background(KJLoader *parent)
443
mBackground=parent->pixmap(parser()["BackgroundImage"][1]);
444
ibackground=parent->image(parser()["BackgroundImage"][1]);
445
parent->setMask(getMask(ibackground));
446
parent->setFixedSize(QSize(mBackground.width(), mBackground.height()));
448
setRect(0,0,parent->width(),parent->height());
451
void Background::paint(QPainter *painter, const QRect &rect)
453
QPaintDevice *dev=painter->device();
454
bitBlt(dev, rect.topLeft(), &mBackground, rect, Qt::CopyROP);
455
// bitBlt(dev, rect.topLeft(), parent()->pixmap("SeekImage", 1), rect, Qt::CopyROP);
458
/*******************************************
460
*******************************************/
462
KJButton::KJButton(const QStringList &i, KJLoader *parent)
463
: KJWidget(parent), mTitle(i[0]), mShowPressed(false)
465
mPushedPixmap=(i.count()==7);
475
mPressed=parent->pixmap(backgroundPressed(i[6]));
478
QString KJButton::tip()
481
if (mTitle=="CloseButton")
483
else if (mTitle=="MinimizeButton")
484
str=i18n("Minimize");
485
else if (mTitle=="AboutButton")
487
else if (mTitle=="StopButton")
489
else if (mTitle=="PlayButton")
491
else if (mTitle=="PauseButton")
493
else if (mTitle=="OpenFileButton")
495
else if (mTitle=="PlaylistButton")
496
str=i18n("Playlist");
497
else if (mTitle=="RepeatButton")
499
else if (mTitle=="EqualizerButton")
501
else if (mTitle=="NextSongButton")
503
else if (mTitle=="PreviousSongButton")
504
str=i18n("Previous");
505
else if (mTitle=="PreferencesButton")
506
str=i18n("Preferences");
510
void KJButton::paint(QPainter *, const QRect &)
513
bitBlt(parent(), rect().topLeft(), &mPressed, rect(), Qt::CopyROP);
516
bool KJButton::mousePress(const QPoint &)
518
bitBlt(parent(), rect().topLeft(), &mPressed, rect(), Qt::CopyROP);
522
void KJButton::showPressed(bool b)
528
void KJButton::mouseRelease(const QPoint &, bool in)
534
// now, find what widget I am and do the proper action
535
if (mTitle=="CloseButton")
537
else if (mTitle=="MinimizeButton")
538
parent()->minimize();
539
else if (mTitle=="AboutButton")
540
parent()->helpMenu()->aboutApplication();
541
else if (mTitle=="StopButton")
542
napp->player()->stop();
543
else if (mTitle=="PlayButton")
544
napp->player()->play();
545
else if (mTitle=="PauseButton")
546
napp->player()->playpause();
547
else if (mTitle=="OpenFileButton")
549
KURL file(KFileDialog::getOpenURL(0, napp->mimeTypes(), parent(),
550
i18n("Select a File to Play")));
551
if (!file.isMalformed())
552
napp->player()->openFile(file);
554
else if (mTitle=="PlaylistButton")
555
napp->player()->toggleListView();
556
else if (mTitle=="RepeatButton")
558
napp->player()->loop(napp->player()->loopStyle()==Player::None
559
? Player::Song : Player::None);
560
showPressed(napp->player()->loopStyle());
562
else if (mTitle=="EqualizerButton")
564
else if (mTitle=="NextSongButton")
565
napp->player()->fastForward();
566
else if (mTitle=="PreviousSongButton")
567
napp->player()->back();
568
else if (mTitle=="PreferencesButton")
573
KJSeeker::KJSeeker(const QStringList &i, KJLoader *l) : KJWidget(l), g(0)
575
mActive=parent()->image(backgroundPressed("BMP1"));
576
mScale=parent()->image(parser()["SeekImage"][1]);
577
QImage pixmapNoPress=parent()->image(parser()["BackgroundImage"][1]);
585
QImage transmask(xs, ys, 1, 2, QImage::LittleEndian);
587
transmask.setColor(0, qRgb(0,0,0));
588
transmask.setColor(1, qRgb(255,255,255));
591
QImage *barmodeImages[256];
592
memset(barmodeImages, 0, 256*sizeof(QImage*));
593
memset(barmode, 0, 256*sizeof(QPixmap*));
594
// Now do the pixel f�king
595
for (int iy=y;iy<y+ys; iy++)
596
for (int ix=x;ix<x+xs; ix++)
598
QRgb checkmScale=mScale.pixel(ix, iy);
600
if (!isGray(checkmScale))
602
setPixel1BPP(transmask, ix-x, iy-y, 0);
605
setPixel1BPP(transmask, ix-x, iy-y, 1);
608
int level=grayRgb(checkmScale)+1;
609
if (level>255) level=255;
610
// allocate the pixmap of the level proper
611
// copy the color to the surface proper
612
QRgb activeColor=mActive.pixel(ix,iy);
613
QRgb inactiveColor=pixmapNoPress.pixel(ix,iy);
614
// set this pixel and everything before it
615
for(int i=0; i<level; i++)
617
if (!barmodeImages[i])
618
barmodeImages[i]=new QImage(xs,ys, 32);
619
QRgb *l=(QRgb*)barmodeImages[i]->scanLine(iy-y);
620
l[ix-x]=inactiveColor;
625
if (!barmodeImages[level])
626
barmodeImages[level]=new QImage(xs,ys, 32);
627
QRgb *l=(QRgb*)barmodeImages[level]->scanLine(iy-y);
631
napp->processEvents();
634
for (int i=1; i<256; i++)
636
if (!barmodeImages[i])
638
barmode[i]=new QPixmap(xs,ys);
639
barmode[i]->convertFromImage(*barmodeImages[i]);
640
delete barmodeImages[i];
641
napp->processEvents();
643
// create the blank one
644
barmode[0]=new QPixmap(xs, ys);
645
QPixmap px=parent()->pixmap(parser()["BackgroundImage"][1]);
646
bitBlt(barmode[0], 0, 0, &px, x, y, xs, ys, Qt::CopyROP);
648
px.convertFromImage(transmask);
652
KJSeeker::~KJSeeker()
654
for (int i=0; i<256; i++)
659
void KJSeeker::paint(QPainter *p, const QRect &)
662
barmode[g]->setMask(barModeMask);
663
bitBlt(p->device(), rect().topLeft().x(), rect().topLeft().y(), barmode[g], 0, 0, rect().width(), rect().height(), Qt::CopyROP);
666
bool KJSeeker::mousePress(const QPoint &pos)
668
return (isGray(mScale.pixel(rect().topLeft().x()+pos.x(), rect().topLeft().y()+pos.y())));
671
void KJSeeker::mouseRelease(const QPoint &pos, bool in)
673
QRgb color=mScale.pixel(rect().topLeft().x()+pos.x(),
674
rect().topLeft().y()+pos.y());
675
if (!isGray(color) || !in)
681
napp->player()->skipTo(g*napp->player()->getLength()/255);
686
void KJSeeker::timeUpdate(int sec)
688
int length = napp->player()->getLength() / 1000;
697
g = sec * 255 / length;
698
// fprintf(stderr,"sec: %d, len: %d, g: %d\n", sec, length, g);
699
QPainter p(parent());
703
void KJSeeker::closest()
705
int south=g, north=g;
706
bool southtried=false, northtried=false;
707
while (!barmode[south] && !barmode[north])
709
if (southtried && northtried) { g=0; return; }
712
if (north>255) {northtried=true; north=g;}
713
if (south<0) {southtried=true; south=g;}
717
else if (barmode[north])
721
KJVolumeBMP::KJVolumeBMP(const QStringList &i, KJLoader *p)
722
: KJWidget(p), mVolume(0)
731
mWidth=parser()["VolumeControlImageXSize"][1].toInt();
732
mCount=parser()["VolumeControlImageNb"][1].toInt()-1;
734
mImages=parent()->pixmap(parser()["VolumeControlImage"][1]);
735
mPos=parent()->image(parser()["VolumeControlImagePosition"][1]);
738
QString KJVolumeBMP::tip()
740
return i18n("Volume");
743
void KJVolumeBMP::paint(QPainter *p, const QRect &)
745
QRect from(mVolume*mCount/100*mWidth, 0, mWidth, mImages.height());
746
bitBlt(p->device(), rect().topLeft(), &mImages, from, Qt::CopyROP);
749
bool KJVolumeBMP::mousePress(const QPoint &pos)
751
QRgb color=mPos.pixel(rect().topLeft().x()+pos.x(),
752
rect().topLeft().y()+pos.y());
756
mVolume=grayRgb(color)*100/255;
757
napp->player()->setVolume(mVolume);
763
void KJVolumeBMP::mouseRelease(const QPoint &, bool)
766
void KJVolumeBMP::mouseMove(const QPoint &pos, bool in)
772
void KJVolumeBMP::timeUpdate(int)
774
mVolume=napp->player()->volume();
779
KJFont::KJFont(const QString &prefix, KJLoader *parent)
781
if (prefix=="TimeFont")
783
mString[0]="0123456789: ";
784
mString[1]=mString[2]=0;
789
mString[0]="abcdefghijklmnopqrstuvwxyz\"@";
790
mString[1]="0123456789;_:()-'!_+\\/[]*&%.=$#";
791
mString[2]="���?*, ";
795
mText=parent->pixmap(parent->item(prefix+"Image")[1]);
796
mWidth=parent->item(prefix+"Size")[1].toInt();
797
mHeight=parent->item(prefix+"Size")[2].toInt();
798
mSpacing=parent->item(prefix+"Spacing")[1].toInt();
799
mTransparent=(bool)parent->item(prefix+"Transparent")[1].toInt();
802
QPixmap KJFont::draw(const QCString &str, int wide, const QPoint &pos) const
805
QCString string=str.lower();
807
(string.length()*mWidth+string.length()*mSpacing > (unsigned int)wide
808
? string.length()*mWidth+string.length()*mSpacing : wide),
811
for (unsigned int len=0; len<string.length(); len++)
814
drawCharacter(®ion, to, c);
816
to+=QPoint(mWidth, 0);
817
// draw according to "spacing"
818
QPoint p=charSource(' ');
819
bitBlt(®ion, to, &mText, QRect(p.x(), p.y(), mSpacing, mHeight), Qt::CopyROP);
820
to+=QPoint(mSpacing, 0);
822
for (; to.x()<=wide; to+=QPoint(mWidth, 0))
823
drawCharacter(®ion, to, ' ');
828
void KJFont::drawCharacter(QPixmap *dev, const QPoint &to, char c) const
830
QPoint src=charSource(c);
836
bitBlt(dev, to, &mText, QRect(x,y,xs,ys), Qt::CopyROP);
842
QPoint KJFont::charSource(char c) const
844
for (int i=0; i<3; i++)
846
const char *pos=strchr(mString[i], c);
849
return QPoint(mWidth*((int)(pos-mString[i])), mHeight*i);
852
return charSource(mNullChar);
855
KJFilename::KJFilename(const QStringList &l, KJLoader *p)
856
: QObject(0), KJWidget(p)
860
int xs=l[3].toInt()-x;
861
int ys=l[4].toInt()-y;
864
mDistance=2; // how far it moves per cycle
866
prepareString(i18n("No File").latin1());
870
void KJFilename::paint(QPainter *p, const QRect &)
872
bitBlt(p->device(), rect().topLeft(), &mView,
873
QRect(0,0, rect().width(), rect().height()), Qt::CopyROP);
876
void KJFilename::timerEvent(QTimerEvent *)
878
int height=mView.height();
879
int width=mView.width();
880
QPixmap cycle(1, height);
881
bitBlt(&cycle, 0,0, &mView, 0,0, 1, height, Qt::CopyROP);
882
bitBlt(&mView, 0,0, &mView, 1, 0, width-1, height, Qt::CopyROP);
883
bitBlt(&mView, width-1, 0, &cycle, 0,0, 1, height, Qt::CopyROP);
887
bool KJFilename::mousePress(const QPoint &)
892
void KJFilename::prepareString(const QCString &str)
895
mView=textFont().draw(str, rect().width());
899
void KJFilename::newFile()
901
QCString timestring=napp->player()->lengthString().latin1();
902
timestring=timestring.mid(timestring.find('/')+1);
903
prepareString(QCString(napp->player()->current()->title().latin1())
904
+ " (" + timestring + ") ");
907
KJTime::KJTime(const QStringList &l, KJLoader *p)
912
int xs=l[3].toInt()-x;
913
int ys=l[4].toInt()-y;
916
prepareString("00:00");
919
void KJTime::paint(QPainter *p, const QRect &)
921
bitBlt(p->device(), rect().topLeft(), &mTime,
922
QRect(0,0, rect().width(), rect().height()), Qt::CopyROP);
925
bool KJTime::mousePress(const QPoint &)
930
void KJTime::timeUpdate(int)
932
if (!napp->player()->current())
934
QCString time=napp->player()->lengthString().latin1();
935
time=time.left(time.find('/'));
940
void KJTime::prepareString(const QCString &str)
942
if (str==mCurrentStr) return;
943
mTime=timeFont().draw(str, rect().width());
948
void KJVisScope::swapScope(Visuals newOne)
950
QStringList line=parent()->item("AnalyzerWindow");
951
KJLoader *p=parent();
952
p->removeChild(this);
959
w=new KJNullScope(line, p);
962
w=new KJVis(line, p);
965
w=new KJScope(line, p);
971
KJNullScope::KJNullScope(const QStringList &l, KJLoader *parent)
976
int xs=l[3].toInt()-x;
977
int ys=l[4].toInt()-y;
981
bool KJNullScope::mousePress(const QPoint &)
983
parent()->repaint(rect(), false);
989
KJVis::KJVis(const QStringList &l, KJLoader *parent)
990
: KJVisScope(parent), MonoFFTScope(100)
994
int xs=l[3].toInt()-x;
995
int ys=l[4].toInt()-y;
996
QStringList &col=parser()["AnalyzerColor"];
997
mColor.setRgb(col[1].toInt(), col[2].toInt(), col[3].toInt());
1006
// center the difference
1015
void KJVis::scopeEvent(float *d, int size)
1017
QPainter p(parent());
1020
int height=rect().height();
1023
float fheight=(float)height;
1024
parent()->repaint(rect(), false);
1025
for ( ; start<end; ++start)
1029
float n=(*start)+1.0;
1033
if (amp>height) amp=height;
1034
p.fillRect(x, y+(height-amp), mMultiples, amp, mColor);
1040
bool KJVis::mousePress(const QPoint &)
1042
parent()->repaint(rect(), false);
1048
KJScope::KJScope(const QStringList &l, KJLoader *parent)
1049
: KJVisScope(parent), MonoScope(100)
1053
int xs=mWidth=l[3].toInt()-x;
1054
int ys=mHeight=l[4].toInt()-y;
1055
QStringList &col=parser()["AnalyzerColor"];
1056
mColor.setRgb(col[1].toInt(), col[2].toInt(), col[3].toInt());
1057
setRect(x,y, xs, ys);
1060
// set the samplewidth to the largest integer divisible by mWidth
1061
setSamples(mWidth-1);
1064
void KJScope::scopeEvent(float *d, int size)
1066
QPainter p(parent());
1069
parent()->repaint(rect(), false);
1072
int heightHalf=mHeight/2;
1080
n *= heightHalf*1.5;
1082
if (amp>heightHalf) amp=heightHalf;
1083
else if (amp<-heightHalf) amp=-heightHalf;
1085
p.drawLine(x, y, x, y+amp);
1092
bool KJScope::mousePress(const QPoint &)
1094
parent()->repaint(rect(), false);
1099
KJEqualizer::KJEqualizer(const QStringList &l, KJLoader *parent)
1100
: QObject(0), KJWidget(parent)
1104
int xs=l[3].toInt()-x;
1105
int ys=l[4].toInt()-y;
1108
mBars=parent->pixmap(parser()["EqualizerBmp"][3]);
1110
mBands=l[6].toInt();
1111
mXSpace=l[7].toInt();
1112
mBuffer.resize(rect().size());
1114
mXSize=parser()["EqualizerBmp"][1].toInt();
1115
mNumber=parser()["EqualizerBmp"][2].toInt();
1119
int KJEqualizer::barNum(const QPoint &pos) const
1123
return napp->equalizer()->bandCount()*x / mBands;
1126
int KJEqualizer::level(const QPoint &pos) const
1129
y+=rect().height()/2;
1130
y*=200/(rect().height()/2);
1134
void KJEqualizer::paint(QPainter *, const QRect &)
1139
void KJEqualizer::updateBuffer()
1141
QPainter paint(&mBuffer);
1142
for (int band=0; band< mBands; band++)
1150
void KJEqualizer::mouseMove(const QPoint &pos, bool in)
1154
napp->equalizer()->band(barNum(pos))->setLevel(level(pos));
1157
bool KJEqualizer::mousePress(const QPoint &p)
1164
#include "kjloader.moc"