~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to noatun/noatun/modules/monoscope/monoscope.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "monoscope.h"
2
 
#include <player.h>
3
 
#include <noatunapp.h>
4
 
#include <math.h>
5
 
#include <qpainter.h>
6
 
//#include "prefs.h"
7
 
#include <klocale.h>
8
 
 
9
 
extern "C"
10
 
{
11
 
        Plugin *create_plugin()
12
 
        {
13
 
                return new Monoscope();
14
 
        }
15
 
}
16
 
 
17
 
Monoscope::Monoscope() : QWidget(0,0,WRepaintNoErase), MonoScope(50), Plugin()
18
 
{
19
 
        NOATUNPLUGINC(Monoscope);
20
 
        
21
 
        mLowColor=qRgb(0,0,0);
22
 
        mHighColor=qRgb(238,238,238);
23
 
        resize(320, 240);
24
 
        MonoScope::start();
25
 
        setCaption(i18n("Monoscope"));
26
 
        show();
27
 
        resizeEvent(0);
28
 
        repaint(0,0, QWidget::width(), height(), false);
29
 
        resizeEvent(0);
30
 
        setBackgroundColor(mLowColor);
31
 
}
32
 
 
33
 
Monoscope::~Monoscope()
34
 
{
35
 
        napp->pluginMenuRemove(pluginMenuItem);
36
 
}
37
 
 
38
 
void Monoscope::init()
39
 
{
40
 
        pluginMenuItem = napp->pluginMenuAdd(i18n("Toggle Monoscope"), this, SLOT(toggle(void)));
41
 
}
42
 
 
43
 
void Monoscope::toggle(void)
44
 
{
45
 
        if(isHidden())
46
 
                show();
47
 
        else
48
 
                hide();
49
 
}
50
 
 
51
 
void Monoscope::closeEvent(QCloseEvent *)
52
 
{
53
 
        hide();
54
 
}
55
 
 
56
 
void Monoscope::resizeEvent(QResizeEvent *)
57
 
{
58
 
        setSamples(width());
59
 
}
60
 
 
61
 
void Monoscope::scopeEvent(float *d, int size)
62
 
{
63
 
        // save cpu
64
 
        if(isHidden()) return;
65
 
 
66
 
        const bool line=false;
67
 
        
68
 
        int viewWidth =width();
69
 
        int viewHeight=height();
70
 
 
71
 
        float *end=d+size;
72
 
        int x=0;
73
 
        int heightHalf=viewHeight/4;
74
 
        int y=viewHeight/2;
75
 
        // reduce flicker
76
 
        QPixmap buffer(viewWidth, viewHeight, -1, QPixmap::BestOptim);
77
 
        buffer.fill(mLowColor);
78
 
        QPainter p(&buffer);
79
 
        p.setPen(mHighColor);
80
 
        repaint(rect());
81
 
 
82
 
        if (line)
83
 
                p.moveTo(0, y);
84
 
        
85
 
        while (d<=end)
86
 
        {
87
 
                float &n=*d;
88
 
        
89
 
                n *= heightHalf;
90
 
                int amp=(int)n;
91
 
 
92
 
                if (line) // line
93
 
                        p.lineTo(x, y+amp);
94
 
                else // fill
95
 
                        p.drawLine(x, y, x, y+amp);
96
 
                d++;
97
 
                x++;
98
 
                
99
 
        }
100
 
        if (line)
101
 
                p.drawLine(0, y, size, y);
102
 
        bitBlt(this, 0, 0, &buffer, 0, 0, viewWidth, viewHeight, Qt::CopyROP);
103
 
}
104
 
 
105
 
#include "monoscope.moc"
106