[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:23:22 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=baf176a
The following commit has been merged in the master branch:
commit baf176a92a7025f938731cc5814d934ee0a8a76e
Author: Roman Nazarenko <me at jtalk.me>
Date: Fri Mar 1 20:13:49 2013 +0600
Send Message shortcut is now configurable
REVIEW: 109202
BUG: 308894
---
app/chat-window.cpp | 13 ++++++++++++-
app/chat-window.h | 1 +
lib/chat-text-edit.cpp | 46 +++++++++++++++++++++++++++++++++++-----------
lib/chat-text-edit.h | 4 ++++
4 files changed, 52 insertions(+), 12 deletions(-)
diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index c79e3aa..8092c3a 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -189,6 +189,11 @@ ChatTab* ChatWindow::getTab(const Tp::TextChannelPtr& incomingTextChannel)
return match;
}
+ChatTab *ChatWindow::getCurrentTab()
+{
+ return qobject_cast<ChatTab*>(m_tabWidget->currentWidget());
+}
+
void ChatWindow::removeTab(ChatTab *tab)
{
kDebug();
@@ -689,6 +694,12 @@ void ChatWindow::setupCustomActions()
EmoticonTextEditAction *addEmoticonAction = new EmoticonTextEditAction(this);
connect(addEmoticonAction, SIGNAL(emoticonActivated(QString)), this, SLOT(onAddEmoticon(QString)) );
+ KAction *sendMessage = new KAction(i18n("Send message"), this);
+ sendMessage->setShortcut(QKeySequence::InsertParagraphSeparator, KAction::DefaultShortcut);
+ sendMessage->setShortcutConfigurable(true);
+ sendMessage->setGlobalShortcutAllowed(false);
+ connect(sendMessage, SIGNAL(triggered()), SLOT(sendCurrentTabMessage()));
+
// add custom actions to the collection
actionCollection()->addAction(QLatin1String("next-tab"), nextTabAction);
actionCollection()->addAction(QLatin1String("previous-tab"), previousTabAction);
@@ -703,6 +714,7 @@ void ChatWindow::setupCustomActions()
actionCollection()->addAction(QLatin1String("open-log"), openLogAction);
actionCollection()->addAction(QLatin1String("clear-chat-view"), clearViewAction);
actionCollection()->addAction(QLatin1String("emoticons"), addEmoticonAction);
+ actionCollection()->addAction(QLatin1String("send-message"), sendMessage);
}
void ChatWindow::setAudioCallEnabled(bool enable)
@@ -922,7 +934,6 @@ void ChatWindow::onZoomFactorChanged(qreal zoom)
KConfig config(QLatin1String("ktelepathyrc"));
KConfigGroup group = config.group("Appearance");
group.writeEntry("zoomFactor", m_zoomFactor);
-
}
#include "chat-window.moc"
diff --git a/app/chat-window.h b/app/chat-window.h
index 018e91a..a92cb75 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -56,6 +56,7 @@ public:
* @param incomingTextChannel textChannel to search for
*/
ChatTab* getTab(const Tp::TextChannelPtr &incomingTextChannel);
+ ChatTab* getCurrentTab();
void focusChat(ChatTab *tab);
diff --git a/lib/chat-text-edit.cpp b/lib/chat-text-edit.cpp
index 19fdb38..8fb7e13 100644
--- a/lib/chat-text-edit.cpp
+++ b/lib/chat-text-edit.cpp
@@ -25,17 +25,32 @@
#include <QtGui/QAction>
#include <QtCore/QTimer>
#include <QtCore/QDebug>
+#include <QtCore/QString>
#include <KStandardShortcut>
+#include <KActionCollection>
#define MAXHISTORY 100
+KAction *searchActionGlobal(const QString& name)
+{
+ QList<KActionCollection*> collections = KActionCollection::allCollections();
+ KAction* action = NULL;
+ Q_FOREACH(KActionCollection *collection, collections) {
+ if (!action) {
+ action = qobject_cast<KAction*>(collection->action(name));
+ }
+ }
+ return action;
+}
+
ChatTextEdit::ChatTextEdit(QWidget *parent) :
KTextEdit(parent),
m_contactModel(0),
m_oldCursorPos(0),
m_completionPosition(0),
- m_continuousCompletion(false)
+ m_continuousCompletion(false),
+ m_sendMessageAction(0)
{
setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); // no need for horizontal scrollbar with this
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -52,6 +67,8 @@ ChatTextEdit::ChatTextEdit(QWidget *parent) :
m_historyPos = 0;
connect(this, SIGNAL(textChanged()), SLOT(recalculateSize()));
+
+ m_sendMessageAction = searchActionGlobal(QLatin1String("send-message"));
}
void ChatTextEdit::setContactModel(ChannelContactModel* model)
@@ -89,16 +106,6 @@ QSize ChatTextEdit::sizeHint() const
void ChatTextEdit::keyPressEvent(QKeyEvent *e)
{
- if ((e->key()==Qt::Key_Return || e->key()==Qt::Key_Enter) && !e->modifiers()) {
- if (!toPlainText().isEmpty()) {
- addHistory(toPlainText());
- }
- m_continuousCompletion = false;
-
- Q_EMIT returnKeyPressed();
- return;
- }
-
if (e->matches(QKeySequence::Copy)) {
if (!textCursor().hasSelection()) {
QWidget::keyReleaseEvent(e); //skip internal trapping, and pass to parent.
@@ -141,6 +148,13 @@ bool ChatTextEdit::event(QEvent *e)
if (e->type() == QEvent::ShortcutOverride) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(e);
const int key = keyEvent->key() | keyEvent->modifiers();
+ if (m_sendMessageAction->shortcut().contains(key)) {
+ // keyPressEvent() handles Control modifier wrong, so we need that thing
+ // to be in event().
+ this->sendMessage();
+ e->setAccepted(true);
+ return false;
+ }
if (KStandardShortcut::find().contains(key)) {
return false; //never catch "find" sequence.
}
@@ -171,6 +185,16 @@ void ChatTextEdit::updateScrollBar()
ensureCursorVisible();
}
+void ChatTextEdit::sendMessage()
+{
+ if (!toPlainText().isEmpty()) {
+ addHistory(toPlainText());
+ }
+ m_continuousCompletion = false;
+
+ Q_EMIT returnKeyPressed();
+}
+
// History of sent messages based on code from Konversation
// by Dario Abatianni
diff --git a/lib/chat-text-edit.h b/lib/chat-text-edit.h
index 4279ce5..7611924 100644
--- a/lib/chat-text-edit.h
+++ b/lib/chat-text-edit.h
@@ -21,6 +21,7 @@
#define CHATTEXTEDIT_H
#include <KTextEdit>
+#include <KAction>
class ChannelContactModel;
class ChatTextEdit : public KTextEdit
@@ -58,6 +59,7 @@ Q_SIGNALS:
public Q_SLOTS:
/** wraps setFontWeight to a simple on/off bold) */
void setFontBold(bool);
+ void sendMessage(); // Sends message entered (<= Return key pressing)
private:
QStringList m_history;
@@ -69,6 +71,8 @@ private:
int m_oldCursorPos;
int m_completionPosition;
bool m_continuousCompletion;
+
+ KAction *m_sendMessageAction;
};
#endif // CHATTEXTEDIT_H
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list