[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:08:06 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=736a0e3

The following commit has been merged in the master branch:
commit 736a0e3f6d37344abca818022ed6e82748acde52
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date:   Mon Nov 21 15:36:20 2011 +0100

    Make adding a presence message easy
    
    Clicking the combobox will turn it into a KLineEdit (indicated by a "typing" cursor), losing focus will turn it back to combobox. The user can still open the combobox dropdown by clicking the down arrow.
    
    Reviewed-by: David Edmundson & Dario Freddi
    REVIEW: 103170
    FEATURE: 283805
---
 global-presence-chooser.cpp | 78 +++++++++++++++++++++++++++++++++++++++++++--
 global-presence-chooser.h   |  1 -
 2 files changed, 75 insertions(+), 4 deletions(-)

diff --git a/global-presence-chooser.cpp b/global-presence-chooser.cpp
index 56a066d..14d52bc 100644
--- a/global-presence-chooser.cpp
+++ b/global-presence-chooser.cpp
@@ -31,14 +31,14 @@
 #include <KDebug>
 #include <KPixmapSequence>
 #include <KPixmapSequenceOverlayPainter>
+#include <KMessageBox>
 
 #include <TelepathyQt4/Presence>
 #include <TelepathyQt4/Account>
 
 #include <QMouseEvent>
 #include <QtGui/QToolTip>
-#include <KMessageBox>
-
+#include <QStyle>
 
 //A sneaky class that adds an extra entry to the end of the presence model
 //called "Configure Presences"
@@ -166,6 +166,10 @@ GlobalPresenceChooser::GlobalPresenceChooser(QWidget *parent) :
 {
     this->setModel(m_modelExtended);
 
+    setEditable(false);
+    //needed for mousemove events
+    setMouseTracking(true);
+
     m_busyOverlay = new KPixmapSequenceOverlayPainter(this);
     m_busyOverlay->setSequence(KPixmapSequence("process-working"));
     m_busyOverlay->setWidget(this);
@@ -215,6 +219,75 @@ bool GlobalPresenceChooser::event(QEvent *e)
     if (e->type() == QEvent::Resize) {
         repositionSpinner();
     }
+
+    if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonRelease || e->type() == QEvent::MouseButtonDblClick) {
+        QMouseEvent *me = static_cast<QMouseEvent*>(e);
+        QStyleOptionComboBox opt;
+        initStyleOption(&opt);
+
+        //get the subcontrol this event occured in
+        QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, me->pos(),
+                                                               this);
+
+        if (sc == QStyle::SC_ComboBoxArrow) {
+            //if user pressed the combo arrow, pass it to parent
+            QComboBox::mousePressEvent(me);
+        } else {
+            //set combo editable if user click to any other parts
+            setEditable(true);
+            //if current presence has no presence message, delete the text
+            if (m_globalPresence->currentPresence().statusMessage().isEmpty()) {
+                lineEdit()->clear();
+            }
+            lineEdit()->setFocus();
+        }
+
+        return true;
+    }
+
+    if (e->type() == QEvent::MouseMove) {
+        QMouseEvent *me =  static_cast<QMouseEvent*>(e);
+        QStyleOptionComboBox opt;
+        initStyleOption(&opt);
+
+        //get the subcontrol this event occured in
+        QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, me->pos(),
+                                                               this);
+
+        //set ArrowCursor for the combo arrow, "typing" cursor for all the rest
+        if (sc == QStyle::SC_ComboBoxArrow) {
+            setCursor(Qt::ArrowCursor);
+        } else {
+            setCursor(Qt::IBeamCursor);
+        }
+
+        return true;
+    }
+
+    if (e->type() == QEvent::KeyPress) {
+        QKeyEvent *ke = static_cast<QKeyEvent*>(e);
+
+        if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return) {
+            Tp::Presence presence = itemData(currentIndex(), PresenceModel::PresenceRole).value<Tp::Presence>();
+            presence.setStatus(presence.type(), presence.status(), lineEdit()->text());
+            QModelIndex newPresence = m_model->addPresence(presence); //m_model->addPresence(presence);
+            setEditable(false);
+            kDebug() << newPresence.row();
+            setCurrentIndex(newPresence.row());
+            //this is needed because currentIndexChanged signal is not connected and that is to not crash contact list
+            //because this signal is emitted once there is a valid model and that happens before AccountManager is ready
+            //and thus crashes contact list. Therefore it's called manually here.
+            onCurrentIndexChanged(newPresence.row());
+
+            return true;
+        }
+    }
+
+    if (e->type() == QEvent::FocusOut) {
+        //just cancel editable and let it exec parent event()
+        setEditable(false);
+    }
+
     return QComboBox::event(e);
 }
 
@@ -302,6 +375,5 @@ void GlobalPresenceChooser::repositionSpinner()
     m_busyOverlay->setRect(QRect(topLeft, m_busyOverlay->sequence().frameSize()));
 }
 
-
 #include "global-presence-chooser.moc"
 #include "moc_global-presence-chooser.cpp" //hack because we have two QObejcts in teh same file
diff --git a/global-presence-chooser.h b/global-presence-chooser.h
index c4e4302..f0eb623 100644
--- a/global-presence-chooser.h
+++ b/global-presence-chooser.h
@@ -30,7 +30,6 @@ class GlobalPresence;
 class PresenceModel;
 class PresenceModelExtended;
 
-
 class GlobalPresenceChooser : public KComboBox
 {
     Q_OBJECT

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list