On Thursday 22 June 2006 11:38, Georgi Chulkov wrote:
> 1) Is it possible to send messages with Enter and insert a newline with
> Ctrl-enter, which is the opposite of the default.

Attaching a patch that makes this possible. It's a bit rough atm (not 
configurable at runtime), but i'll fix that as soon as i have some time to 
spare. But please test the patch and report back to the list.

// Erik
Index: mledit.cpp
===================================================================
--- mledit.cpp	(revision 4451)
+++ mledit.cpp	(working copy)
@@ -47,12 +47,6 @@
     setWordWrap(NoWrap);
   }
 
-  QAccel *a = new QAccel( this );
-  a->connectItem(a->insertItem(Key_Enter + CTRL),
-                 this, SIGNAL(signal_CtrlEnterPressed()));
-  a->connectItem(a->insertItem(Key_Return + CTRL),
-                 this, SIGNAL(signal_CtrlEnterPressed()));
-
   if (editFont) QWidget::setFont(*editFont, true);
 }
 
@@ -154,8 +148,30 @@
 
 void MLEditWrap::keyPressEvent( QKeyEvent *e )
 {
-  if(e->state() & ControlButton) {
-    switch(e->key()) {
+  const bool m_sendWithCtrlEnter = false;
+
+  const bool isEnter = (e->key() == Key_Enter || e->key() == Key_Return);
+  const bool isCtrl  = (e->state() & ControlButton);
+
+  if (isEnter)
+  {
+    if ((m_sendWithCtrlEnter && isCtrl) || (!m_sendWithCtrlEnter && !isCtrl))
+    {
+      emit signal_CtrlEnterPressed();
+      return;
+    }
+
+    if (!m_sendWithCtrlEnter && isCtrl)
+    {
+      QKeyEvent enter(QEvent::KeyPress, e->key(), e->ascii(), Qt::NoButton, e->text(), e->isAutoRepeat(), e->count());
+      return QMultiLineEdit::keyPressEvent(&enter);
+    }
+  }
+
+  if (isCtrl)
+  {
+    switch (e->key())
+    {
     case Key_W:
       cursorWordBackward(true);
       del();
@@ -169,6 +185,7 @@
       break;
     default:
       QMultiLineEdit::keyPressEvent(e);
+      break;
     }
     return;
   }
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Licq-Main mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/licq-main

Reply via email to