[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/krita/plugins/extensions/dockers/colorselectorng
From: Adam Celarek <bugs_kde_org () xibo ! at>
Date: 2010-08-31 21:34:57
Message-ID: 20100831213457.9FFEAAC857 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1170433 by adamc:
o removed resource manager from KisShadeSelectorLine
o added options, for when an color update of the shade selector is
triggered: left click, right click, foreground change, background change
M +1 -3 kis_color_selector_base.cpp
M +8 -8 kis_color_selector_base.h
M +0 -5 kis_color_selector_container.cpp
M +15 -0 kis_color_selector_settings.cpp
M +2 -2 kis_color_selector_triangle.h
M +18 -0 kis_minimal_shade_selector.cpp
M +3 -0 kis_minimal_shade_selector.h
M +34 -3 kis_my_paint_shade_selector.cpp
M +3 -0 kis_my_paint_shade_selector.h
M +14 -13 kis_shade_selector_line.cpp
M +0 -3 kis_shade_selector_line.h
M +22 -25 wdg_color_selector_settings.ui
--- trunk/koffice/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector_base.cpp \
#1170432:1170433 @@ -41,12 +41,12 @@
m_canvas(0),
m_popup(0),
m_parent(0),
+ m_colorUpdateAllowed(true),
m_hideDistance(40),
m_timer(new QTimer(this)),
m_popupOnMouseOver(false),
m_popupOnMouseClick(true),
m_colorSpace(0),
- m_colorUpdateAllowed(true),
m_isPopup(false)
{
m_timer->setInterval(350);
@@ -322,8 +322,6 @@
else
m_canvas->resourceManager()->setBackgroundColor(color);
- emit colorChanged(rawColor);
-
m_colorUpdateAllowed=true;
}
--- trunk/koffice/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector_base.h \
#1170432:1170433 @@ -46,32 +46,33 @@
virtual void updateSettings();
virtual void setColor(const QColor& color);
virtual void showPopup();
+ /// commits a color to the resource manager
+ void commitColor(const KoColor& koColor, const QColor& qColor, ColorRole role);
public:
void mousePressEvent(QMouseEvent *);
+ /// finds a QColor, that will be ref.toQColor(), if converting it to the color \
space of ref + QColor findGeneratingColor(const KoColor& ref) const;
+
protected:
void mouseMoveEvent(QMouseEvent *);
void keyPressEvent(QKeyEvent *);
virtual KisColorSelectorBase* createPopup() const = 0;
- /// finds a QColor, that will be ref.toQColor(), if converting it to the color \
space of ref
- QColor findGeneratingColor(const KoColor& ref) const;
void dragEnterEvent(QDragEnterEvent *);
void dropEvent(QDropEvent *);
protected slots:
void hidePopup();
- void commitColor(const KoColor& koColor, const QColor& qColor, ColorRole role);
- void resourceChanged(int key, const QVariant& v);
-signals:
- /// emits the new color raw, that means without color space transformation
- void colorChanged(const QColor& rawColor) const;
+ /// if you overwrite this, keep in mind, that you should set the colour only, if \
m_colorUpdateAllowed is true + virtual void resourceChanged(int key, const \
QVariant& v);
protected:
KisCanvas2* m_canvas;
KisColorSelectorBase* m_popup;
QWidget* m_parent;
+ bool m_colorUpdateAllowed;
private:
int m_hideDistance;
@@ -79,7 +80,6 @@
bool m_popupOnMouseOver;
bool m_popupOnMouseClick;
mutable const KoColorSpace* m_colorSpace;
- bool m_colorUpdateAllowed;
bool m_isPopup; //this instance is a popup
};
--- trunk/koffice/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector_container.cpp \
#1170432:1170433 @@ -72,11 +72,6 @@
connect(this, SIGNAL(settingsChanged()), m_myPaintShadeSelector, \
SLOT(updateSettings()));
connect(this, SIGNAL(settingsChanged()), this, \
SLOT(updateSettings()));
connect(this, SIGNAL(settingsChanged()), m_minimalShadeSelector, \
SLOT(updateSettings()));
-
- connect(m_colorSelector, SIGNAL(colorChanged(const QColor&)), \
m_myPaintShadeSelector, SLOT(setColor(const QColor&)));
- connect(m_myPaintShadeSelector, SIGNAL(colorChanged(const QColor&)), \
m_colorSelector, SLOT(setColor(const QColor&)));
- connect(m_colorSelector, SIGNAL(colorChanged(const QColor&)), \
m_minimalShadeSelector, SLOT(setColor(const QColor&)));
- connect(m_myPaintShadeSelector, SIGNAL(colorChanged(const QColor&)), \
m_minimalShadeSelector, SLOT(setColor(const QColor&))); }
void KisColorSelectorContainer::setCanvas(KisCanvas2 *canvas)
--- trunk/koffice/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector_settings.cpp \
#1170432:1170433 @@ -155,6 +155,11 @@
cfg.writeEntry("shadeSelectorType", shadeSelectorType);
+ cfg.writeEntry("shadeSelectorUpdateOnRightClick", \
ui->shadeSelectorUpdateOnRightClick->isChecked()); + \
cfg.writeEntry("shadeSelectorUpdateOnForeground", \
ui->shadeSelectorUpdateOnForeground->isChecked()); + \
cfg.writeEntry("shadeSelectorUpdateOnLeftClick", \
ui->shadeSelectorUpdateOnLeftClick->isChecked()); + \
cfg.writeEntry("shadeSelectorUpdateOnBackground", \
ui->shadeSelectorUpdateOnBackground->isChecked()); +
cfg.writeEntry("minimalShadeSelectorAsGradient", \
ui->minimalShadeSelectorAsGradient->isChecked());
cfg.writeEntry("minimalShadeSelectorPatchCount", \
ui->minimalShadeSelectorPatchesPerLine->value());
cfg.writeEntry("minimalShadeSelectorLineConfig", \
ui->minimalShadeSelectorLineSettings->toString()); @@ -248,6 +253,11 @@
ui->shadeSelectorTypeMinimal->setChecked(shadeSelectorType=="Minimal");
ui->shadeSelectorTypeHidden->setChecked(shadeSelectorType=="Hidden");
+ ui->shadeSelectorUpdateOnRightClick->setChecked(cfg.readEntry("shadeSelectorUpdateOnRightClick", \
false)); + ui->shadeSelectorUpdateOnForeground->setChecked(cfg.readEntry("shadeSelectorUpdateOnForeground", \
false)); + ui->shadeSelectorUpdateOnLeftClick->setChecked(cfg.readEntry("shadeSelectorUpdateOnLeftClick", \
false)); + ui->shadeSelectorUpdateOnBackground->setChecked(cfg.readEntry("shadeSelectorUpdateOnBackground", \
true)); +
bool asGradient = cfg.readEntry("minimalShadeSelectorAsGradient", false);
if(asGradient) ui->minimalShadeSelectorAsGradient->setChecked(true);
else ui->minimalShadeSelectorAsColorPatches->setChecked(true);
@@ -308,6 +318,11 @@
ui->shadeSelectorTypeMinimal->setChecked(true);
ui->shadeSelectorTypeHidden->setChecked(true);
+ ui->shadeSelectorUpdateOnRightClick->setChecked(false);
+ ui->shadeSelectorUpdateOnForeground->setChecked(false);
+ ui->shadeSelectorUpdateOnLeftClick->setChecked(false);
+ ui->shadeSelectorUpdateOnBackground->setChecked(true);
+
// bool asGradient = false;
// if(asGradient) ui->minimalShadeSelectorAsGradient->setChecked(true);
// else
--- trunk/koffice/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector_triangle.h \
#1170432:1170433 @@ -29,11 +29,11 @@
explicit KisColorSelectorTriangle(KisColorSelector* parent);
QColor selectColor(int x, int y);
void setColor(const QColor &color);
-signals:
- void colorChanged(QColor color);
+
protected:
void paint(QPainter*);
bool isComponent(int x, int y) const;
+
private:
int triangleWidth() const;
int triangleHeight() const;
--- trunk/koffice/krita/plugins/extensions/dockers/colorselectorng/kis_minimal_shade_selector.cpp \
#1170432:1170433 @@ -26,6 +26,8 @@
#include <KComponentData>
#include <KGlobal>
+#include "KoResourceManager.h"
+
#include "kis_shade_selector_line.h"
@@ -90,6 +92,22 @@
setPopupBehaviour(false, false);
}
+void KisMinimalShadeSelector::resourceChanged(int key, const QVariant &v)
+{
+ if(m_colorUpdateAllowed==false)
+ return;
+
+ KConfigGroup cfg = KGlobal::config()->group("advancedColorSelector");
+
+ bool onForeground = cfg.readEntry("shadeSelectorUpdateOnForeground", false);
+ bool onBackground = cfg.readEntry("shadeSelectorUpdateOnBackground", true);
+
+ if ((key == KoCanvasResource::ForegroundColor && onForeground)
+ || (key == KoCanvasResource::BackgroundColor && onBackground)) {
+ setColor(findGeneratingColor(v.value<KoColor>()));
+ }
+}
+
void KisMinimalShadeSelector::paintEvent(QPaintEvent *)
{
QPainter painter(this);
--- trunk/koffice/krita/plugins/extensions/dockers/colorselectorng/kis_minimal_shade_selector.h \
#1170432:1170433 @@ -34,6 +34,9 @@
void setColor(const QColor& color);
void updateSettings();
+protected slots:
+ void resourceChanged(int key, const QVariant& v);
+
protected:
void paintEvent(QPaintEvent *);
virtual KisColorSelectorBase* createPopup() const;
--- trunk/koffice/krita/plugins/extensions/dockers/colorselectorng/kis_my_paint_shade_selector.cpp \
#1170432:1170433 @@ -20,8 +20,10 @@
*/
#include "kis_my_paint_shade_selector.h"
+
#include <cmath>
#include <cstdlib>
+
#include <QImage>
#include <QColor>
#include <QPainter>
@@ -31,9 +33,15 @@
#include <QtGlobal>
#include <QTimer>
+#include <KConfig>
+#include <KConfigGroup>
+#include <KComponentData>
+#include <KGlobal>
+
#include "KoColorSpace.h"
#include "KoColorSpaceRegistry.h"
#include "KoColor.h"
+#include "KoResourceManager.h"
#include <KDebug>
@@ -190,16 +198,23 @@
e->setAccepted(false);
KisColorSelectorBase::mousePressEvent(e);
- QRect widgetRect(0, 0, qMin(width(), height()), qMin(width(), height()));
- if(!e->isAccepted() && widgetRect.contains(e->pos())) {
+ if(!e->isAccepted()) {
QColor color = QColor(m_pixelCache.pixel(e->x(), e->y()));
color = findGeneratingColor(KoColor(color, \
KoColorSpaceRegistry::instance()->rgb8()));
ColorRole role=Foreground;
- if(e->buttons()&Qt::RightButton)
+ if(e->button()&Qt::RightButton)
role=Background;
+ KConfigGroup cfg = KGlobal::config()->group("advancedColorSelector");
+ bool onRightClick = cfg.readEntry("shadeSelectorUpdateOnRightClick", false);
+ bool onLeftClick = cfg.readEntry("shadeSelectorUpdateOnLeftClick", false);
+
+ if((e->button()&Qt::LeftButton && onLeftClick)
+ || (e->button()&Qt::RightButton && onRightClick)) {
setColor(color);
+ }
+
commitColor(KoColor(color, colorSpace()), color, role);
}
@@ -219,6 +234,22 @@
m_updateTimer->start();
}
+void KisMyPaintShadeSelector::resourceChanged(int key, const QVariant &v)
+{
+ if(m_colorUpdateAllowed==false)
+ return;
+
+ KConfigGroup cfg = KGlobal::config()->group("advancedColorSelector");
+
+ bool onForeground = cfg.readEntry("shadeSelectorUpdateOnForeground", false);
+ bool onBackground = cfg.readEntry("shadeSelectorUpdateOnBackground", true);
+
+ if ((key == KoCanvasResource::ForegroundColor && onForeground)
+ || (key == KoCanvasResource::BackgroundColor && onBackground)) {
+ setColor(findGeneratingColor(v.value<KoColor>()));
+ }
+}
+
inline int sqr(int x) {
return x*x;
}
--- trunk/koffice/krita/plugins/extensions/dockers/colorselectorng/kis_my_paint_shade_selector.h \
#1170432:1170433 @@ -37,6 +37,9 @@
public slots:
void setColor(const QColor& c);
+protected slots:
+ void resourceChanged(int key, const QVariant& v);
+
protected:
void paintEvent(QPaintEvent *);
void mousePressEvent(QMouseEvent *);
--- trunk/koffice/krita/plugins/extensions/dockers/colorselectorng/kis_shade_selector_line.cpp \
#1170432:1170433 @@ -32,6 +32,7 @@
#include "kis_canvas2.h"
+#include "kis_color_selector_base.h"
#include "kis_minimal_shade_selector.h"
#include <KDebug>
@@ -83,9 +84,6 @@
void KisShadeSelectorLine::setCanvas(KisCanvas2 *canvas)
{
m_canvas=canvas;
-
- connect(m_canvas->resourceManager(), SIGNAL(resourceChanged(int, const \
QVariant&)),
- this, SLOT(resourceChanged(int, const \
QVariant&)), Qt::UniqueConnection); }
QString KisShadeSelectorLine::toString() const
@@ -183,18 +181,21 @@
if(color==m_backgroundColor)
return;
- if(e->button()==Qt::LeftButton)
- m_canvas->resourceManager()->setForegroundColor(KoColor(color, \
KoColorSpaceRegistry::instance()->rgb8())); + KisColorSelectorBase* parent = \
dynamic_cast<KisColorSelectorBase*>(parentWidget());
+ KisColorSelectorBase::ColorRole role = KisColorSelectorBase::Foreground;
if(e->button()==Qt::RightButton)
- m_canvas->resourceManager()->setBackgroundColor(KoColor(color, \
KoColorSpaceRegistry::instance()->rgb8())); + role = \
KisColorSelectorBase::Background;
+ parent->commitColor(KoColor(color, KoColorSpaceRegistry::instance()->rgb8()), \
color, role); +
+ KConfigGroup cfg = KGlobal::config()->group("advancedColorSelector");
+
+ bool onRightClick = cfg.readEntry("shadeSelectorUpdateOnRightClick", false);
+ bool onLeftClick = cfg.readEntry("shadeSelectorUpdateOnLeftClick", false);
+
+ if((e->button()==Qt::LeftButton && onLeftClick) || (e->button()==Qt::RightButton \
&& onRightClick)) + \
parent->setColor(parent->findGeneratingColor(KoColor(color, \
KoColorSpaceRegistry::instance()->rgb8()))); +
e->accept();
}
-
-void KisShadeSelectorLine::resourceChanged(int key, const QVariant &v)
-{
- if (key == KoCanvasResource::ForegroundColor || key == \
KoCanvasResource::BackgroundColor) {
- setColor((v.value<KoColor>()).toQColor());
- }
-}
--- trunk/koffice/krita/plugins/extensions/dockers/colorselectorng/kis_shade_selector_line.h \
#1170432:1170433 @@ -54,9 +54,6 @@
void paintEvent(QPaintEvent *);
void mousePressEvent(QMouseEvent *);
-protected slots:
- void resourceChanged(int key, const QVariant &v);
-
private:
qreal m_hueDelta;
qreal m_saturationDelta;
--- trunk/koffice/krita/plugins/extensions/dockers/colorselectorng/wdg_color_selector_settings.ui \
#1170432:1170433 @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>494</width>
- <height>353</height>
+ <width>514</width>
+ <height>333</height>
</rect>
</property>
<property name="windowTitle">
@@ -206,19 +206,6 @@
<item row="0" column="1">
<widget class="KisColorSelectorComboBox" name="colorSelectorConfiguration"/>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Color Harmonies</string>
- </property>
- <property name="buddy">
- <cstring>comboBox_3</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QComboBox" name="comboBox_3"/>
- </item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
@@ -263,25 +250,35 @@
<property name="title">
<string>Update shade selector</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_6">
- <item>
- <widget class="QCheckBox" name="checkBox">
+ <layout class="QGridLayout" name="gridLayout_6">
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="shadeSelectorUpdateOnRightClick">
<property name="text">
<string>on right click</string>
</property>
</widget>
</item>
- <item>
- <widget class="QCheckBox" name="checkBox_2">
+ <item row="0" column="1">
+ <widget class="QCheckBox" name="shadeSelectorUpdateOnForeground">
<property name="text">
+ <string>on foreground color selector change</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="shadeSelectorUpdateOnLeftClick">
+ <property name="text">
<string>on left click</string>
</property>
</widget>
</item>
- <item>
- <widget class="QCheckBox" name="checkBox_3">
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="shadeSelectorUpdateOnBackground">
<property name="text">
- <string>on color selector change</string>
+ <string>on background color change</string>
</property>
<property name="checked">
<bool>true</bool>
@@ -397,8 +394,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>265</width>
- <height>114</height>
+ <width>280</width>
+ <height>124</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic