[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    =?UTF-8?B?W1BBVENIXSBCVUcgMTk5MTA3IG1ha2UgdGhlIHBvcHVwIGRpYWxvZyBvZiBncm91cCBoaWRlIGF1?=
From:       "=?UTF-8?B?5r2Y5Y2r5bmzKFBldGVyIFBhbik=?=" <wppan () redflag-linux ! com>
Date:       2009-07-06 9:49:09
Message-ID: 20090706094909.4CBCC1377D0 () mail ! redflag-linux ! com
[Download RAW message or body]

This is a MIME-formatted message.  If you see this text it means that your
mail software cannot handle MIME-formatted messages.


Hi, all

The patch is related to grouping of tasks on taskbar. 

I think that we should make the popup dialog of group hide automatically, seem to be \
more intelligent.

When the mouse move out of the popup dialog of the group, and it isn't hovering on \
the group, I let the dialog hide automically.


regards

--
潘卫平(Peter Pan)


["kdebase-plasma-tasks-grouphide.patch" (kdebase-plasma-tasks-grouphide.patch)]

Index: taskgroupitem.cpp
===================================================================
--- taskgroupitem.cpp	(revision 992092)
+++ taskgroupitem.cpp	(working copy)
@@ -59,6 +59,7 @@
       m_group(0),
       m_tasksLayout(0),
       m_popupMenuTimer(0),
+      m_hidePopupMenuTimer(0),
       m_lastActivated(-1),
       m_activeTaskIndex(0),
       m_maximumRows(1),
@@ -69,6 +70,7 @@
       m_offscreenWidget(0),
       m_offscreenLayout(0),
       m_collapsed(true),
+      m_windowItemContextMenuIsShown(false),
       m_mainLayout(0),
       m_popupDialog(0),
       m_popupLostFocus(false)
@@ -475,6 +477,7 @@
     if (isNew) {
         connect(item, SIGNAL(activated(AbstractTaskItem*)),
                 this, SLOT(updateActive(AbstractTaskItem*)));
+        connect(item, SIGNAL(contextMenuIsShown(bool)), this, SLOT(setWindowPopupMenuIsShown(bool)));
 
         TaskGroupItem *group = qobject_cast<TaskGroupItem*>(item);
         if (group) {
@@ -591,6 +594,13 @@
         m_popupDialog->getContentsMargins(&left, &top, &right, &bottom);
         m_offscreenWidget->setMinimumWidth(size().width() - left - right);
         m_popupDialog->setGraphicsWidget(m_offscreenWidget);
+
+        if (!m_hidePopupMenuTimer) {
+            m_hidePopupMenuTimer = new QTimer(this);
+            m_hidePopupMenuTimer->setSingleShot(true);
+            m_hidePopupMenuTimer->setInterval(500);
+            connect(m_hidePopupMenuTimer, SIGNAL(timeout()), this, SLOT(hidePopupMenu()));
+        }
     }
 
     if (m_popupDialog->isVisible()) {
@@ -621,6 +631,14 @@
 
 bool TaskGroupItem::eventFilter(QObject *watched, QEvent *event)
 {
+    if (watched == m_popupDialog && event->type() == QEvent::Enter) {
+        m_hidePopupMenuTimer->stop();
+    }
+
+    if (watched == m_popupDialog && event->type() == QEvent::Leave && !m_windowItemContextMenuIsShown) {
+        m_hidePopupMenuTimer->start(500);
+    }
+
     if (watched == m_popupDialog && event->type() == QEvent::WindowDeactivate) {
         Q_ASSERT(m_popupDialog);
         m_popupLostFocus = true; //avoid opening it again when clicking on the group
@@ -1267,5 +1285,46 @@
     return m_popupDialog;
 }
 
+void TaskGroupItem::hidePopupMenu()
+{
+    if (m_popupDialog) {
+        if (m_applet->location() != Plasma::Floating) {
+            m_popupDialog->animatedHide(Plasma::locationToInverseDirection(m_applet->location()));
+        } else {
+            m_popupDialog->hide();
+        }
+    }
+}
+
+void TaskGroupItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
+{
+    if (m_hidePopupMenuTimer) {
+        m_hidePopupMenuTimer->stop();
+    }
+
+    AbstractTaskItem::hoverEnterEvent(event);    
+}
+
+void TaskGroupItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
+{
+    if (m_hidePopupMenuTimer) {
+        m_hidePopupMenuTimer->start(500);
+    }
+
+    AbstractTaskItem::hoverLeaveEvent(event);    
+}
+
+void TaskGroupItem::setWindowPopupMenuIsShown(bool isShown)
+{
+    m_windowItemContextMenuIsShown = isShown;
+
+    if (m_hidePopupMenuTimer) {
+        if (m_windowItemContextMenuIsShown) {
+            m_hidePopupMenuTimer->stop();
+        } else {
+            m_hidePopupMenuTimer->start(500);      
+        }
+    }
+}
 #include "taskgroupitem.moc"
 
Index: taskgroupitem.h
===================================================================
--- taskgroupitem.h	(revision 992092)
+++ taskgroupitem.h	(working copy)
@@ -143,6 +143,8 @@
 
     void handleDroppedId(WId id, AbstractTaskItem *targetTask, QGraphicsSceneDragDropEvent *event);
 
+    void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
+    void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
     void mousePressEvent(QGraphicsSceneMouseEvent *event);
     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
     void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
@@ -169,6 +171,8 @@
     void itemPositionChanged(AbstractGroupableItem *);
 
     void popupMenu();
+    void hidePopupMenu();
+    void setWindowPopupMenuIsShown(bool isShown);
     /** force a relayout of all items */
     void relayoutItems();
 
@@ -193,6 +197,7 @@
 
     TaskItemLayout *m_tasksLayout;
     QTimer *m_popupMenuTimer;
+    QTimer *m_hidePopupMenuTimer;
     QHash<int, Order> m_taskOrder;
     int m_lastActivated;
     int m_activeTaskIndex;
@@ -205,6 +210,7 @@
     QGraphicsWidget *m_offscreenWidget;
     QGraphicsLinearLayout *m_offscreenLayout;
     bool m_collapsed;
+    bool m_windowItemContextMenuIsShown;
     QGraphicsLinearLayout *m_mainLayout;
     Plasma::Dialog *m_popupDialog;
     bool m_popupLostFocus;
Index: windowtaskitem.cpp
===================================================================
--- windowtaskitem.cpp	(revision 992092)
+++ windowtaskitem.cpp	(working copy)
@@ -296,6 +296,8 @@
 
     Q_ASSERT(m_applet->containment());
     Q_ASSERT(m_applet->containment()->corona());
+    connect(&menu, SIGNAL(aboutToShow()), this, SLOT(setContextMenuIsShown()));
+    connect(&menu, SIGNAL(aboutToHide()), this, SLOT(setContextMenuIsHidden()));
     menu.exec(m_applet->containment()->corona()->popupPosition(this, menu.size()));
     delete a;
 }
@@ -322,5 +324,14 @@
     }
 }
 
+void WindowTaskItem::setContextMenuIsShown()
+{
+    emit contextMenuIsShown(true);
+}
+
+void WindowTaskItem::setContextMenuIsHidden()   
+{
+    emit contextMenuIsShown(false);
+}
 #include "windowtaskitem.moc"
 
Index: windowtaskitem.h
===================================================================
--- windowtaskitem.h	(revision 992092)
+++ windowtaskitem.h	(working copy)
@@ -58,6 +58,7 @@
 signals:
     /** Emitted when a window is selected for activation, minimization, iconification */
     //void windowSelected(WindowTaskItem *); //what is it for?
+    void contextMenuIsShown(bool IsShown);
 
 public slots:
     void activate();
@@ -71,6 +72,8 @@
 private slots:
     void updateTask(::TaskManager::TaskChanges changes);
     void gotTaskPointer();
+    void setContextMenuIsShown();
+    void setContextMenuIsHidden();    
 
 private:
     /** Sets the starting task represented by this item. */


_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic