Review request for implementation of https://bugs.kde.org/show_bug.cgi?id=138153

View: New views
3 Messages — Rating Filter:   Alert me  

Review request for implementation of https://bugs.kde.org/show_bug.cgi?id=138153

by Bugzilla from boud@valdyas.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

This is an implementation of wish 138153, Use keyboard to switch between
foreground and background color. It adds to actions to KisTool to swap fg and
bg color and to reset fg/bg to defaults. It uses the X and D shortcuts
proposed by Alan Horkan. Since it's implemented in the base for all krita
tools, it's still possible to type x and d in the text tool :-)
--
Boudewijn Rempt | http://www.valdyas.org

[0001-Implement-wish-138153-Use-keyboard-to-switch-betwee.patch]

From d628261d34e340c8c703ca7174e4134e7dcd42bc Mon Sep 17 00:00:00 2001
From: Boudewijn Rempt <boud@...>
Date: Sun, 8 Nov 2009 11:09:55 +0100
Subject: [PATCH] Implement wish 138153: Use keyboard to switch between foreground and background color

Add two actions to KisTool, with the default shortcuts
as proposed by Alan Horkan to swap the fg and bg color
and to reset them.
---
 krita/ui/tool/kis_tool.cc |   32 ++++++++++++++++++++++++++++++++
 krita/ui/tool/kis_tool.h  |    4 ++++
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/krita/ui/tool/kis_tool.cc b/krita/ui/tool/kis_tool.cc
index 96adaac..16ae196 100644
--- a/krita/ui/tool/kis_tool.cc
+++ b/krita/ui/tool/kis_tool.cc
@@ -22,7 +22,10 @@
 #include <QWidget>
 
 #include <klocale.h>
+#include <kaction.h>
 
+#include <KoColorSpaceRegistry.h>
+#include <KoColor.h>
 #include <KoCanvasBase.h>
 #include <KoShapeManager.h>
 #include <KoTool.h>
@@ -77,6 +80,10 @@ struct KisTool::Private {
     float currentExposure;
     KisFilterConfiguration * currentGenerator;
     QWidget* optionWidget;
+
+    KAction* toggleFgBg;
+    KAction* resetFgBg;
+
 };
 
 KisTool::KisTool(KoCanvasBase * canvas, const QCursor & cursor)
@@ -88,6 +95,16 @@ KisTool::KisTool(KoCanvasBase * canvas, const QCursor & cursor)
 
     connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(resetCursorStyle()));
 
+    d->toggleFgBg = new KAction(i18n("Swap Foreground and Background Color"), this);
+    d->toggleFgBg->setShortcut(QKeySequence(Qt::Key_X));
+    connect(d->toggleFgBg, SIGNAL(triggered()), this, SLOT(slotToggleFgBg()));
+    addAction("toggle_fg_bg", d->toggleFgBg);
+
+    d->resetFgBg = new KAction(i18n("Reset Foreground and Background Color"), this);
+    d->resetFgBg->setShortcut(QKeySequence(Qt::Key_D));
+    connect(d->resetFgBg, SIGNAL(triggered()), this, SLOT(slotResetFgBg()));
+    addAction("reset_fg_bg", d->resetFgBg);
+
 }
 
 KisTool::~KisTool()
@@ -414,5 +431,20 @@ void KisTool::resetCursorStyle()
 }
 
 
+void KisTool::slotToggleFgBg()
+{
+    KoCanvasResourceProvider* resourceProvider = canvas()->resourceProvider();
+    KoColor c = resourceProvider->foregroundColor();
+    resourceProvider->setForegroundColor(resourceProvider->backgroundColor());
+    resourceProvider->setBackgroundColor(c);
+}
+
+void KisTool::slotResetFgBg()
+{
+    KoCanvasResourceProvider* resourceProvider = canvas()->resourceProvider();
+    resourceProvider->setForegroundColor(KoColor(Qt::black, KoColorSpaceRegistry::instance()->rgb8()));
+    resourceProvider->setBackgroundColor(KoColor(Qt::white, KoColorSpaceRegistry::instance()->rgb8()));
+}
+
 #include "kis_tool.moc"
 
diff --git a/krita/ui/tool/kis_tool.h b/krita/ui/tool/kis_tool.h
index c706c56..e55604b 100644
--- a/krita/ui/tool/kis_tool.h
+++ b/krita/ui/tool/kis_tool.h
@@ -149,6 +149,10 @@ protected slots:
      */
     virtual void resetCursorStyle();
 
+private slots:
+
+    void slotToggleFgBg();
+    void slotResetFgBg();
 
 private:
     PaintMode m_outlinePaintMode;
--
1.6.0.2



_______________________________________________
kimageshop mailing list
kimageshop@...
https://mail.kde.org/mailman/listinfo/kimageshop

Re: Review request for implementation of https://bugs.kde.org/show_bug.cgi?id=138153

by Bugzilla from lukast.dev@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sunday 08 November 2009 11:13:27 Boudewijn Rempt wrote:
> Hi,
>
> This is an implementation of wish 138153, Use keyboard to switch between
> foreground and background color. It adds to actions to KisTool to swap fg
>  and bg color and to reset fg/bg to defaults. It uses the X and D shortcuts
>  proposed by Alan Horkan. Since it's implemented in the base for all krita
>  tools, it's still possible to type x and d in the text tool :-)
>

Seems fine
+1 from me
_______________________________________________
kimageshop mailing list
kimageshop@...
https://mail.kde.org/mailman/listinfo/kimageshop

Re: Review request for implementation of https://bugs.kde.org/show_bug.cgi?id=138153

by Bugzilla from boud@valdyas.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sunday 08 November 2009, Boudewijn Rempt wrote:
> Hi,
>
> This is an implementation of wish 138153, Use keyboard to switch between
> foreground and background color. It adds to actions to KisTool to swap fg
>  and bg color and to reset fg/bg to defaults. It uses the X and D shortcuts
>  proposed by Alan Horkan. Since it's implemented in the base for all krita
>  tools, it's still possible to type x and d in the text tool :-)
>

I've found a problem with this patch: if you once switch between mouse and
stylus, the action gets added a second time, causing a conflict. I'm
investigating KotoolManager to see if it's a bug in there.

--
Boudewijn Rempt | http://www.valdyas.org
_______________________________________________
kimageshop mailing list
kimageshop@...
https://mail.kde.org/mailman/listinfo/kimageshop