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

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • kdeui
  • colors
kcolorchoosermode.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the KDE project.
3  * Copyright © 2010 Christoph Feck <christoph@maxiom.de>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License version 2 as published by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #include "kcolorchoosermode_p.h"
21 
22 #include <QtGui/QColor>
23 
24 namespace KDEPrivate {
25 
26 qreal getComponentValue(const QColor &color, KColorChooserMode chooserMode)
27 {
28  switch (chooserMode) {
29  case ChooserRed:
30  return color.redF();
31  case ChooserGreen:
32  return color.greenF();
33  case ChooserBlue:
34  return color.blueF();
35  case ChooserHue:
36  return color.hueF();
37  case ChooserSaturation:
38  return color.saturationF();
39  default:
40  return color.valueF();
41  }
42 }
43 
44 void setComponentValue(QColor &color, KColorChooserMode chooserMode, qreal value)
45 {
46  if (chooserMode >= ChooserRed) {
47  if (chooserMode == ChooserRed) {
48  color.setRedF(value);
49  } else if (chooserMode == ChooserGreen) {
50  color.setGreenF(value);
51  } else { // chooserMode == ChooserBlue
52  color.setBlueF(value);
53  }
54  } else {
55  qreal h, s, v, a;
56  color.getHsvF(&h, &s, &v, &a);
57  if (chooserMode == ChooserHue) {
58  h = value;
59  } else if (chooserMode == ChooserSaturation) {
60  s = value;
61  } else { // chooserMode == ChooserValue
62  v = value;
63  }
64  color.setHsvF(h, s, v, a);
65  }
66 }
67 
68 } // namespace KDEPrivate
ChooserRed
Definition: kcolorchoosermode.h:28
QColor::setRedF
void setRedF(qreal red)
QColor::redF
qreal redF() const
QColor::setBlueF
void setBlueF(qreal blue)
QColor::blueF
qreal blueF() const
KDEPrivate::getComponentValue
qreal getComponentValue(const QColor &color, KColorChooserMode chooserMode)
Definition: kcolorchoosermode.cpp:26
KDEPrivate::setComponentValue
void setComponentValue(QColor &color, KColorChooserMode chooserMode, qreal value)
Definition: kcolorchoosermode.cpp:44
ChooserSaturation
Definition: kcolorchoosermode.h:26
QColor::valueF
qreal valueF() const
QColor::setGreenF
void setGreenF(qreal green)
QColor::greenF
qreal greenF() const
QColor
KColorChooserMode
KColorChooserMode
Definition: kcolorchoosermode.h:22
QColor::setHsvF
void setHsvF(qreal h, qreal s, qreal v, qreal a)
QColor::saturationF
qreal saturationF() const
ChooserHue
Definition: kcolorchoosermode.h:25
QColor::hueF
qreal hueF() const
ChooserGreen
Definition: kcolorchoosermode.h:29
QColor::getHsvF
void getHsvF(qreal *h, qreal *s, qreal *v, qreal *a) const
ChooserBlue
Definition: kcolorchoosermode.h:30
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

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