1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
/***************************************************************************
gammactrl.cpp - description
-------------------
begin : Sun Oct 7 2001
copyright : (C) 2001 by Michael v.Ostheim
email : MvOstheim@web.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <tqlabel.h>
#include <tqlineedit.h>
#include <tqstring.h>
#include <kdialog.h>
#include "gammactrl.h"
#include "xvidextwrap.h"
#include "displaynumber.h"
#include "gammactrl.moc"
GammaCtrl::GammaCtrl(TQWidget *tqparent, XVidExtWrap *xvid, int channel, \
const TQString& mingamma, const TQString& maxgamma, const TQString& setgamma, \
const char *name) : TQHBox(tqparent, name)
{
int maxslider = (int)( ( maxgamma.toDouble() - mingamma.toDouble() \
+ 0.0005 ) * 20 );
int setslider = (int)( ( setgamma.toDouble() - mingamma.toDouble() \
+ 0.0005 ) * 20 );
setslider = (setslider > maxslider) ? maxslider : setslider;
setslider = (setslider < 0) ? 0 : setslider;
suspended = false;
changed=false;
ming = mingamma.toFloat();
mgamma = mingamma;
oldpos = setslider;
gchannel = channel;
xv = xvid;
setSpacing(KDialog::spacingHint());
slider = new TQSlider(Qt::Horizontal, this);
slider->setFixedHeight(24);
slider->setTickmarks(TQSlider::Below);
slider->setRange(0, maxslider);
slider->setTickInterval(2);
slider->setValue(setslider);
connect(slider, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(setGamma(int)));
connect(slider, TQT_SIGNAL(sliderPressed()), TQT_SLOT(pressed()));
textfield = new DisplayNumber(this, 4, 2);
textfield->setText(setgamma);
}
GammaCtrl::~GammaCtrl()
{
}
/** set gamma, slider and textfield */
void GammaCtrl::setGamma(const TQString& gamma){
int sliderpos;
sliderpos = (int)( ( gamma.toDouble() - mgamma.toDouble() + 0.0005 ) * 20 );
changed=true;
slider->setValue(sliderpos);
setGamma(sliderpos);
if (suspended) {
suspended=false;
textfield->setDisabled(false);
}
}
/** set slider and textfield */
void GammaCtrl::setControl(const TQString& gamma){
int sliderpos;
sliderpos = (int)( ( gamma.toDouble() - mgamma.toDouble() + 0.0005 ) * 20 );
setCtrl(sliderpos);
}
/** Return the current gamma value with precision prec */
TQString GammaCtrl::gamma(int prec){
TQString gammatext;
gammatext.setNum(xv->getGamma(gchannel) + 0.0005, 'f', prec);
return(gammatext);
}
/** Slot: set gamma and textfield */
void GammaCtrl::setGamma(int sliderpos){
if (sliderpos != oldpos || changed) {
xv->setGamma(gchannel, ming+(float)(slider->value())*0.05);
textfield->setNum(xv->getGamma(gchannel));
oldpos = sliderpos;
changed=false;
emit gammaChanged(sliderpos);
}
}
/** Slot: set slider and textfield */
void GammaCtrl::setCtrl(int sliderpos){
if (suspended) {
suspended=false;
textfield->setDisabled(false);
}
oldpos = sliderpos;
slider->setValue(sliderpos);
textfield->setNum(xv->getGamma(gchannel));
}
/** Slot: disable textfield */
void GammaCtrl::suspend(){
if (!suspended) {
suspended = true;
textfield->setDisabled(true);
}
}
/** Slot: Change status of GammaCtrl when pressed */
void GammaCtrl::pressed(){
if (suspended) {
suspended=false;
textfield->setDisabled(false);
changed=true;
setGamma(slider->value());
}
}
|