[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:20:20 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=e8df9c8
The following commit has been merged in the master branch:
commit e8df9c842805dd449704f85cb8e8ab23c6341d5b
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Tue Oct 18 20:20:59 2011 +0100
Tidy up all key handling code.
Remove signals and slots, and use event propogation where it makes more sense to pass events to parents.
REVIEW: 102908
BUG: 277231
BUG: 284531
---
lib/adium-theme-view.cpp | 5 -----
lib/adium-theme-view.h | 1 -
lib/chat-text-edit.cpp | 36 ++++++++++++++++++++++++++++++------
lib/chat-text-edit.h | 5 ++---
lib/chat-widget.cpp | 23 ++++++++++++++---------
lib/chat-widget.h | 1 -
6 files changed, 46 insertions(+), 25 deletions(-)
diff --git a/lib/adium-theme-view.cpp b/lib/adium-theme-view.cpp
index 9edfdbe..804ed0a 100644
--- a/lib/adium-theme-view.cpp
+++ b/lib/adium-theme-view.cpp
@@ -488,11 +488,6 @@ QString AdiumThemeView::replaceMessageKeywords(QString &htmlTemplate, const Adiu
return htmlTemplate;
}
-void AdiumThemeView::onScrollEvent(QKeyEvent* e)
-{
- keyPressEvent(e);
-}
-
void AdiumThemeView::appendNewMessage(QString &html)
{
//by making the JS return false evaluateJavaScript is a _lot_ faster, as it has nothing to convert to QVariant.
diff --git a/lib/adium-theme-view.h b/lib/adium-theme-view.h
index 0403c8c..d42812c 100644
--- a/lib/adium-theme-view.h
+++ b/lib/adium-theme-view.h
@@ -80,7 +80,6 @@ public Q_SLOTS:
void addStatusMessage(const AdiumThemeStatusInfo&);
void onLinkClicked(const QUrl &);
void onOpenLinkActionTriggered();
- void onScrollEvent(QKeyEvent*);
protected:
virtual void contextMenuEvent(QContextMenuEvent *event);
diff --git a/lib/chat-text-edit.cpp b/lib/chat-text-edit.cpp
index a81f828..79ef3d8 100644
--- a/lib/chat-text-edit.cpp
+++ b/lib/chat-text-edit.cpp
@@ -24,6 +24,8 @@
#include <QtGui/QAction>
#include <QtCore/QTimer>
+#include <KStandardShortcut>
+
ChatTextEdit::ChatTextEdit(QWidget *parent) :
KTextEdit(parent)
{
@@ -70,22 +72,44 @@ QSize ChatTextEdit::sizeHint() const
void ChatTextEdit::keyPressEvent(QKeyEvent* e)
{
- if (e->key()==Qt::Key_Enter && !e->modifiers()) {
+ if (e->key()==Qt::Key_Return && !e->modifiers()) {
Q_EMIT returnKeyPressed();
+ return;
}
- if (e->key() == Qt::Key_PageUp ||
- e->key() == Qt::Key_PageDown) {
- Q_EMIT scrollEventRecieved(e);
+ if (e->matches(QKeySequence::Copy)) {
+ if (!textCursor().hasSelection()) {
+ QWidget::keyReleaseEvent(e); //skip internal trapping, and pass to parent.
+ return;
+ }
}
- if (e->matches(QKeySequence::Find)) {
- Q_EMIT findTextShortcutPressed();
+ if (e->key() == Qt::Key_PageUp ||
+ e->key() == Qt::Key_PageDown) {
+ QWidget::keyPressEvent(e); //pass to parent.
+ return;
}
KTextEdit::keyPressEvent(e);
}
+bool ChatTextEdit::event(QEvent *e)
+{
+ if (e->type() == QEvent::ShortcutOverride) {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(e);
+ const int key = keyEvent->key() | keyEvent->modifiers();
+ if (KStandardShortcut::find().contains(key)) {
+ return false; //never catch "find" sequence.
+ }
+ if (KStandardShortcut::copy().contains(key)) {
+ if (!textCursor().hasSelection()) {
+ return false; //don't catch "copy" sequence if there is no selected text.
+ }
+ }
+ }
+ return KTextEdit::event(e);
+}
+
void ChatTextEdit::resizeEvent(QResizeEvent* e)
{
KTextEdit::resizeEvent(e);
diff --git a/lib/chat-text-edit.h b/lib/chat-text-edit.h
index 31bdf97..3e2dec0 100644
--- a/lib/chat-text-edit.h
+++ b/lib/chat-text-edit.h
@@ -33,9 +33,10 @@ public:
QSize sizeHint() const;
protected:
- /// HACK this method is overridden to catch the ctrl+f signal for the toggleSearchBar.
void keyPressEvent(QKeyEvent *e);
+ bool event(QEvent *);
+
// reimplemented
void resizeEvent(QResizeEvent*);
@@ -45,8 +46,6 @@ private Q_SLOTS:
Q_SIGNALS:
void returnKeyPressed();
- void findTextShortcutPressed();
- void scrollEventRecieved(QKeyEvent*);
public Q_SLOTS:
/** wraps setFontWeight to a simple on/off bold) */
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index 393f6a0..8fe4eeb 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -170,8 +170,6 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, const Tp::AccountPtr
connect(d->ui.sendMessageBox, SIGNAL(returnKeyPressed()), SLOT(sendMessage()));
connect(d->ui.sendButton, SIGNAL(clicked()), SLOT(sendMessage()));
- // 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)));
@@ -179,9 +177,6 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, const Tp::AccountPtr
connect(this, SIGNAL(searchTextComplete(bool)), d->ui.searchBar, SLOT(onSearchTextComplete(bool)));
- // to make PgUp and PgDown keys work properly
- connect(d->ui.sendMessageBox, SIGNAL(scrollEventRecieved(QKeyEvent*)), d->ui.chatArea, SLOT(onScrollEvent(QKeyEvent*)));
-
// initialize LogManager
d->logManager = new LogManager(account, channel->targetContact(), this);
d->logManager->setFetchAmount(3);
@@ -289,12 +284,23 @@ Tp::TextChannelPtr ChatWidget::textChannel() const
void ChatWidget::keyPressEvent(QKeyEvent* e)
{
+ if (e->matches(QKeySequence::Copy)) {
+ d->ui.chatArea->triggerPageAction(QWebPage::Copy);
+ return;
+ }
+
if (e->key() == Qt::Key_Escape && d->ui.searchBar->isVisible()) {
d->ui.searchBar->toggleView(false);
+ return;
}
- else {
- QWidget::keyPressEvent(e);
+
+ if (e->key() == Qt::Key_PageUp ||
+ e->key() == Qt::Key_PageDown) {
+ d->ui.chatArea->event(e);
+ return;
}
+
+ QWidget::keyPressEvent(e);
}
QString ChatWidget::title() const
@@ -860,5 +866,4 @@ KIcon ChatWidget::iconForPresence(Tp::ConnectionPresenceType presence)
return KIcon(iconName);
}
-#include "chat-widget.moc" //for MessageBoxEventFilter
-#include "moc_chat-widget.cpp" //for ChatWidget
+#include "chat-widget.moc"
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index 61538c9..5672e1c 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -87,7 +87,6 @@ public Q_SLOTS:
void resetUnreadMessageCount();
-
protected:
void changeEvent(QEvent *e);
void resizeEvent(QResizeEvent *);
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list