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

List:       kfm-devel
Subject:    Fw: PATCH: Opera mouse gestures in Konqueror
From:       "Jean-Philippe Bouchard" <jean-philippe.bouchard () mcgill ! ca>
Date:       2001-11-26 14:51:14
[Download RAW message or body]

As requested, here is the patch in unified format...

JPB
----- Original Message -----
From: "Simon Hausmann" <hausmann@kde.org>
To: "Jean-Philippe Bouchard" <jean-philippe.bouchard@mcgill.ca>
Cc: <kfm-devel@kde.org>
Sent: Monday, November 26, 2001 4:13 AM
Subject: Re: PATCH: Opera mouse gestures in Konqueror


> (re-directing from konqueror/embedded list to kfm-devel, which is
> the list where konqueror(desktop) development takes place :)
> re-attaching also the patch, for those not subscribed to the konq-e
> list ;)
>
> On Sat, Nov 24, 2001 at 08:34:50PM -0500, Jean-Philippe Bouchard wrote:
> >     Now about the patch. Ever since Opera started implementing mouse
> > gestures in their browser (http://www.opera.com/windows/mouse.html) I
wanted
> > to have them in Konqueror. The new feature 'Right click goes back in
> > history' of KDE 3 is useful but it is nothing compared to mouse
gestures.
> > Earlier this week, I decided to give the implementation of mouse
gestures in
> > Konqueror a try. I implemented back and forward mouse gestures in this
patch
>
> Very cool! :)
>
> > and want feedback before going further. In particular, I'd like to know
if:
> >
> >     -the patch has a chance to be integrated into Konqueror;
>
> IMHO yes (many people have been asking for that feature) , OTOH
> we're in a feature freeze. Let's see what others (especially Dirk)
> say.
>
> >     -the implementation makes sense (I'm new to QT/KDE and pretty green
in
> > C++);
>
> Yes, looks quite good :)
> (can you re-do the patch as unified diff (with cvs diff -u ...) ?
> makes the patch a bit more readable :)
>
> >     -there should be an option to enable/disable mouse gestures in the
> > settings;
>
> IMHO yes (a simple checkbox should probably do the trick)
>
> >     -we should keep the 'Right click goes back in history' feature and
if
> > so, should it be mutually exclusive with mouse gestures;
>
> Hmm, I guess so. What do others think?
>
>
> Simon
>

["konqueror_mouse_gestures.patch" (application/octet-stream)]

Index: konq_view.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_view.cc,v
retrieving revision 1.281
diff -b -B -w -u -r1.281 konq_view.cc
--- konq_view.cc	2001/11/13 18:01:43	1.281
+++ konq_view.cc	2001/11/26 15:15:15
@@ -83,6 +83,8 @@
   m_browserIface = new KonqBrowserInterface( this, "browseriface" );
   m_bBackRightClick = m_pMainWindow->isBackRightClickEnabled();
 
+  m_sMouseGestures.enabled = true;
+
   switchView( viewFactory );
 }
 
@@ -324,7 +326,7 @@
   if ( urlDropHandling.type() == QVariant::Bool &&
        urlDropHandling.toBool() )
       m_pPart->widget()->installEventFilter( this );
-  if (m_bBackRightClick && m_pPart->widget()->inherits("QScrollView") )
+  if ((m_bBackRightClick || m_sMouseGestures.enabled) && m_pPart->widget()->inherits("QScrollView") )
   {
     (static_cast<QScrollView *>(m_pPart->widget()))->viewport()->installEventFilter( this );
   }
@@ -901,6 +903,52 @@
     if ( !m_pPart )
         return false;
 //  kdDebug() << "--" << obj->className() << "--" << e->type() << "--"  << endl;
+
+    if (m_sMouseGestures.enabled)
+		{
+      // Recording mouse position
+      if (e->type() == QEvent::MouseButtonPress)
+			{
+        QMouseEvent *me = static_cast<QMouseEvent *>(e);
+        if (me->button() == QMouseEvent::RightButton)
+				{
+          m_sMouseGestures.x = me->x();
+          m_sMouseGestures.y = me->y();
+          return true;
+        }
+      }
+      if (e->type() == QEvent::MouseButtonRelease)
+			{
+        QMouseEvent *me = static_cast<QMouseEvent *>(e);
+        if (me->button() == QMouseEvent::RightButton)
+				{
+          // The mouse has moved left or right, we need to go back or forward
+          if (me->x() < m_sMouseGestures.x)
+					{
+            m_pMainWindow->slotBack();
+          }
+          else if (me->x() > m_sMouseGestures.x)
+					{
+            m_pMainWindow->slotForward();
+          }
+          // The mouse hasn't moved, we need to generate the context menu we filtered out earlier 
+          else
+					{
+            obj->removeEventFilter(this);
+            QContextMenuEvent ce(QContextMenuEvent::Mouse, me->pos(), Qt::RightButton);
+            QApplication::sendEvent(obj, &ce);
+            obj->installEventFilter(this);
+            return true;
+          }
+        }
+      }
+      // We need to filter out context menu
+      if (e->type() == QEvent::ContextMenu)
+			{
+        return true;
+      }
+    }
+
     if ( e->type() == QEvent::DragEnter && obj == m_pPart->widget() )
     {
         QDragEnterEvent *ev = static_cast<QDragEnterEvent *>( e );
Index: konq_view.h
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_view.h,v
retrieving revision 1.142
diff -b -B -w -u -r1.142 konq_view.h
--- konq_view.h	2001/11/05 10:59:53	1.142
+++ konq_view.h	2001/11/26 15:15:27
@@ -377,6 +377,12 @@
   KonqViewIface * m_dcopObject;
   KonqBrowserInterface *m_browserIface;
   bool m_bBackRightClick;
+
+private:
+  struct {
+    bool enabled;
+    int x, y;
+  } m_sMouseGestures;
 };
 
 #endif


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

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