Debian Codegraph @

samples/qtvidcap/picprop.cpp

raw
1 #include "picprop.h"
2 #include "picprop.moc"
3
4 #include "v4lxif.h"
5
6 #define DECLARE_REGISTRY_SHORTCUT
7 #include "configfile.h"
8 #undef DECLARE_REGISTRY_SHORTCUT
9
10 #include <qlabel.h>
11 #include <qslider.h>
12
13 #include <stdio.h>
14 /*
15 * Constructs a PicturePropDialog which is a child of 'parent', with the
16 * name 'name' and widget flags set to 'f'
17 *
18 * The dialog will by default be modeless, unless you set 'modal' to
19 * TRUE to construct a modal dialog.
20 */
21 PicturePropDialog::PicturePropDialog(v4lxif* pDev)
22 : PicPropDialog( 0, 0, FALSE, 0), m_pDev(pDev)
23 {
24 connect(m_pSlider[PROP_BRIGHTNESS], SIGNAL(valueChanged(int)), this, SLOT(changeBrightness(int)));
25 connect(m_pSlider[PROP_SATURATION], SIGNAL(valueChanged(int)), this, SLOT(changeSaturation(int)));
26 connect(m_pSlider[PROP_CONTRAST], SIGNAL(valueChanged(int)), this, SLOT(changeContrast(int)));
27 connect(m_pSlider[PROP_HUE], SIGNAL(valueChanged(int)), this, SLOT(changeHue(int)));
28
29 m_pSlider[PROP_BRIGHTNESS]->setValue( RI("Image\\Brightness", 0) );
30 m_pSlider[PROP_SATURATION]->setValue( (RI("Image\\Color", 255)-255)/2 );
31 m_pSlider[PROP_CONTRAST]->setValue( (RI("Image\\Contrast", 255)-255)/2 );
32 m_pSlider[PROP_HUE]->setValue( RI("Image\\Hue", 0) );
33 }
34
35 /*
36 * Destroys the object and frees any allocated resources
37 */
38 PicturePropDialog::~PicturePropDialog()
39 {
40 // no need to delete child widgets, Qt does it all for us
41 }
42
43
44 void PicturePropDialog::changeBrightness(int val)
45 {
46 QString s = QString().sprintf( tr("Brightness")+": %d", val );
47 m_pLabel[PROP_BRIGHTNESS]->setText( s );
48 m_pDev->setPicBrightness( val );
49 }
50 void PicturePropDialog::changeContrast(int val)
51 {
52 QString s = QString().sprintf( tr("Contrast:")+": %d", val );
53 m_pLabel[PROP_CONTRAST]->setText( s );
54 m_pDev->setPicConstrast( 2 * (val + 128) );
55 }
56 void PicturePropDialog::changeHue(int val)
57 {
58 QString s = QString().sprintf( tr("Hue")+": %d", val );
59 m_pLabel[PROP_HUE]->setText( s );
60 m_pDev->setPicHue( val );
61 }
62 void PicturePropDialog::changeSaturation(int val)
63 {
64 QString s = QString().sprintf( tr("Saturation")+": %d", val );
65 m_pLabel[PROP_SATURATION]->setText( s );
66 m_pDev->setPicColor( 2 * (val + 128) );
67 }
68
69 void PicturePropDialog::accept()
70 {
71 WI("Image\\Brightness", m_pSlider[PROP_BRIGHTNESS]->value());
72 WI("Image\\Color", 256+2*m_pSlider[PROP_SATURATION]->value());
73 WI("Image\\Contrast", 256+2*m_pSlider[PROP_CONTRAST]->value());
74 WI("Image\\Hue", m_pSlider[PROP_HUE]->value());
75 // printf("Writing: %d %d %d %d\n",
76 // m_pSBrightness->value(),
77 // 256+2*m_pSConstrast->value(),
78 // 256+2*m_pSSaturation->value(),
79 // m_pSHue->value()
80 // );
81 return QDialog::accept();
82 }