summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2005-03-21 10:31:06 (UTC)
committer llornkcor <llornkcor>2005-03-21 10:31:06 (UTC)
commit18825d8195f05d1a82affc0111f524371dbdeb5f (patch) (side-by-side diff)
treeaa807f10454b77496bb18a24569e12bf38acb7cf
parentda645ace9b556dd132ac998cd124fa1e062e0032 (diff)
downloadopie-18825d8195f05d1a82affc0111f524371dbdeb5f.zip
opie-18825d8195f05d1a82affc0111f524371dbdeb5f.tar.gz
opie-18825d8195f05d1a82affc0111f524371dbdeb5f.tar.bz2
fix
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opierec/vumeter.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/noncore/multimedia/opierec/vumeter.cpp b/noncore/multimedia/opierec/vumeter.cpp
index c28dbe4..6a3f7c2 100644
--- a/noncore/multimedia/opierec/vumeter.cpp
+++ b/noncore/multimedia/opierec/vumeter.cpp
@@ -1,158 +1,155 @@
//************************************************************
//=======-VUMeter
///// copyright : (C) 1999 by Martin Lorenz
////// email : lorenz@ch.tum.de
+// also copyright 2005 lpotter@trolltech.com
#include "vumeter.h"
#include "qtrec.h"
#include <qpe/config.h>
#include <qtimer.h>
#include <qdrawutl.h>
-#include <opie2/odebug.h>
-using namespace Opie::Core;
-
#include <math.h>
VUMeter::VUMeter(QWidget *parent, const char *name, const int tr)
: QWidget( parent, name )
{
- int tracks = tr;
+ tracks = tr;
int i;
qWarning("initialize peakvalues");
for(i = 0; i < tracks + 2; i++) {
peak[i] = hold[i] = 32768;
holdTime[i] = 20;
}
+ colorScheme = 0;
+
readConf();
//rainbow effect
if( colorScheme == 0 ) {
for( i = 0; i < para.leds; i++) color[i] = green;
color[0] = color[1] = red;
color[2] = color[3] = color[4] = color[5] = yellow;
} else {
int j = para.leds - 4;
for( i = 0; i < para.leds; i++) {
int i16 = (j);
color[i] = QColor(( 15 - i16) * 16, 255, 255, QColor::Hsv);
-// owarn << color[i].name() << oendl;
j--;
}
}
buffer = new QPixmap();
setBackgroundMode(NoBackground);
vuTimer = new QTimer(this,"vu timer");
connect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot()));
}
VUMeter::~VUMeter(){
- writeConf();
+// writeConf();
}
void VUMeter::update(){
-// qWarning("vumeter update");
vuTimer->start(para.update, FALSE);
if (para.onOff) {
disconnect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot()));
connect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot()));
} else {
disconnect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot()));
}
resize();
}
void VUMeter::slotOn() {
connect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot()));
para.onOff=true;
}
void VUMeter::slotOff() {
disconnect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot()));
para.onOff=false;
}
void VUMeter::slotProps() {
- qDebug("VU-Dialog");
}
void VUMeter::paintEvent(QPaintEvent* e) {
Q_UNUSED(e);
bitBlt(this, 0, 0, buffer);
}
void VUMeter::mousePressEvent(QMouseEvent* e) {
Q_UNUSED(e);
}
void VUMeter::resizeEvent(QResizeEvent* event) {
buffer->resize(event->size());
resize();
}
void VUMeter::resize() {
- qWarning("resize VUMeter painting");
+// qWarning("resize VUMeter painting");
if(buffer == 0)
- qDebug("Dude NULL pixmap buffer!");
+ qWarning("Dude NULL pixmap buffer!");
buffer->fill(black);
x = width() - 7; y = height() - 12;
dx = x / (tracks + 2); dy = y / (para.leds + 2); // size of one LED + black frame
ox = dx / 6 + 4 + (x - (tracks + 2) * dx) / 2;
oy = dy / 5 + 5 + (y - (para.leds + 2) * dy) / 2; //offsets
sx = (4 *dx) / 6; sy = (4 * dy) / 5; //size of one LED
QPainter painter; QString str; QFont font;
int i, textOffset=0;
if( painter.begin(buffer) ==FALSE)
qWarning("Painting pixmap did not work!");
else {
painter.setPen(green);
qDrawShadePanel ( &painter, 0,0, width(),height(), colorGroup(), TRUE, 2, 0);
if (2 * dy - 2 == 10) textOffset = 1;
font = painter.font(); font.setPointSize( 2 * dy - 2);
painter.setFont(font);
+
for(i = 0; i < tracks + 2; i++) {
painter.setPen(green); painter.setBrush(green);
str.sprintf("%d",i+1);
if (i == tracks) str.sprintf("L");
if (i == tracks + 1) str.sprintf("R");
painter.drawRect(ox + dx * i, oy + dy * (para.leds) - 2, sx, 2 * dy - 1);
painter.setPen(black);
painter.drawText(textOffset + ox + dx * i, oy + dy * (para.leds) - 2, sx, 2 * dy, AlignCenter, str);
}
+
painter.end();
paint();
}
}
void VUMeter::timeSlot() {
int i;
-// getting stuck here
-// qDebug("calling paint() from timeSlot()\n");
paint();
for(i = 0; i < tracks + 2; i++) {
peak[i] /= para.resoFactor;
}
}
void VUMeter::paint() {
int i, k;
float p, h ;
QPainter painter;
painter.begin(buffer);
int c;
for(i = 0; i < tracks + 2; i++) {
p = peak[i]; h = hold[i];
if (p >= 32767) p = 32768;
@@ -167,34 +164,32 @@ void VUMeter::paint() {
if (h >= 32768) { //LED-Frame on
painter.setPen(color[c]);
} else { //LED off
painter.setPen(color[c].dark(300));
}
painter.drawRect(ox + dx * i, oy + dy * c, sx, sy);
p *= para.resoFactor; h *= para.resoFactor;
}
if ( --holdTime[i] <= 0) hold[i] = peak[i];
}
painter.end();
bitBlt(this, 0, 0, buffer);
}
void VUMeter::setPeak(int a[]) {
int i;
-// qDebug("set peak int");
-// cerr<<"setting peak\n";
for(i = 0; i < tracks + 2; i++) {
if (a[i] > i_peak[i]) i_peak[i] = a[i];
if (a[i] > i_hold[i]) { i_hold[i] = a[i]; holdTime[i] = para.hold; }
}
paint();
}
void VUMeter::setPeak(float a[]) {
int i;
for(i = 0; i < tracks + 2; i++) {
if (a[i] > peak[i]) peak[i] = a[i];
if (a[i] > hold[i]) { hold[i] = a[i]; holdTime[i] = para.hold; }
}
paint();
}