Bug 73661 - Single-Shot window doesn't correctly bind ENTER
Summary: Single-Shot window doesn't correctly bind ENTER
Status: RESOLVED FIXED
Alias: None
Product: kopete
Classification: Applications
Component: Chat Window (show other bugs)
Version: 0.8.0
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Kopete Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-28 07:41 UTC by Don Curtis
Modified: 2004-02-15 16:54 UTC (History)
0 users

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 Don Curtis 2004-01-28 07:41:32 UTC
Version:           0.8.0 RC1 (using KDE KDE 3.2.0)
Installed from:    Gentoo Packages
Compiler:          gcc (GCC) 3.3.2 20031218 
OS:          Linux

I selected to do the single-shot chat style however i went in to the shortcuts for a single-shot window and bound enter.  however its bound and when i hit enter it does not send even though it IS bound.  ctrl-enter does work though so i don't understand.
Comment 1 jstuart 2004-02-12 19:55:09 UTC
This is confirmed in kopete 0.80.
Comment 2 Richard Smith 2004-02-15 16:41:25 UTC
Mine!
Comment 3 Richard Smith 2004-02-15 16:54:15 UTC
CVS commit by lilachaze: 

Make enter and return work as keyboard shortcuts in the single-shot message
window. This is a hack, but I couldn't find a better way to divert the
keypresses from the text input widget, so I stole this idea from the chat
window.
CCMAIL: 73661-done@bugs.kde.org


  M +34 -0     kopeteemailwindow.cpp   1.35
  M +1 -0      kopeteemailwindow.h   1.7


--- kdenetwork/kopete/kopete/chatwindow/kopeteemailwindow.cpp  #1.34:1.35
@@ -30,4 +30,5 @@
 #include <kcolordialog.h>
 #include <kconfig.h>
+#include <kcursor.h>
 #include <kdebug.h>
 #include <kdeversion.h>
@@ -214,4 +215,6 @@ KopeteEmailWindow::KopeteEmailWindow( Ko
         m_type = KopeteMessage::Email;
 
+        d->txtEntry->installEventFilter( this );
+        KCursor::setAutoHideCursor( d->txtEntry, true, true );
 }
 
@@ -296,4 +299,35 @@ void KopeteEmailWindow::initActions(void
 }
 
+bool KopeteEmailWindow::eventFilter( QObject *o, QEvent *e )
+{
+        if ( o->inherits( "KTextEdit" ) )
+                KCursor::autoHideEventFilter( o, e );
+
+        if( e->type() == QEvent::KeyPress )
+        {
+                QKeyEvent *event = static_cast<QKeyEvent*>( e );
+                KKey key( event );
+
+                // NOTE:
+                // shortcut.contains( key ) doesn't work. It was the old way we used to do it, but it is incorrect
+                // because if you have a multi-key shortcut then pressing any of the keys in
+                // that shortcut individually causes the shortcut to be activated.
+
+                if( d->chatSend->isEnabled() )
+                {
+                        for( uint i = 0; i < d->chatSend->shortcut().count(); i++ )
+                        {
+                                if( key == d->chatSend->shortcut().seq(i).key(0) )
+                                {
+                                        sendMessage();
+                                        return true;
+                                }
+                        }
+                }
+        }
+
+        return false;
+}
+
 void KopeteEmailWindow::slotViewToolBar()
 {

--- kdenetwork/kopete/kopete/chatwindow/kopeteemailwindow.h  #1.6:1.7
@@ -79,4 +79,5 @@ protected:
         virtual bool queryExit();
         virtual void windowActivationChange( bool activated );
+        virtual bool KopeteEmailWindow::eventFilter( QObject *o, QEvent *e );
 
 private slots: