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

List:       kde-panel-devel
Subject:    Re: [PATCH] BUG 199107 make the popup dialog of group hide
From:       潘卫平 <wppan () redflag-linux ! com>
Date:       2009-07-07 11:52:47
Message-ID: 4A53370F.6090805 () redflag-linux ! com
[Download RAW message or body]

潘卫平(Peter Pan) 写道:
> 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)
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel@kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel

Let me try to explain the bug and patch clearly.

The bug is about plasma applet tasks. I found a problem that the popup 
dialog
of a group can't hide automatically.

Reproduce steps:
1、set "By Program Name" grouping strategy, uncheck "Only when the 
taskbar is full".
2、run one konsole application.
3、run two dolphin applications, they will group together on the taskbar.
4、click the dolphin group, a popup dialog will show.
5、move the mouse over konsole on the taskbar, a tooltip will show, but
the popup dialog of dolphin doesn't hide automatically. It is still 
there! see
https://bugs.kde.org/show_bug.cgi?id=199107#c2

And now the tooltip of konsole and the popup dialog of dolphin group 
show together, side by side.
I think that we should make the popup dialog of dolphin group hide 
automatically when it receives a hoverLeaveEvent,
make it seem to be more intelligent.


regards

-- 
潘卫平(Peter Pan)
Red Flag Co.,Ltd


["kdebase-plasma-tasks-grouphide.patch" (text/x-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