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

KDEUI

kcolorchoosermode.cpp

Go to the documentation of this file.
00001 /*
00002  * This file is part of the KDE project.
00003  * Copyright © 2010 Christoph Feck <christoph@maxiom.de>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License version 2 as published by the Free Software Foundation.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this library; see the file COPYING.LIB.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #include "kcolorchoosermode_p.h"
00021 
00022 #include <QtGui/QColor>
00023 
00024 namespace KDEPrivate {
00025 
00026 qreal getComponentValue(const QColor &color, KColorChooserMode chooserMode)
00027 {
00028     switch (chooserMode) {
00029     case ChooserRed:
00030         return color.redF();
00031     case ChooserGreen:
00032         return color.greenF();
00033     case ChooserBlue:
00034         return color.blueF();
00035     case ChooserHue:
00036         return color.hueF();
00037     case ChooserSaturation:
00038         return color.saturationF();
00039     default:
00040         return color.valueF();
00041     }
00042 }
00043 
00044 void setComponentValue(QColor &color, KColorChooserMode chooserMode, qreal value)
00045 {
00046     if (chooserMode >= ChooserRed) {
00047         if (chooserMode == ChooserRed) {
00048             color.setRedF(value);
00049         } else if (chooserMode == ChooserGreen) {
00050             color.setGreenF(value);
00051         } else { // chooserMode == ChooserBlue
00052             color.setBlueF(value);
00053         }
00054     } else {
00055         qreal h, s, v, a;
00056         color.getHsvF(&h, &s, &v, &a);
00057         if (chooserMode == ChooserHue) {
00058             h = value;
00059         } else if (chooserMode == ChooserSaturation) {
00060             s = value;
00061         } else { // chooserMode == ChooserValue
00062             v = value;
00063         }
00064         color.setHsvF(h, s, v, a);
00065     }
00066 }
00067 
00068 } // namespace KDEPrivate

KDEUI

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • 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
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal