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


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

The following commit has been merged in the master branch:
commit 7599bc88d73901e4a8eb05fee0791a604d8a1e08
Author: Ahmed Ibrahim <ahmedibrahimkhali at gmail.com>
Date:   Tue Mar 25 11:49:25 2014 +0100

    Integration with keyboard layout switcher, allow separate keyboard layout per chat tab.
    
    Used DBus interface to switch the keyboard layout and listen to the keyboard layout change. Stored the language in each ChatTab instance and then restore it back when the ChatWindow is activated and when switching between tabs.
    
    REVIEW: 116774
    BUG: 308953
---
 app/chat-window.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++--
 app/chat-window.h   | 10 ++++++++++
 lib/chat-widget.cpp | 11 +++++++++++
 lib/chat-widget.h   |  4 ++++
 4 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index 2c2e12b..4a55238 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -72,7 +72,8 @@ K_GLOBAL_STATIC_WITH_ARGS(KTp::ServiceAvailabilityChecker, s_krfbAvailableChecke
 
 ChatWindow::ChatWindow()
     : m_sendMessage(0),
-      m_tabWidget(0)
+      m_tabWidget(0),
+      m_keyboardLayoutInterface(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
@@ -100,6 +101,11 @@ ChatWindow::ChatWindow()
     KStandardAction::zoomIn(this, SLOT(onZoomIn()), actionCollection());
     KStandardAction::zoomOut(this, SLOT(onZoomOut()), actionCollection());
 
+    m_keyboardLayoutInterface = new QDBusInterface(QLatin1String("org.kde.keyboard"), QLatin1String("/Layouts"),
+						   QLatin1String("org.kde.KeyboardLayouts"), QDBusConnection::sessionBus(), this);
+
+    connect(m_keyboardLayoutInterface, SIGNAL(currentLayoutChanged(QString)), this, SLOT(onKeyboardLayoutChange(QString)));
+
     // set up m_tabWidget
     m_tabWidget = new KTabWidget(this);
     //clicking on the close button can result in the tab bar getting focus, this works round that
@@ -227,6 +233,10 @@ void ChatWindow::addTab(ChatTab *tab)
     setupChatTabSignals(tab);
     tab->setZoomFactor(m_zoomFactor);
 
+    QDBusPendingCall dbusPendingCall = m_keyboardLayoutInterface->asyncCall(QLatin1String("getCurrentLayout"));
+    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(dbusPendingCall, this);
+    connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(onGetCurrentKeyboardLayoutFinished(QDBusPendingCallWatcher*)));
+
     m_tabWidget->addTab(tab, tab->icon(), tab->title());
     m_tabWidget->setCurrentWidget(tab);
     m_tabWidget->setTabToolTip(m_tabWidget->indexOf(tab), tab->title());
@@ -329,6 +339,8 @@ void ChatWindow::onCurrentIndexChanged(int index)
     kDebug() << "Current spell dictionary is" << currentChatTab->spellDictionary();
     m_spellDictCombo->setCurrentByDictionary(currentChatTab->spellDictionary());
 
+    restoreKeyboardLayout(currentChatTab);
+
     // when the tab changes I need to "refresh" the window's findNext and findPrev actions
     if (currentChatTab->chatSearchBar()->searchBar()->text().isEmpty()) {
         onEnableSearchActions(false);
@@ -426,6 +438,19 @@ void ChatWindow::onGenericOperationFinished(Tp::PendingOperation* op)
     }
 }
 
+void ChatWindow::onGetCurrentKeyboardLayoutFinished(QDBusPendingCallWatcher* watcher)
+{
+    if (!watcher->isError()) {
+	QDBusMessage replyMessage = watcher->reply();
+	ChatTab *chatTab = getCurrentTab();
+	if (chatTab) {
+	    QString layout = replyMessage.arguments().first().toString();
+	    chatTab->setCurrentKeyboardLayoutLanguage(layout);
+	}
+    }
+    watcher->deleteLater();
+}
+
 void ChatWindow::onInviteToChatTriggered()
 {
     ChatTab *currChat = qobject_cast<ChatTab*>(m_tabWidget->currentWidget());
@@ -435,6 +460,17 @@ void ChatWindow::onInviteToChatTriggered()
     dialog->show();
 }
 
+void ChatWindow::onKeyboardLayoutChange(const QString& keyboardLayout)
+{
+    ChatTab *currChat = getCurrentTab();
+    if (currChat) {
+	// To prevent keyboard layout change when the ChatWindow is minimized or not active
+	if (currChat->isActiveWindow()) {
+	    currChat->setCurrentKeyboardLayoutLanguage(keyboardLayout);
+	}
+    }
+}
+
 void ChatWindow::onNextTabActionTriggered()
 {
     if (m_tabWidget->count() == 1) {
@@ -894,6 +930,16 @@ void ChatWindow::offerDocumentToChatroom(const Tp::AccountPtr& account, const QS
     }
 }
 
+void ChatWindow::restoreKeyboardLayout(ChatTab *chatTab)
+{
+    if (chatTab) {
+	QString currentKeyboardLayout = chatTab->currentKeyboardLayoutLanguage();
+	if (!currentKeyboardLayout.isEmpty()) {
+	    m_keyboardLayoutInterface->asyncCall(QLatin1String("setLayout"), currentKeyboardLayout);
+	}
+    }
+}
+
 void ChatWindow::startVideoCall(const Tp::AccountPtr& account, const Tp::ContactPtr& contact)
 {
     Tp::PendingChannelRequest* channelRequest = KTp::Actions::startAudioVideoCall(account, contact);
@@ -910,11 +956,12 @@ bool ChatWindow::event(QEvent *e)
 {
     if (e->type() == QEvent::WindowActivate) {
         //when the window is activated reset the message count on the active tab.
-        ChatWidget *currChat =  qobject_cast<ChatWidget*>(m_tabWidget->currentWidget());
+        ChatTab *currChat =  qobject_cast<ChatTab*>(m_tabWidget->currentWidget());
         //it is (apparently) possible to get a window activation event whilst we're closing down and have no tabs
         //see https://bugs.kde.org/show_bug.cgi?id=322135
         if (currChat) {
             currChat->acknowledgeMessages();
+	    restoreKeyboardLayout(currChat);
         }
     }
 
diff --git a/app/chat-window.h b/app/chat-window.h
index 793ac55..9896606 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -34,6 +34,7 @@ namespace Sonnet {
 class KIcon;
 class ChatTab;
 class QLabel;
+class QDBusPendingCallWatcher;
 
 class ChatWindow : public KXmlGuiWindow
 {
@@ -88,7 +89,9 @@ private Q_SLOTS:
     void onFindNextText();                                      /** go to next text the user is searching for */
     void onFindPreviousText();                                  /** go to previous text the user is searching for */
     void onGenericOperationFinished(Tp::PendingOperation *op);
+    void onGetCurrentKeyboardLayoutFinished(QDBusPendingCallWatcher *watcher);
     void onInviteToChatTriggered();                             /** invite contact(s) to chat */
+    void onKeyboardLayoutChange(const QString& keyboardLayout);
     void onNextTabActionTriggered();                            /** go to next tab in the tabwidget */
     void onPreviousTabActionTriggered();                        /** go to previous tab in the tabwidget */
     void onSearchActionToggled();                               /** toggle search bar visibility */
@@ -186,10 +189,17 @@ private:
      */
     void offerDocumentToChatroom(const Tp::AccountPtr& account, const QString& roomName);
 
+    /**
+     * @brief Restores the System's keyboard layout to the layout of the current ChatTab
+     * @param chatTab The tab that the language is going to be restored from
+     */
+    void restoreKeyboardLayout(ChatTab *chatTab);
+
     KAction *m_sendMessage;
 
     KTabWidget *m_tabWidget;
 
+    QDBusInterface *m_keyboardLayoutInterface;
     Sonnet::DictionaryComboBox *m_spellDictCombo;
     QLabel *m_accountIconLabel;
     qreal m_zoomFactor;
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index e7c7619..0bf369b 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -75,6 +75,7 @@ public:
     QString title;
     QString contactName;
     QString yourName;
+    QString currentKeyboardLayoutLanguage;
     Tp::TextChannelPtr channel;
     Tp::AccountPtr account;
     Ui::ChatWidget ui;
@@ -875,6 +876,16 @@ void ChatWidget::setSpellDictionary(const QString &dict)
     d->ui.sendMessageBox->setSpellCheckingLanguage(dict);
 }
 
+QString ChatWidget::currentKeyboardLayoutLanguage() const
+{
+    return d->currentKeyboardLayoutLanguage;
+}
+
+void ChatWidget::setCurrentKeyboardLayoutLanguage(const QString &language)
+{
+    d->currentKeyboardLayoutLanguage = language;
+}
+
 void ChatWidget::saveSpellCheckingOption()
 {
     QString spellCheckingLanguage = spellDictionary();
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index c1dbd41..f2fbd3b 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -87,6 +87,10 @@ public:
 
     void setSpellDictionary(const QString &dict);
 
+    QString currentKeyboardLayoutLanguage() const;
+
+    void setCurrentKeyboardLayoutLanguage(const QString &language);
+
     void addEmoticonToChat(const QString &emoticon);
 
     /** Returns the chat state of remote contact */

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list