r14247 by fschmid - Added the possibility to remove gradient stops with "Del" or "Backspace" key, thus resolving Bug #8062: "wish: suggested improvements for removing colour stops"

scribus-commit scribus-commit at lists.scribus.net
Wed Oct 28 11:55:23 CET 2009


Revision: 14247
Author: fschmid
Date: 2009-10-28T06:50:15.480406Z
Commit message: Added the possibility to remove gradient stops with "Del" or "Backspace" key, thus resolving Bug #8062: "wish: suggested improvements for removing colour stops"

Changeset: 
M  /trunk/Scribus/scribus/ui/gradientpreview.cpp
M  /trunk/Scribus/scribus/ui/gradientpreview.h

Diffs:
Index: scribus/ui/gradientpreview.h
===================================================================
--- scribus/ui/gradientpreview.h	(revision 14246)
+++ scribus/ui/gradientpreview.h	(revision 14247)
@@ -28,6 +28,7 @@
 #include <QFrame>
 #include <QPaintEvent>
 #include <QMouseEvent>
+#include <QKeyEvent>
 #include <QVBoxLayout>
 #include <QHBoxLayout>
 
@@ -44,6 +45,7 @@
 	GradientPreview(QWidget *pa);
 	~GradientPreview() {};
 	void paintEvent(QPaintEvent *e);
+	void keyPressEvent(QKeyEvent *);
 	void mousePressEvent(QMouseEvent *m);
 	void mouseReleaseEvent(QMouseEvent *);
 	void mouseMoveEvent(QMouseEvent *m);
Index: scribus/ui/gradientpreview.cpp
===================================================================
--- scribus/ui/gradientpreview.cpp	(revision 14246)
+++ scribus/ui/gradientpreview.cpp	(revision 14247)
@@ -48,6 +48,7 @@
 	setMinimumSize(QSize(200, 70));
 	setMaximumSize(QSize(3000, 70));
 	setMouseTracking(true);
+	setFocusPolicy(Qt::ClickFocus);
 	Mpressed = false;
 	outside = true;
 	onlyselect = true;
@@ -118,6 +119,27 @@
 	QFrame::paintEvent(e);
 }
 
+void GradientPreview::keyPressEvent(QKeyEvent *e)
+{
+	if (isEditable)
+	{
+		if(e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace)
+		{
+			if ((ActStop > 0) && (ActStop != static_cast<int>(StopM.count()-1)))
+			{
+				onlyselect = false;
+				fill_gradient.removeStop(ActStop);
+				ActStop = 0;
+				repaint();
+				QList<VColorStop*> cstops = fill_gradient.colorStops();
+				emit selectedColor(cstops.at(ActStop)->name, cstops.at(ActStop)->shade);
+				emit currTrans(cstops.at(ActStop)->opacity);
+				emit currStep(cstops.at(ActStop)->rampPoint);
+			}
+		}
+	}
+}
+
 void GradientPreview::mousePressEvent(QMouseEvent *m)
 {
 	QRect fpo;




More information about the scribus-commit mailing list