1
/***************************************************************************
2
|FILENAME| - description
5
copyright : (C) |YEAR| by |AUTHOR|
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
***************************************************************************/
18
#include <qradiobutton.h>
25
#include <qdrawutil.h>
31
#define Black color[0]
32
#define Grey color[64]
33
#define Cyan color[127]
34
#define Yellow color[192]
36
mySlider::mySlider(QWidget *parent, const char *name = 0) :
39
setOrientation( QSlider::Vertical );
40
setTickmarks( QSlider::NoMarks );
41
setTickInterval( 10 );
54
/** Painting Slider Background depending on Threshold and Signal Strength
57
void mySlider::paintEvent(QPaintEvent *)
62
QColorGroup cg(colorGroup());
63
const QColor c0 = cg.shadow();
64
const QColor c1 = cg.dark();
65
const QColor c3 = cg.light();
73
int mid = this->width()/2;
74
QRect groove = this->rect();
75
QRect handle = this->sliderRect();
79
if ( this->orientation() == Horizontal )
82
y = groove.y() + mid - 3;
89
x = groove.x() + mid - 3;
95
p.fillRect( x, y, w, h, c1);
96
scale=(h*(100-SquelchLevel))/100;
98
if (SquelchLevel > (100-value()) )
103
if ( SquelchLevel == 0 )
108
//p->drawLine( x, y, x + w - 1, y );
109
p.drawLine( x, y, x, y + h - 1);
111
//p->drawLine( x + 1, y + 1, x + w - 2, y + 1 );
112
p.drawLine( x + 1, y + 1, x + 1, y + h - 2 );
115
p.drawLine( x + 1, y + h - 2, x + w - 2, y + h - 2 );
116
p.drawLine( x + w - 2, y + 1, x + w - 2, y + h - 2 );
118
p.drawLine( x, y + h - 1, x + w - 1, y + h - 1 );
119
p.drawLine( x + w - 1, y, x + w - 1, y + h - 1 );
121
p.fillRect(x+1,y+scale,w-2,h-scale,c4);
125
p.drawPie(x,y-w/2,w-1,w-1,0,2880);
128
p.drawPie(x,h,w-1,w-1,2880,2880);
130
p.drawArc(x,h,w-1,w-1,2880,1440);
132
p.drawArc(x,h,w-1,w-1,4320,1440);
134
// ### end slider groove
138
int x2 = handle.x() + handle.width() - 1;
140
int y2 = handle.y() + handle.height() - 1;
141
int mx = handle.width() / 2;
142
int my = handle.height() / 2;
144
if ( this->orientation() == Vertical ) {
146
QBrush oldBrush = p.brush();
147
p.setBrush( cg.brush( QColorGroup::Button ) );
150
a.setPoint( 0, x1 + 1, y1 + 1 );
151
a.setPoint( 1, x2 - my + 2, y1 + 1 );
152
a.setPoint( 2, x2 - 1, y1 + my - 1 );
153
a.setPoint( 3, x2 - 1, y2 - my + 1 );
154
a.setPoint( 4, x2 - my + 2, y2 - 1 );
155
a.setPoint( 5, x1 + 1, y2 - 1 );
157
p.setBrush( oldBrush );
161
p.drawLine( x1, y1 + 1, x1,y2 - 1 );
162
p.drawLine( x2 - my + 2, y1, x2, y1 + my - 2 );
163
p.drawLine( x2 - my + 2, y2, x2, y1 + my + 2 );
164
p.drawLine( x2, y1 + my - 2, x2, y1 + my + 2 );
165
p.drawLine( x1 + 1, y1, x2 - my + 2, y1 );
166
p.drawLine( x1 + 1, y2, x2 - my + 2, y2 );
170
p.drawLine( x1 + 1, y1 + 2, x1 + 1, y2 - 2 );
171
p.drawLine( x1 + 1, y1 + 1, x2 - my + 2, y1 + 1 );
172
p.drawLine( x2 - my + 2, y1 + 1, x2 - 1, y1 + my - 2 );
176
p.drawLine( x2 - 1, y1 + my - 2, x2 - 1, y1 + my + 2 );
177
p.drawLine( x2 - my + 2, y2 - 1, x2 - 1, y1 + my + 2 );
178
p.drawLine( x1 + 1, y2 - 1, x2 -my + 2, y2 - 1 );
180
} else { // Horizontal
181
QBrush oldBrush = p.brush();
182
p.setBrush( cg.brush( QColorGroup::Button ) );
185
a.setPoint( 0, x2 - 1, y1 + 1 );
186
a.setPoint( 1, x2 - 1, y2 - mx + 2 );
187
a.setPoint( 2, x2 - mx + 1, y2 - 1 );
188
a.setPoint( 3, x1 + mx - 1, y2 - 1 );
189
a.setPoint( 4, x1 + 1, y2 - mx + 2 );
190
a.setPoint( 5, x1 + 1, y1 + 1 );
192
p.setBrush( oldBrush );
196
p.drawLine( x1 + 1, y1, x2 - 1, y1 );
197
p.drawLine( x1, y2 - mx + 2, x1 + mx - 2, y2 );
198
p.drawLine( x2, y2 - mx + 2, x1 + mx + 2, y2 );
199
p.drawLine( x1 + mx - 2, y2, x1 + mx + 2, y2 );
200
p.drawLine( x1, y1 + 1, x1, y2 - mx + 2 );
201
p.drawLine( x2, y1 + 1, x2, y2 - mx + 2 );
205
p.drawLine( x1 + 1, y1 + 1, x2 - 1, y1 + 1 );
206
p.drawLine( x1 + 1, y1 + 1, x1 + 1, y2 - mx + 2 );
210
p.drawLine( x2 - 1, y1 + 1, x2 - 1, y2 - mx + 2 );
211
p.drawLine( x1 + 1, y2 - mx + 2, x1 + mx - 2, y2 - 1 );
212
p.drawLine( x2 - 1, y2 - mx + 2, x1 + mx + 2, y2 - 1 );
213
p.drawLine( x1 + mx - 2, y2 - 1, x1 + mx + 2, y2 - 1 );
224
void mySlider::setSquelchLevel(int level)
230
int mySlider::getThreshold()
236
* Constructs a CSquelch which is a child of 'parent', with the
239
CSquelch::CSquelch( QWidget* parent, const char* name )
240
: QGroupBox( parent, name )
242
setFrameShape( QGroupBox::WinPanel );
243
setFrameShadow( QGroupBox::Raised );
244
setAlignment( int( QGroupBox::AlignHCenter ) );
246
Activate = new QRadioButton( this, "Activate" );
247
Activate->setGeometry( QRect( 120, 340, 60, 41 ) );
248
ActivateText = new QLabel(this,"ActivateText");
249
ActivateText->setAlignment(AlignHCenter);
252
Squelch = new mySlider( this, "Squelch" );
253
// Squelch->setPaletteBackgroundColor( QColor( 0, 0, 0 ) );
254
Squelch->setOrientation( QSlider::Vertical );
255
Squelch->setTickmarks( QSlider::NoMarks );
256
Squelch->setTickInterval( 10 );
257
Squelch->setMinValue(0);
258
Squelch->setMaxValue(100);
266
* Destroys the object and frees any allocated resources
268
CSquelch::~CSquelch()
270
// no need to delete child widgets, Qt does it all for us
274
* Sets the strings of the subwidgets using the current
277
void CSquelch::languageChange()
279
setTitle( tr( "Squelch" ) );
280
ActivateText->setText( tr( "On/Off" ) );
282
void CSquelch::resizeEvent( QResizeEvent * )
284
calculateSizeofComponents();
287
void CSquelch::calculateSizeofComponents()
291
/** WIDTH and Height in % **/
292
#define SQUELCHWIDTH 25
293
#define SQUELCHHEIGHT 70
294
#define BUTTONWIDTH 90
295
#define BUTTONHEIGHT 10
297
int xpos,ypos, width,height,innerwidth,innerheight;
300
height=this->height();
301
innerwidth=width*SQUELCHWIDTH/100;
302
xpos=(width-innerwidth)/2;
303
ypos=height*TOPMARGIN/100;
304
innerheight=height*SQUELCHHEIGHT/100;
305
Squelch->setGeometry(xpos,ypos,innerwidth,innerheight);
306
ypos=ypos+innerheight;
307
innerheight=height*BUTTONHEIGHT/100;
308
Activate->setGeometry(xpos,ypos,innerwidth,innerheight);
309
innerwidth=width*BUTTONWIDTH/100;
310
xpos=(width-innerwidth)/2;
311
ypos=ypos+innerheight;
312
ActivateText->setGeometry(xpos,ypos,innerwidth,innerheight);
314
this->setFrameRect(QRect(0,0,width,height));
318
void CSquelch::setSquelchLevel(int level)
320
Squelch->setSquelchLevel(level);
324
int CSquelch::getThreshold()
326
return Squelch->getThreshold();
328
bool CSquelch::getSquelchState()
330
return Activate->isOn();
332
void CSquelch::setSquelchState(bool state)
334
Activate->setChecked(state);
336
void CSquelch::setThreshold(int Threshold)
338
Squelch->setValue(100-Threshold);