• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

libs/libksane/libksane

  • sources
  • kde-4.14
  • kdegraphics
  • libs
  • libksane
  • libksane
  • options
ksane_opt_gamma.cpp
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is part of the KDE project
4  *
5  * Date : 2009-01-31
6  * Description : Sane interface for KDE
7  *
8  * Copyright (C) 2009 by Kare Sars <kare dot sars at iki dot fi>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) version 3, or any
14  * later version accepted by the membership of KDE e.V. (or its
15  * successor approved by the membership of KDE e.V.), which shall
16  * act as a proxy defined in Section 6 of version 3 of the license.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this program. If not, see <http://www.gnu.org/licenses/>.
25  *
26  * ============================================================ */
27 // Local includes
28 #include "ksane_opt_gamma.h"
29 #include "ksane_opt_gamma.moc"
30 
31 #include "labeled_gamma.h"
32 
33 // Qt includes
34 #include <QtCore/QVarLengthArray>
35 
36 // KDE includes
37 #include <KDebug>
38 #include <KLocale>
39 
40 namespace KSaneIface
41 {
42 
43 KSaneOptGamma::KSaneOptGamma(const SANE_Handle handle, const int index)
44 : KSaneOption(handle, index), m_gamma(0)
45 {
46 }
47 
48 void KSaneOptGamma::createWidget(QWidget *parent)
49 {
50  if (m_widget) return;
51 
52  readOption();
53 
54  if (!m_optDesc) {
55  kDebug() << "This is a bug";
56  m_widget = new KSaneOptionWidget(parent, "");
57  return;
58  }
59 
60  m_widget = m_gamma = new LabeledGamma(parent, i18n(m_optDesc->title),
61  m_optDesc->size/sizeof(SANE_Word));
62  connect(m_gamma, SIGNAL(gammaTableChanged(QVector<int>)),
63  this, SLOT(gammaTableChanged(QVector<int>)));
64  if (strcmp(m_optDesc->name, SANE_NAME_GAMMA_VECTOR_R) == 0) m_gamma->setColor(Qt::red);
65  if (strcmp(m_optDesc->name, SANE_NAME_GAMMA_VECTOR_G) == 0) m_gamma->setColor(Qt::green);
66  if (strcmp(m_optDesc->name, SANE_NAME_GAMMA_VECTOR_B) == 0) m_gamma->setColor(Qt::blue);
67 
68  m_widget->setToolTip(i18n(m_optDesc->desc));
69  updateVisibility();
70  readValue();
71 }
72 
73 void KSaneOptGamma::gammaTableChanged(const QVector<int> &gam_tbl)
74 {
75  QVector<int> copy = gam_tbl;
76  writeData(copy.data());
77 }
78 
79 void KSaneOptGamma::readValue()
80 {
81  // Unfortunately gamma table to brigthness, contrast and gamma is
82  // not easy nor fast.. ergo not done
83 }
84 
85 bool KSaneOptGamma::getValue(float &) {return false;}
86 bool KSaneOptGamma::setValue(float) {return false;}
87 
88 bool KSaneOptGamma::getValue(QString &val)
89 {
90  if (!m_gamma) return false;
91  if (state() == STATE_HIDDEN) return false;
92  int bri;
93  int con;
94  int gam;
95  m_gamma->getValues(bri, con, gam);
96  val = QString().sprintf("%d:%d:%d", bri, con, gam);
97  return true;
98 }
99 
100 bool KSaneOptGamma::setValue(const QString &val)
101 {
102  if (!m_gamma) return false;
103  if (state() == STATE_HIDDEN) return false;
104 
105  m_gamma->setValues(val);
106  return true;
107 }
108 
109 } // NameSpace KSaneIface
QWidget
KSaneIface::KSaneOptGamma::KSaneOptGamma
KSaneOptGamma(const SANE_Handle handle, const int index)
Definition: ksane_opt_gamma.cpp:43
KSaneIface::LabeledGamma::setValues
void setValues(int bri, int con, int gam)
Definition: labeled_gamma.cpp:100
QVector::data
T * data()
KSaneIface::KSaneOption::state
KSaneOptWState state()
Definition: ksane_option.cpp:92
KSaneIface::KSaneOption::m_optDesc
const SANE_Option_Descriptor * m_optDesc
This pointer is provided by sane.
Definition: ksane_option.h:115
KSaneIface::KSaneOptionWidget
A wrapper for a checkbox.
Definition: ksane_option_widget.h:45
KSaneIface::LabeledGamma
A wrapper for a checkbox.
Definition: labeled_gamma.h:45
QString
KSaneIface::LabeledGamma::setColor
void setColor(const QColor &color)
Definition: labeled_gamma.cpp:93
KSaneIface::KSaneOption
Definition: ksane_option.h:49
KSaneIface::KSaneOption::STATE_HIDDEN
Definition: ksane_option.h:69
QVector< int >
KSaneIface::KSaneOption::writeData
bool writeData(void *data)
Definition: ksane_option.cpp:126
KSaneIface::KSaneOption::readOption
virtual void readOption()
Definition: ksane_option.cpp:73
QString::sprintf
QString & sprintf(const char *cformat,...)
KSaneIface::KSaneOption::updateVisibility
void updateVisibility()
Definition: ksane_option.cpp:79
KSaneIface::KSaneOption::m_widget
KSaneOptionWidget * m_widget
Definition: ksane_option.h:117
QWidget::setToolTip
void setToolTip(const QString &)
labeled_gamma.h
KSaneIface::KSaneOptGamma::createWidget
void createWidget(QWidget *parent)
Definition: ksane_opt_gamma.cpp:48
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
KSaneIface::KSaneOptGamma::readValue
void readValue()
Definition: ksane_opt_gamma.cpp:79
ksane_opt_gamma.h
KSaneIface::LabeledGamma::getValues
bool getValues(int &bri, int &con, int &gam)
Definition: labeled_gamma.cpp:147
KSaneIface::KSaneOptGamma::setValue
bool setValue(float val)
Definition: ksane_opt_gamma.cpp:86
KSaneIface::KSaneOptGamma::getValue
bool getValue(float &val)
Definition: ksane_opt_gamma.cpp:85
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:19:47 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libs/libksane/libksane

Skip menu "libs/libksane/libksane"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal