[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:16:03 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=4eb2d29

The following commit has been merged in the master branch:
commit 4eb2d29f0b3df156f80bfbbc2d5a9201bbfc768f
Author: Daniele Elmo Domenichelli <daniele.domenichelli at gmail.com>
Date:   Thu Aug 5 14:33:29 2010 +0000

    Add an eventFilter to ui->sendMessageBox to send message when enter or return key is pressed
    
    svn path=/trunk/playground/network/telepathy-chat-handler/; revision=1159515
---
 lib/chatwindow.cpp | 21 +++++++++++++++++++++
 lib/chatwindow.h   | 13 +++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/lib/chatwindow.cpp b/lib/chatwindow.cpp
index 6941b5e..d445c67 100644
--- a/lib/chatwindow.cpp
+++ b/lib/chatwindow.cpp
@@ -21,6 +21,7 @@
 #include "ui_chatwindow.h"
 #include "telepathychatmessageinfo.h"
 #include "telepathychatinfo.h"
+#include <QKeyEvent>
 
 
 ChatWindow::ChatWindow(ChatConnection* chat, QWidget *parent) :
@@ -41,8 +42,13 @@ ChatWindow::ChatWindow(ChatConnection* chat, QWidget *parent) :
     connect(m_chatConnection->channel().data(), SIGNAL(messageSent(Tp::Message, Tp::MessageSendingFlags, QString)), SLOT(handleMessageSent(Tp::Message, Tp::MessageSendingFlags, QString)));
     connect(m_chatConnection->channel().data(), SIGNAL(chatStateChanged(Tp::ContactPtr, ChannelChatState)), SLOT(updateChatStatus(Tp::ContactPtr, ChannelChatState)));
     connect(ui->sendMessageButton, SIGNAL(released()), SLOT(sendMessage()));
+
+    messageBoxEventFilter = new MessageBoxEventFilter(this);
+    ui->sendMessageBox->installEventFilter(messageBoxEventFilter);
+    connect(messageBoxEventFilter, SIGNAL(returnKeyPressed()), SLOT(sendMessage()));
 }
 
+
 ChatWindow::~ChatWindow()
 {
     delete ui;
@@ -155,3 +161,18 @@ void ChatWindow::updateEnabledState(bool enable)
         }
     }
 }
+
+bool MessageBoxEventFilter::eventFilter(QObject *obj, QEvent *event)
+{
+    if (event->type() == QEvent::KeyPress) {
+        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+        if(keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) {
+            if(!keyEvent->modifiers()) {
+                Q_EMIT returnKeyPressed();
+                return true;
+            }
+        }
+    }
+    // standard event processing
+    return QObject::eventFilter(obj, event);
+}
diff --git a/lib/chatwindow.h b/lib/chatwindow.h
index e37a9d3..f97c7b7 100644
--- a/lib/chatwindow.h
+++ b/lib/chatwindow.h
@@ -30,6 +30,18 @@ namespace Ui
 class ChatWindow;
 }
 
+class MessageBoxEventFilter : public QObject
+{
+    Q_OBJECT
+public:
+    MessageBoxEventFilter(QObject* parent = 0) : QObject(parent) {};
+    virtual ~MessageBoxEventFilter() {}
+protected:
+    bool eventFilter(QObject *obj, QEvent *event);
+Q_SIGNALS:
+    void returnKeyPressed();
+};
+
 class ChatWindow : public QWidget
 {
     Q_OBJECT
@@ -64,6 +76,7 @@ private:
 
     //mark as true when the chat window has been set up.
     bool m_initialised;
+    MessageBoxEventFilter* messageBoxEventFilter;
 };
 
 #endif // CHATWINDOW_H

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list