[kde-doc-english] extragear/graphics/kcoloredit/src/widgets
Percy Camilo Triveño Aucahuasi
orgyforever at gmail.com
Tue Aug 26 18:15:03 CEST 2008
SVN commit 852796 by aucahuasi:
GUI:
* Fixed wrongs icons
* Updated messages from "colortoolwidget"
* "Saturation tool" ready
M +39 -14 colortoolwidget.cpp
M +10 -1 colortoolwidget.h
M +11 -2 kcoloreditwidget.cpp
--- trunk/extragear/graphics/kcoloredit/src/widgets/colortoolwidget.cpp #852795:852796
@@ -19,7 +19,7 @@
#include "colortoolwidget.h"
-#include <QtGui/QGridLayout>
+#include <QtGui/QLayout>
#include <QtGui/QLabel>
#include <QtGui/QCheckBox>
#include <QtGui/QGroupBox>
@@ -28,7 +28,6 @@
#include <KLocalizedString>
#include <KPushButton>
-
ColorToolWidget::ColorToolWidget(QWidget * parent)
: QWidget(parent)
{
@@ -36,13 +35,15 @@
QGroupBox * brightnessBox = new QGroupBox(i18n("Brightness"), this);
- KPushButton * decreaseBrightnessButton = new KPushButton(brightnessBox);
- KPushButton * increaseBrightnessButton = new KPushButton(brightnessBox);
+ KPushButton * decreaseBrightnessButton = new KPushButton(KIcon("arrow-down"), i18n("Decrease"), brightnessBox);
+ KPushButton * increaseBrightnessButton = new KPushButton(KIcon("arrow-up"), i18n("Increase"), brightnessBox);
+ m_brightnessPercentage = new QLabel("45%", brightnessBox);
+
QHBoxLayout * brightnessLayout = new QHBoxLayout(brightnessBox);
brightnessLayout->addWidget(decreaseBrightnessButton);
brightnessLayout->addWidget(increaseBrightnessButton);
- brightnessLayout->addWidget(new QLabel("45%", brightnessBox));
+ brightnessLayout->addWidget(m_brightnessPercentage);
//END Brightness settings
@@ -50,13 +51,15 @@
QGroupBox * saturationBox = new QGroupBox(i18n("Saturation"), this);
- KPushButton * decreaseSaturationButton = new KPushButton(saturationBox);
- KPushButton * increaseSaturationButton = new KPushButton(saturationBox);
+ KPushButton * decreaseSaturationButton = new KPushButton(KIcon("arrow-down"), i18n("Decrease"), saturationBox);
+ KPushButton * increaseSaturationButton = new KPushButton(KIcon("arrow-up"), i18n("Increase"), saturationBox);
+ m_saturationPercentage = new QLabel("15%", saturationBox);
+
QHBoxLayout * saturationLayout = new QHBoxLayout(saturationBox);
saturationLayout->addWidget(decreaseSaturationButton);
saturationLayout->addWidget(increaseSaturationButton);
- saturationLayout->addWidget(new QLabel("15%", saturationBox));
+ saturationLayout->addWidget(m_saturationPercentage);
connect(decreaseSaturationButton, SIGNAL( pressed () ), SLOT( decreaseSaturation() ));
connect(increaseSaturationButton, SIGNAL( pressed () ), SLOT( increaseSaturation() ));
@@ -67,11 +70,12 @@
QGroupBox * extraSelectorsBox = new QGroupBox(i18n("Extra color selectors"), this);
- KPushButton * pickColorButton = new KPushButton(KIcon("pick-color"), i18n("pick a color from desktop"), extraSelectorsBox);
+ KPushButton * pickColorButton = new KPushButton(KIcon("color-picker"), i18n("Pick a color"), extraSelectorsBox);
+ h_checkBoxHideWindow = new QCheckBox(i18n("Hide window"), extraSelectorsBox);
QHBoxLayout * pickColorLayout = new QHBoxLayout();
pickColorLayout->addWidget(pickColorButton);
- pickColorLayout->addWidget(new QCheckBox(extraSelectorsBox));
+ pickColorLayout->addWidget(h_checkBoxHideWindow);
QVBoxLayout * extraSelectorsLayout = new QVBoxLayout(extraSelectorsBox);
extraSelectorsLayout->addLayout(pickColorLayout);
@@ -92,6 +96,8 @@
void ColorToolWidget::setColor(const QColor & color)
{
m_color = color;
+
+ m_saturationPercentage->setText(QString::number(static_cast<int>(m_color.saturation()*100/255)) + "%");
}
void ColorToolWidget::pickColorFromDesktop()
@@ -99,17 +105,36 @@
}
+void ColorToolWidget::decreaseBrightness()
+{
+
+}
+
+void ColorToolWidget::increaseBrightness()
+{
+
+}
+
void ColorToolWidget::decreaseSaturation()
{
- //emit colorSelected(randColor);
+ int tmpSaturation = qBound(0, m_color.saturation() - 5, 255);
+
+ m_color.setHsv(m_color.hue(), tmpSaturation, m_color.value());
+
+ m_saturationPercentage->setText(QString::number(static_cast<int>(m_color.saturation()*100/255)) + "%");
+
+ emit colorSelected(m_color);
}
void ColorToolWidget::increaseSaturation()
{
- static QColor saturatedColor;
- saturatedColor.setHsv(m_color.hue(), m_color.saturation() + 0.05 * 100, m_color.value());
+ int tmpSaturation = qBound(0, m_color.saturation() + 5, 255);
- emit colorSelected(saturatedColor);
+ m_color.setHsv(m_color.hue(), tmpSaturation, m_color.value());
+
+ m_saturationPercentage->setText(QString::number(static_cast<int>(m_color.saturation()*100/255)) + "%");
+
+ emit colorSelected(m_color);
}
#include "colortoolwidget.moc"
--- trunk/extragear/graphics/kcoloredit/src/widgets/colortoolwidget.h #852795:852796
@@ -22,7 +22,8 @@
#include <QtGui/QWidget>
-class QEvent;
+class QLabel;
+class QCheckBox;
class ColorToolWidget : public QWidget
{
@@ -38,6 +39,9 @@
void colorSelected(const QColor & color);
private slots:
+ void decreaseBrightness();
+ void increaseBrightness();
+
void decreaseSaturation();
void increaseSaturation();
@@ -45,6 +49,11 @@
private:
QColor m_color;
+
+ QLabel * m_brightnessPercentage;
+ QLabel * m_saturationPercentage;
+
+ QCheckBox * h_checkBoxHideWindow;
};
#endif // COLORTOOL_WIDGET_H
--- trunk/extragear/graphics/kcoloredit/src/widgets/kcoloreditwidget.cpp #852795:852796
@@ -53,7 +53,7 @@
m_blenderColorSelector->setWindowIcon(KIcon("fill-color"));
m_colorToolWidget = new ColorToolWidget(colorTools);
- m_colorToolWidget->setWindowTitle(i18nc("Set of extra tools apart of color selectors", "Extra"));
+ m_colorToolWidget->setWindowTitle(i18nc("Set of extra tools apart of color selectors", "Extras"));
colorTools->addPage(m_kdeColorSelector);
colorTools->addPage(m_gtkColorSelector);
@@ -96,9 +96,18 @@
connect(m_blenderColorSelector, SIGNAL( colorsAdded(QVector<QColor>) ), SLOT( appendColorsFromGradientSelector(QVector<QColor>) ));
- for (int i = 0; i < colorTools->count(); i++)
+ // TODO document this
+
+ // All color selector can change the color of the dispatcher and extratools
+ for (int i = 0; i < colorTools->count() - 1; i++)
+ {
connect(colorTools->widget(i), SIGNAL( colorSelected(QColor) ), m_colorDispatcher, SLOT( setColor(QColor) ));
+ connect(colorTools->widget(i), SIGNAL( colorSelected(QColor) ), colorTools->widget(colorTools->count() - 1), SLOT( setColor(QColor) ));
+ }
+ // Extratools can change the color of the dispatcher
+ connect(colorTools->widget(colorTools->count() - 1), SIGNAL( colorSelected(QColor) ), m_colorDispatcher, SLOT( setColor(QColor) ));
+
for (int j = 0; j < colorInfoTexts->count(); j++)
connect(m_colorDispatcher, SIGNAL( colorChanged(QColor) ), colorInfoTexts->widget(j), SLOT( setColor(QColor) ));
More information about the kde-doc-english
mailing list