[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:33 UTC 2016


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

The following commit has been merged in the master branch:
commit c971c72970192ab6bd2df246fa53c44028ff0093
Author: Roman Nazarenko <me at jtalk.me>
Date:   Wed Mar 13 23:47:37 2013 +0600

    Fixed crash on Send Message shortcut checking, when tab was detached and parent window was already destroyed.
    KAction pointer is replaced with KShortcut object inside every tab's Text Edit.
    
    REVIEW: 109466
    BUG: 316484
---
 app/chat-window.cpp    | 31 +++++++++++++++++++++++--------
 app/chat-window.h      |  4 ++++
 lib/chat-text-edit.cpp | 25 ++++++++-----------------
 lib/chat-text-edit.h   | 11 ++++++++++-
 lib/chat-widget.cpp    |  5 +++++
 lib/chat-widget.h      |  3 +++
 6 files changed, 53 insertions(+), 26 deletions(-)

diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index 02a390e..9a014e3 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -67,6 +67,8 @@ K_GLOBAL_STATIC_WITH_ARGS(KTp::ServiceAvailabilityChecker, s_krfbAvailableChecke
                           (QLatin1String(PREFERRED_RFB_HANDLER)));
 
 ChatWindow::ChatWindow()
+    : m_sendMessage(0),
+      m_tabWidget(0)
 {
     //This effectively constructs the s_krfbAvailableChecker object the first
     //time that this code is executed. This is to start the d-bus query early, so
@@ -94,9 +96,6 @@ ChatWindow::ChatWindow()
     KStandardAction::zoomIn(this, SLOT(onZoomIn()), actionCollection());
     KStandardAction::zoomOut(this, SLOT(onZoomOut()), actionCollection());
 
-    // create custom actions
-    setupCustomActions();
-
     // set up m_tabWidget
     m_tabWidget = new KTabWidget(this);
     m_tabWidget->setMovable(true);
@@ -111,6 +110,10 @@ ChatWindow::ChatWindow()
 
     setCentralWidget(m_tabWidget);
 
+    // create custom actions
+    // we must do it AFTER m_tabWidget is set up
+    setupCustomActions();
+
     setupGUI(QSize(460, 440), static_cast<StandardWindowOptions>(Default^StatusBar), QLatin1String("chatwindow.rc"));
 
     // Connects the toolbars iconSizeChanged to the custom toolbar item
@@ -224,6 +227,8 @@ void ChatWindow::addTab(ChatTab *tab)
             m_tabWidget->setTabBarHidden(false);
         }
     }
+
+    tab->updateSendMessageShortcuts(m_sendMessage->shortcut());
 }
 
 void ChatWindow::destroyTab(QWidget* chatWidget)
@@ -694,13 +699,14 @@ 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->setShortcuts(
+    m_sendMessage = new KAction(i18n("Send message"), this);
+    m_sendMessage->setShortcuts(
                 // Setting default shortcuts. Return will be a primary one, and Enter (on keypad) - alternate.
                 QList<QKeySequence>() << QKeySequence(Qt::Key_Return) << QKeySequence(Qt::Key_Enter),
                 KAction::DefaultShortcut);
-    sendMessage->setShortcutConfigurable(true);
-    connect(sendMessage, SIGNAL(triggered()), SLOT(sendCurrentTabMessage()));
+    m_sendMessage->setShortcutConfigurable(true);
+    connect(m_sendMessage, SIGNAL(triggered()), SLOT(sendCurrentTabMessage()));
+    connect(m_sendMessage, SIGNAL(changed()), SLOT(updateSendMessageShortcuts()));
 
     // add custom actions to the collection
     actionCollection()->addAction(QLatin1String("next-tab"), nextTabAction);
@@ -716,7 +722,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);
+    actionCollection()->addAction(QLatin1String("send-message"), m_sendMessage);
 }
 
 void ChatWindow::setAudioCallEnabled(bool enable)
@@ -938,4 +944,13 @@ void ChatWindow::onZoomFactorChanged(qreal zoom)
     group.writeEntry("zoomFactor", m_zoomFactor);
 }
 
+void ChatWindow::updateSendMessageShortcuts()
+{
+    KShortcut newSendMessageShortcuts = m_sendMessage->shortcut();
+    for (int i = 0; i < m_tabWidget->count(); i++) {
+        ChatTab* tab = qobject_cast<ChatTab*>(m_tabWidget->widget(i));
+        tab->updateSendMessageShortcuts(newSendMessageShortcuts);
+    }
+}
+
 #include "chat-window.moc"
diff --git a/app/chat-window.h b/app/chat-window.h
index a92cb75..277baab 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -25,6 +25,7 @@
 
 #include <KXmlGuiWindow>
 #include <KTabWidget>
+#include <KAction>
 
 namespace Sonnet {
     class DictionaryComboBox;
@@ -107,6 +108,7 @@ private Q_SLOTS:
     void onZoomIn();
     void onZoomOut();
     void onZoomFactorChanged(qreal zoom);
+    void updateSendMessageShortcuts();
 
 protected Q_SLOTS:
     void showSettingsDialog();
@@ -170,6 +172,8 @@ private:
 
     KTabWidget *m_tabWidget;
 
+    KAction *m_sendMessage;
+
     Sonnet::DictionaryComboBox *m_spellDictCombo;
     QLabel *m_accountIconLabel;
     qreal m_zoomFactor;
diff --git a/lib/chat-text-edit.cpp b/lib/chat-text-edit.cpp
index 00c3f47..305455c 100644
--- a/lib/chat-text-edit.cpp
+++ b/lib/chat-text-edit.cpp
@@ -32,25 +32,12 @@
 
 #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_sendMessageAction(0)
+        m_continuousCompletion(false)
 {
     setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);    // no need for horizontal scrollbar with this
     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -67,8 +54,6 @@ ChatTextEdit::ChatTextEdit(QWidget *parent) :
     m_historyPos = 0;
 
     connect(this, SIGNAL(textChanged()), SLOT(recalculateSize()));
-
-    m_sendMessageAction = searchActionGlobal(QLatin1String("send-message"));
 }
 
 void ChatTextEdit::setContactModel(ChannelContactModel* model)
@@ -153,7 +138,8 @@ bool ChatTextEdit::event(QEvent *e)
             // Keypad modifier is not used in KDE shortcuts setup, so, we need to skip it.
             key |= keyEvent->modifiers();
         }
-        if (m_sendMessageAction->shortcut().contains(key)) {
+
+        if (m_sendMessageShortcuts.contains(key)) {
             // keyPressEvent() handles Control modifier wrong, so we need that thing
             // to be in event().
             this->sendMessage();
@@ -200,6 +186,11 @@ void ChatTextEdit::sendMessage()
     Q_EMIT returnKeyPressed();
 }
 
+void ChatTextEdit::setSendMessageShortcuts(const KShortcut &shortcuts)
+{
+    m_sendMessageShortcuts = KShortcut(shortcuts);
+}
+
 // 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 7611924..11d428e 100644
--- a/lib/chat-text-edit.h
+++ b/lib/chat-text-edit.h
@@ -20,6 +20,9 @@
 #ifndef CHATTEXTEDIT_H
 #define CHATTEXTEDIT_H
 
+#include <QtCore/QList>
+#include <QtGui/QKeySequence>
+
 #include <KTextEdit>
 #include <KAction>
 
@@ -61,6 +64,12 @@ public Q_SLOTS:
     void setFontBold(bool);
     void sendMessage(); // Sends message entered (<= Return key pressing)
 
+    /**
+     * Updates internal message sending shortcuts. Must be called on every window
+     * creation and every message sending shortcuts change.
+     */
+    void setSendMessageShortcuts(const KShortcut &shortcuts);
+
 private:
     QStringList m_history;
     int m_historyPos;
@@ -72,7 +81,7 @@ private:
     int m_completionPosition;
     bool m_continuousCompletion;
 
-    KAction *m_sendMessageAction;
+    KShortcut m_sendMessageShortcuts;
 };
 
 #endif // CHATTEXTEDIT_H
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index 4416d68..d1071f4 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -489,6 +489,11 @@ void ChatWidget::acknowledgeMessages()
     }
 }
 
+void ChatWidget::updateSendMessageShortcuts(const KShortcut &shortcuts)
+{
+    d->ui.sendMessageBox->setSendMessageShortcuts(shortcuts);
+}
+
 bool ChatWidget::isOnTop() const
 {
     kDebug() << ( isActiveWindow() && isVisible() );
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index 9eecc89..fcda548 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -29,6 +29,7 @@
 
 #include <KIcon>
 #include <KColorScheme>
+#include <KShortcut>
 
 #include <TelepathyQt/ReceivedMessage>
 
@@ -110,6 +111,8 @@ public Q_SLOTS:
       */
     void acknowledgeMessages();
 
+    void updateSendMessageShortcuts(const KShortcut &shortcuts);
+
 protected:
     void changeEvent(QEvent *e);
     void resizeEvent(QResizeEvent *);

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list