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

List:       kde-devel
Subject:    Re: KMenu title patch
From:       Rafael =?utf-8?q?Fern=C3=A1ndez_L=C3=B3pez?= <ereslibre () kde ! org>
Date:       2008-04-29 22:59:37
Message-ID: 200804300059.40319.ereslibre () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi all,

Attached is my proposal. Through an event filter.

Do you want me to commit this ?


Regards,
Rafael Fern=C3=A1ndez L=C3=B3pez

GPG Fingerprint: B9F4 4730 43F8 FFDD CC5E BA8E 724E 406E 3F01 D070

["kdelibs-kmenu.diff" (text/x-diff)]

Index: kdeui/widgets/kmenu.cpp
===================================================================
--- kdeui/widgets/kmenu.cpp	(revisiĆ³n: 802558)
+++ kdeui/widgets/kmenu.cpp	(copia de trabajo)
@@ -21,6 +21,7 @@
 #include "kmenu.h"
 #include "khbox.h"
 
+#include <QtCore/QObject>
 #include <QtCore/QPointer>
 #include <QtCore/QTimer>
 #include <QtGui/QApplication>
@@ -40,24 +41,8 @@
 class KMenu::KMenuPrivate
 {
 public:
-    KMenuPrivate (KMenu *_parent)
-        : parent(_parent)
-        , noMatches(false)
-        , shortcuts(false)
-        , autoExec(false)
-        , lastHitAction(0L)
-        , mouseButtons(Qt::NoButton)
-        , keyboardModifiers(Qt::NoModifier)
-        , ctxMenu(0)
-        , highlightedAction(0)
-    {
-        resetKeyboardVars();
-    }
-
-    ~KMenuPrivate ()
-    {
-        delete ctxMenu;
-    }
+    KMenuPrivate (KMenu *_parent);
+    ~KMenuPrivate ();
 
     void resetKeyboardVars(bool noMatches = false);
     void actionHovered(QAction* action);
@@ -82,8 +67,54 @@
     // support for RMB menus on menus
     QMenu* ctxMenu;
     QPointer<QAction> highlightedAction;
+
+    class EventSniffer;
+    EventSniffer *eventSniffer;
 };
 
+class KMenu::KMenuPrivate::EventSniffer
+    : public QObject
+{
+public:
+    EventSniffer(QObject *parent = 0)
+        : QObject(parent) { }
+
+    ~EventSniffer() { }
+
+    bool eventFilter(QObject *object, QEvent *event)
+    {
+        Q_UNUSED(object);
+
+        if (event->type() == QEvent::Paint) {
+            return false;
+        }
+
+        event->accept();
+        return true;
+    }
+};
+
+KMenu::KMenuPrivate::KMenuPrivate (KMenu *_parent)
+    : parent(_parent)
+    , noMatches(false)
+    , shortcuts(false)
+    , autoExec(false)
+    , lastHitAction(0L)
+    , mouseButtons(Qt::NoButton)
+    , keyboardModifiers(Qt::NoModifier)
+    , ctxMenu(0)
+    , highlightedAction(0)
+    , eventSniffer(new EventSniffer)
+{
+    resetKeyboardVars();
+}
+
+KMenu::KMenuPrivate::~KMenuPrivate ()
+{
+    delete ctxMenu;
+    delete eventSniffer;
+}
+
 
 /**
  * custom variant type for QAction::data of kmenu context menus
@@ -143,6 +174,7 @@
 
     QWidgetAction *action = new QWidgetAction(this);
     QToolButton *titleButton = new QToolButton(this);
+    titleButton->installEventFilter(d->eventSniffer);
     titleButton->setDefaultAction(buttonAction);
     titleButton->setDown(true); // prevent hover style changes in some styles
     titleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

["signature.asc" (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


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

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