diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 47d455dd55be855e4cc691c32f687f723d9247ee (patch) | |
tree | 52e236aaa2576bdb3840ebede26619692fed6d7d /kgamma/kcmkgamma/gammactrl.cpp | |
download | tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kgamma/kcmkgamma/gammactrl.cpp')
-rw-r--r-- | kgamma/kcmkgamma/gammactrl.cpp | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/kgamma/kcmkgamma/gammactrl.cpp b/kgamma/kcmkgamma/gammactrl.cpp new file mode 100644 index 00000000..2052fd34 --- /dev/null +++ b/kgamma/kcmkgamma/gammactrl.cpp @@ -0,0 +1,138 @@ +/*************************************************************************** + gammactrl.cpp - description + ------------------- + begin : Sun Oct 7 2001 + copyright : (C) 2001 by Michael v.Ostheim + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 <qlabel.h> +#include <qlineedit.h> +#include <qstring.h> + +#include <kdialog.h> + +#include "gammactrl.h" +#include "xvidextwrap.h" +#include "displaynumber.h" +#include "gammactrl.moc" + +GammaCtrl::GammaCtrl(QWidget *parent, XVidExtWrap *xvid, int channel, \ + const QString& mingamma, const QString& maxgamma, const QString& setgamma, \ + const char *name) : QHBox(parent, 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 QSlider(Horizontal, this); + slider->setFixedHeight(24); + slider->setTickmarks(QSlider::Below); + slider->setRange(0, maxslider); + slider->setTickInterval(2); + slider->setValue(setslider); + connect(slider, SIGNAL(valueChanged(int)), SLOT(setGamma(int))); + connect(slider, SIGNAL(sliderPressed()), SLOT(pressed())); + + textfield = new DisplayNumber(this, 4, 2); + textfield->setText(setgamma); + +} + +GammaCtrl::~GammaCtrl() +{ +} + +/** set gamma, slider and textfield */ +void GammaCtrl::setGamma(const QString& 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 QString& gamma){ + int sliderpos; + + sliderpos = (int)( ( gamma.toDouble() - mgamma.toDouble() + 0.0005 ) * 20 ); + setCtrl(sliderpos); +} + +/** Return the current gamma value with precision prec */ +QString GammaCtrl::gamma(int prec){ + QString 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()); + } +} + |