Bug 138429 - cannot add text to picture after cancel
Summary: cannot add text to picture after cancel
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Unclassified
Component: General (show other bugs)
Version: 1.6.1
Platform: openSUSE RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Halla Rempt
URL:
Keywords:
: 139013 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-12-06 07:53 UTC by Brice Hunt
Modified: 2006-12-30 09:12 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brice Hunt 2006-12-06 07:53:06 UTC
Version:           1.6.1 (using KDE KDE 3.5.5)
Installed from:    SuSE RPMs
OS:                Linux

Steps to reproduce:
1. Open Krita
2. Open a jpeg image.
3. Choose the text tool from the tool bar.
4. Click on the image to add text.
5. Click cancel in the dialog to add text.
6. The text tool will no longer work.

Expected behavior:
The text tool should continue to work no matter how many times the dialog is canceled.
Comment 1 Brice Hunt 2006-12-06 07:54:40 UTC
Clarification in item number 5 to reproduce the bug:
Should read click the "Cancel" button in the new text dialog box.
Comment 2 Halla Rempt 2006-12-06 08:21:44 UTC
Ah, bah. This must be related to my fixes for http://bugs.kde.org/show_bug.cgi?id=136151 :-(.
Comment 3 Halla Rempt 2006-12-06 08:22:25 UTC
Cyrille's fixes, actually. But I'll look at it.
Comment 4 Halla Rempt 2006-12-30 09:11:26 UTC
SVN commit 617757 by rempt:

BUG: 138429 Simple fix for this bug.
Also: add keyboard handling to the move tool for pixel-precise layer moving


 M  +72 -3     kis_tool_move.cc  
 M  +14 -1     kis_tool_move.h  
 M  +3 -2      kis_tool_text.cc  


--- branches/koffice/1.6/koffice/krita/plugins/tools/defaulttools/kis_tool_move.cc #617756:617757
@@ -39,10 +39,14 @@
 
 KisToolMove::KisToolMove()
     : super(i18n("Move Tool"))
+    , m_subject( 0 )
+    , m_keyEvent( 0 )
 {
     setName("tool_move");
-    m_subject = 0;
+
     setCursor(KisCursor::moveCursor());
+    m_repeatTimer = new QTimer(this);
+    connect( m_repeatTimer, SIGNAL( timeout() ), this, SLOT( slotMove() ) );
 }
 
 KisToolMove::~KisToolMove()
@@ -66,14 +70,13 @@
         if (!img || !(dev = img->activeLayer()))
             return;
 
-        m_dragStart = pos;
         m_strategy.startDrag(pos);
     }
 }
 
 void KisToolMove::move(KisMoveEvent *e)
 {
-    if (m_subject) {
+    if (m_subject  && e->state() == QMouseEvent::LeftButton) {
         QPoint pos = e->pos().floorQPoint();
         if((e->state() & Qt::AltButton) || (e->state() & Qt::ControlButton)) {
             if(fabs(pos.x() - m_dragStart.x()) > fabs(pos.y() - m_dragStart.y()))
@@ -110,3 +113,69 @@
     }
 }
 
+
+void KisToolMove::keyPress( QKeyEvent *e )
+{
+    m_keyEvent = e;
+
+   if (m_subject) {
+
+        KisImageSP img = m_subject->currentImg();
+        KisLayerSP dev;
+
+        if (!img || !(dev = img->activeLayer()))
+            return;
+
+        m_dragStart = QPoint( 0, 0 );
+        m_strategy.startDrag( m_dragStart );
+        m_steps = 1;
+        m_repeatTimer->start(200);
+
+    }
+}
+
+void KisToolMove::keyRelease(QKeyEvent *)
+{
+    m_repeatTimer->stop();
+
+    if ( m_subject && m_keyEvent) {
+
+        if ( m_keyEvent->key() == Qt::Key_Left ) {
+            m_strategy.endDrag(QPoint( -m_steps, 0 ));
+        }
+        else if ( m_keyEvent->key() == Qt::Key_Right ) {
+            m_strategy.endDrag(QPoint(m_steps, 0) );
+        }
+        else if ( m_keyEvent->key() == Qt::Key_Up ) {
+            m_strategy.endDrag(QPoint(0, -m_steps) );
+        }
+        else if ( m_keyEvent->key() == Qt::Key_Down ) {
+            m_strategy.endDrag(QPoint(0, m_steps) );
+        }
+    }
+    m_steps = 0;
+    m_keyEvent = 0;
+
+}
+
+void KisToolMove::slotMove()
+{
+    if (m_subject  && m_keyEvent) {
+
+        if ( m_keyEvent->key() == Qt::Key_Left ) {
+            m_strategy.drag(QPoint(-m_steps, 0) );
+        }
+        else if ( m_keyEvent->key() == Qt::Key_Right ) {
+            m_strategy.drag(QPoint(m_steps, 0) );
+        }
+        else if ( m_keyEvent->key() == Qt::Key_Up ) {
+            m_strategy.drag(QPoint(0, -m_steps) );
+        }
+        else if ( m_keyEvent->key() == Qt::Key_Down ) {
+            m_strategy.drag(QPoint(0, m_steps) );
+        }
+
+        ++m_steps;
+    }
+
+}
--- branches/koffice/1.6/koffice/krita/plugins/tools/defaulttools/kis_tool_move.h #617756:617757
@@ -21,11 +21,14 @@
 #ifndef KIS_TOOL_MOVE_H_
 #define KIS_TOOL_MOVE_H_
 
+#include <qtimer.h>
+
 #include "kis_strategy_move.h"
 #include "kis_tool_non_paint.h"
 #include "kis_tool_factory.h"
 
-// XXX: Moving is not nearly smooth enough!
+class QTimer;
+
 class KisToolMove : public KisToolNonPaint {
 
     typedef KisToolNonPaint super;
@@ -46,11 +49,21 @@
     virtual void buttonPress(KisButtonPressEvent *e);
     virtual void move(KisMoveEvent *e);
     virtual void buttonRelease(KisButtonReleaseEvent *e);
+    virtual void keyPress(QKeyEvent *e);
+    virtual void keyRelease(QKeyEvent *e);
 
+private slots:
+
+    void slotMove();
+
 private:
+
     KisCanvasSubject *m_subject;
     KisStrategyMove m_strategy;
     QPoint m_dragStart;
+    QTimer * m_repeatTimer;
+    QKeyEvent * m_keyEvent;
+    int m_steps;
 };
 
 
--- branches/koffice/1.6/koffice/krita/plugins/tools/defaulttools/kis_tool_text.cc #617756:617757
@@ -83,7 +83,6 @@
 
     if (m_subject && e->button() == QMouseEvent::LeftButton) {
         if(!m_wasPressed) return;
-        m_windowIsBeingShown = true;
         m_wasPressed = false;
         KisImageSP img = m_subject->currentImg();
 
@@ -91,8 +90,10 @@
         bool ok;
         QString text = KInputDialog::getText(i18n("Font Tool"), i18n("Enter text:"),
              QString::null, &ok);
-        if (!ok)
+        if (!ok) {
+            m_windowIsBeingShown = false;
             return;
+        }
 
         KisUndoAdapter *undoAdapter = img->undoAdapter();
         if (undoAdapter) {
Comment 5 Halla Rempt 2006-12-30 09:12:53 UTC
*** Bug 139013 has been marked as a duplicate of this bug. ***