[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-16 8:59:35
Message-ID: 4A5EEBF7.8070203 () redflag-linux ! com
[Download RAW message or body]

Aaron J. Seigo 写道:
> On Friday 10 July 2009, 潘卫平(Peter Pan) wrote:
>> I still think that hiding the popup automatically is more convenient
>> than rejecting showing tooltip and context menu.
> 
> for context menus, i agree. if a context menu i shown, the task group popup 
> should also go away. that's a general issues, though (any right click menu on 
> any widget will not hide the group popup). so looks like there's a bug in the 
> code that decides when to hide the group popup in those cases.
> 
> this is probably made a bit trickier because you can pull up a context menu on 
> items _inside_ the group popup!
> 
> however, for tooltips, i really don't think they are important enough to be 
> shown when a group is already open.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel@kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel

Since the problem is too complicated, maybe we should divide and conquer it.

For context menus, maybe it's a bug in Qt? I'll look into it later.

For tooltips, I agree that they are less important than the popup 
dialog, so I made another patch to reject showing tooltips when a popup 
dialog is showing.

Regards!

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

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

Index: taskgroupitem.cpp
===================================================================
--- taskgroupitem.cpp	(revision 997661)
+++ taskgroupitem.cpp	(working copy)
@@ -188,6 +188,7 @@
     //close the popup if the group is removed
     if (m_popupDialog) {
         m_popupDialog->hide();
+        disconnect(m_popupDialog, 0, 0, 0);
         m_popupDialog->deleteLater();
         m_popupDialog = 0;
     }
@@ -263,6 +264,13 @@
         return;
     }
 
+    QWidget * dialog = m_applet->popupDialog();
+
+    if (dialog && dialog->isVisible()) {
+        Plasma::ToolTipManager::self()->clearContent(this);
+        return;
+    }
+
     Plasma::ToolTipContent data(m_group->name(),
                                 i18nc("Which virtual desktop a window is currently \
                on", "On %1",
                                        \
KWindowSystem::desktopName(m_group->desktop()))); @@ -598,6 +606,7 @@
     if (!m_popupDialog) {
         // Initialize popup dialog
         m_popupDialog = new Plasma::Dialog();
+        connect(m_popupDialog, SIGNAL(dialogVisible(bool)), m_applet, \
                SLOT(setPopupDialog(bool)));
         KWindowSystem::setState(m_popupDialog->winId(), NET::SkipTaskbar| \
                NET::SkipPager);
         m_popupDialog->setWindowFlags(Qt::FramelessWindowHint | \
                Qt::WindowStaysOnTopHint);
         //TODO in the future it may be possible to use the Qt::Popup flag instead of \
                the eventFilter, but for now the focus works better with the \
                eventFilter
Index: windowtaskitem.cpp
===================================================================
--- windowtaskitem.cpp	(revision 997661)
+++ windowtaskitem.cpp	(working copy)
@@ -185,21 +185,41 @@
 {
     if (!m_task) {
         return;
-    }
+    } 
+   
+    bool showToolTip = true;
+    TaskGroupItem *group = parentGroup();
 
-    QPixmap p = m_task->task()->icon(KIconLoader::SizeLarge, KIconLoader::SizeLarge, \
                false);
-    if (p.height() > KIconLoader::SizeLarge) {
-        p = p.scaled(QSize(KIconLoader::SizeLarge, KIconLoader::SizeLarge),
-                     Qt::KeepAspectRatio, Qt::SmoothTransformation);
-    }
+    if (group) {
+        QWidget *groupPopupDialog = parentGroup()->popupDialog();
+        QWidget *dialog = m_applet->popupDialog();
 
-    Plasma::ToolTipContent data(m_task->name(),
-                                i18nc("Which virtual desktop a window is currently \
                on", "On %1",
-                                      \
                KWindowSystem::desktopName(m_task->desktop())), p);
-    data.setWindowToPreview(m_task->task()->window());
-    data.setClickable(true);
+        if (dialog && dialog->isVisible()) {
+            if (groupPopupDialog && groupPopupDialog == dialog) {
+                showToolTip = true;
+            } else {
+                showToolTip = false;
+            }
+        }
+    } 
+    
+    if (showToolTip) {
+        QPixmap p = m_task->task()->icon(KIconLoader::SizeLarge, \
KIconLoader::SizeLarge, false); +        if (p.height() > KIconLoader::SizeLarge) {
+            p = p.scaled(QSize(KIconLoader::SizeLarge, KIconLoader::SizeLarge),
+                                Qt::KeepAspectRatio, Qt::SmoothTransformation);
+        }
 
-    Plasma::ToolTipManager::self()->setContent(this, data);
+        Plasma::ToolTipContent data(m_task->name(),
+                                    i18nc("Which virtual desktop a window is \
currently on", "On %1", +                                    \
KWindowSystem::desktopName(m_task->desktop())), p); +        \
data.setWindowToPreview(m_task->task()->window()); +        data.setClickable(true);
+
+        Plasma::ToolTipManager::self()->setContent(this, data);
+    } else {
+        Plasma::ToolTipManager::self()->clearContent(this);
+    }
 }
 
 void WindowTaskItem::setStartupTask(TaskItem *task)
Index: tasks.cpp
===================================================================
--- tasks.cpp	(revision 997661)
+++ tasks.cpp	(working copy)
@@ -52,7 +52,8 @@
        m_bottomMargin(0),
        m_rootGroupItem(0),
        m_groupManager(0),
-       m_groupModifierKey(Qt::AltModifier)
+       m_groupModifierKey(Qt::AltModifier),
+       m_popupDialog(0)
 {
     setHasConfigurationInterface(true);
     setAspectRatioMode(Plasma::IgnoreAspectRatio);
@@ -391,7 +392,20 @@
     return m_rootGroupItem;
 }
 
+QWidget *Tasks::popupDialog() const
+{
+    return m_popupDialog;
+}
 
+void Tasks::setPopupDialog(bool status)
+{
+    QWidget *widget = qobject_cast<QWidget *>(sender());
+    
+    if (widget->isVisible()) {
+        m_popupDialog = widget;
+    }
+}
+
 K_EXPORT_PLASMA_APPLET(tasks, Tasks)
 
 #include "tasks.moc"
Index: tasks.h
===================================================================
--- tasks.h	(revision 997661)
+++ tasks.h	(working copy)
@@ -105,8 +105,8 @@
         bool showToolTip() const;
 
         void needsVisualFocus();
-
-
+        // return a pointer referring to the popup dialog which is showing
+        QWidget *popupDialog() const;
 signals:
     /**
     * emitted whenever we receive a constraintsEvent
@@ -116,6 +116,7 @@
 
 protected slots:
         void configAccepted();
+        void setPopupDialog(bool status);
 
 protected:
         void createConfigurationInterface(KConfigDialog *parent);
@@ -156,7 +157,8 @@
         Qt::KeyboardModifier m_groupModifierKey;
 
         int m_currentDesktop;
-
+        // a pointer referring to the popup dialog which is showing
+        QWidget *m_popupDialog;
 };
 
 #endif



_______________________________________________
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