~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to noatun/noatun/library/controls.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "controls.h"
 
2
 
 
3
L33tSlider::L33tSlider(QWidget * parent, const char * name) :
 
4
        QSlider(parent,name), pressed(false)
 
5
{}
 
6
L33tSlider::L33tSlider(Orientation o, QWidget * parent, const char * name) :
 
7
        QSlider(o,parent,name), pressed(false)
 
8
{}
 
9
L33tSlider::L33tSlider(int minValue, int maxValue, int pageStep, int value,
 
10
                           Orientation o, QWidget * parent, const char * name) :
 
11
        QSlider(minValue, maxValue, pageStep, value, o, parent,name), pressed(false)
 
12
{}
 
13
 
 
14
bool L33tSlider::currentlyPressed() const
 
15
{
 
16
        return pressed;
 
17
}
 
18
 
 
19
void L33tSlider::setValue(int i)
 
20
{
 
21
        if (!pressed)
 
22
                QSlider::setValue(i);
 
23
}
 
24
 
 
25
void L33tSlider::mousePressEvent(QMouseEvent*e)
 
26
{
 
27
        if (e->button()!=RightButton)
 
28
        {
 
29
                pressed=true;
 
30
                QSlider::mousePressEvent(e);
 
31
        }
 
32
}
 
33
 
 
34
void L33tSlider::mouseReleaseEvent(QMouseEvent*e)
 
35
{
 
36
        pressed=false;
 
37
        QSlider::mouseReleaseEvent(e);
 
38
        emit userChanged(value());
 
39
}
 
40
 
 
41
void L33tSlider::wheelEvent(QWheelEvent *e)
 
42
{
 
43
        QSlider::wheelEvent(e);
 
44
        int newValue=value() /* +e->delta()/120 */;
 
45
        if (newValue<minValue())
 
46
                newValue=minValue();
 
47
        else if (newValue>maxValue())
 
48
                newValue=maxValue();
 
49
        setValue(newValue);
 
50
        emit userChanged(newValue);
 
51
}
 
52
 
 
53
 
 
54
SliderAction::SliderAction(const QString& text, int accel, const QObject *receiver,
 
55
                                 const char *member, QObject* parent, const char* name )
 
56
        : KAction( text, accel, parent, name )
 
57
{
 
58
        m_receiver = receiver;
 
59
        m_member = member;
 
60
}
 
61
 
 
62
int SliderAction::plug( QWidget *w, int index )
 
63
{
 
64
        if (!w->inherits("KToolBar")) return -1;
 
65
 
 
66
        KToolBar *toolBar = (KToolBar *)w;
 
67
        int id = KAction::getToolButtonID();
 
68
        
 
69
        //Create it.
 
70
        m_slider=new L33tSlider(0, 1000, 100, 0, Horizontal, toolBar);
 
71
        m_slider->setMinimumWidth(10);
 
72
        toolBar->insertWidget(id, 10, m_slider, index );
 
73
 
 
74
 
 
75
        addContainer( toolBar, id );
 
76
        connect( toolBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
 
77
        toolBar->setItemAutoSized( id, true );
 
78
 
 
79
        if (w->inherits( "KToolBar" ))
 
80
                connect(toolBar, SIGNAL(moved(KToolBar::BarPosition)), this, SLOT(toolbarMoved(KToolBar::BarPosition)));
 
81
        
 
82
        emit plugged();
 
83
 
 
84
        return containerCount() - 1;
 
85
}
 
86
 
 
87
void SliderAction::toolbarMoved(KToolBar::BarPosition)
 
88
{
 
89
// I wish this worked :)
 
90
return; 
 
91
/*
 
92
        if (pos == KToolBar::Left || pos == KToolBar::Right)
 
93
        {
 
94
                m_slider->setOrientation(Vertical);
 
95
                m_slider->setFixedWidth(m_slider->height());
 
96
        }
 
97
        else
 
98
        {
 
99
                m_slider->setOrientation(Horizontal);
 
100
                m_slider->resize(m_slider->height(), m_slider->height());
 
101
        }
 
102
*/
 
103
}
 
104
 
 
105
void SliderAction::unplug( QWidget *w )
 
106
{
 
107
        KToolBar *toolBar = (KToolBar *)w;
 
108
        int idx = findContainer( w );
 
109
 
 
110
        toolBar->removeItem( menuId( idx ) );
 
111
        removeContainer( idx );
 
112
}
 
113
 
 
114
#include "controls.moc"