[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Btelepathy-chat-handler=5D_lib=3A_Fix_activation_of_?=
From:       Francesco Nwokeka <francesco.nwokeka () gmail ! com>
Date:       2011-04-02 0:38:27
Message-ID: 20110402003827.D98A1A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit 1a0bad7e2d5aa289db783e49ae7fb9520ed88542 by Francesco Nwokeka.
Committed on 02/04/2011 at 02:36.
Pushed by nwokeka into branch 'master'.

Fix activation of the "Find" shortcut in the chatwindow

The "find" shortcut wasn't being called anymore because ovveridden by the \
introduction of KTextEdit for the inheritance of "ChatTextEdit". So what I basically \
did was to overload the "keyPressEvent(QKeyEvent* e)" and emit a custom signal.

Reviewed by Dario Freddi

M  +8    -1    lib/chat-text-edit.cpp     
M  +6    -0    lib/chat-text-edit.h     
M  +1    -0    lib/chat-widget.cpp     

http://commits.kde.org/telepathy-chat-handler/1a0bad7e2d5aa289db783e49ae7fb9520ed88542


diff --git a/lib/chat-text-edit.cpp b/lib/chat-text-edit.cpp
index a24c7ff..0462810 100644
--- a/lib/chat-text-edit.cpp
+++ b/lib/chat-text-edit.cpp
@@ -33,7 +33,7 @@ ChatTextEdit::ChatTextEdit(QWidget *parent) :
     setCheckSpellingEnabled(true);
     enableFindReplace(false);
     setMinimumHeight(0);
-    
+
     connect(this, SIGNAL(textChanged()), SLOT(recalculateSize()));
 }
 
@@ -65,6 +65,13 @@ QSize ChatTextEdit::sizeHint() const
     return sh;
 }
 
+void ChatTextEdit::keyPressEvent(QKeyEvent* e)
+{
+    if (e->matches(QKeySequence::Find)) {
+        emit findTextShortcutPressed();
+    }
+}
+
 void ChatTextEdit::resizeEvent(QResizeEvent* e)
 {
     QTextEdit::resizeEvent(e);
diff --git a/lib/chat-text-edit.h b/lib/chat-text-edit.h
index ba46e39..4f553da 100644
--- a/lib/chat-text-edit.h
+++ b/lib/chat-text-edit.h
@@ -33,6 +33,9 @@ public:
     QSize sizeHint() const;
 
 protected:
+    /// HACK this method is overidden to catch the ctrl+f signal for the \
toggleSearchBar. +    void keyPressEvent(QKeyEvent *e);
+
     // reimplemented
     void resizeEvent(QResizeEvent*);
 
@@ -40,6 +43,9 @@ private slots:
     void recalculateSize();
     void updateScrollBar();
 
+signals:
+    void findTextShortcutPressed();
+
 public slots:
     /** wraps setFontWeight to a simple on/off bold) */
     void setFontBold(bool);
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index 33bd5c9..af7edff 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -235,6 +235,7 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, \
                QWidget *parent)
     connect(windowEventFilter, SIGNAL(windowActivated()), SLOT(windowActivated()));
 
     // find text in chat
+    connect(d->ui.sendMessageBox, SIGNAL(findTextShortcutPressed()), this, \
                SLOT(toggleSearchBar()));
     connect(d->ui.searchBar, SIGNAL(findTextSignal(QString,QWebPage::FindFlags)), \
                this, SLOT(findTextInChat(QString,QWebPage::FindFlags)));
     connect(d->ui.searchBar, SIGNAL(findNextSignal(QString,QWebPage::FindFlags)), \
                this, SLOT(findNextTextInChat(QString,QWebPage::FindFlags)));
     connect(d->ui.searchBar, \
SIGNAL(findPreviousSignal(QString,QWebPage::FindFlags)), this, \
SLOT(findPreviousTextInChat(QString,QWebPage::FindFlags)));


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic