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

List:       kfm-devel
Subject:    [patch] navigating with side buttons through konqueror history
From:       Nicolas Bellm <nbellm () gmx ! de>
Date:       2004-07-22 17:25:48
Message-ID: 200407221925.48796.nbellm () gmx ! de
[Download RAW message or body]

Hello!

I think now my patch is on the right mailing list:
This patch enables to navigate with the side buttons of a mouse with five 
buttons through the konqueror history. I've read very often that this feature 
is wanted. At most cases these people use imwheel, but I didn't want to use 
it. So I made a patch which directly enables this function in the konqueror.
In this patch I used the QWheel event which reacts to the side buttons.

Nicolas Bellm

["sidebuttons_withoption.diff" (text/x-diff)]

Index: kcontrol/konqhtml/htmlopts.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/konqhtml/htmlopts.cpp,v
retrieving revision 1.85
diff -U3 -r1.85 htmlopts.cpp
--- kcontrol/konqhtml/htmlopts.cpp	13 Jun 2004 11:56:12 -0000	1.85
+++ kcontrol/konqhtml/htmlopts.cpp	14 Jul 2004 20:23:30 -0000
@@ -117,6 +117,22 @@
       "To access the context menu, press the right mouse button and move." ) );
     connect(m_pBackRightClick, SIGNAL(clicked()), this, SLOT(slotChanged()));
 
+    m_pSideButtons = new QCheckBox( i18n( "Navigate with &Forward && Back Internet \
Buttons through the history" ), bgMouse ); +    QWhatsThis::add( m_pSideButtons, \
i18n( +      "If this box is checked, you can navigate through the history with the \
Forward & Back Internet Buttons.<br><br>" +      "For using this function the mouse \
section in your XF86Config have to look like this:" ) + +      "<pre>Section \
\"InputDevice\"<br>" +      "  Identifier      \"Generic Mouse\"<br>"
+      "  Driver          \"mouse\"<br>"
+      "  Option          \"CorePointer\"<br>"
+      "  Option          \"Device\"                \"/dev/psaux\"<br>"
+      "  Option          \"Protocol\"              \"<b>ExplorerPS/2</b>\"<br>"
+      "  Option          \"Emulate3Buttons\"       \"false\"<br>"
+      "  Option          \"ZAxisMapping\"          \"<b>4 5</b>\"<br>"
+      "  Option          \"Buttons\"               \"7\"<br>"
+      "EndSection</pre>" );
+    connect(m_pSideButtons, SIGNAL(clicked()), this, SLOT(slotChanged()));
+    
     lay->addMultiCellWidget( bgMouse, row, row, 0, 1 );
     row++;
 
@@ -202,6 +218,7 @@
     SET_GROUP( "MainView Settings" );
     bool bOpenMiddleClick = READ_BOOL( "OpenMiddleClick", true );
     bool bBackRightClick = READ_BOOL( "BackRightClick", false );
+    bool bSideButtons = READ_BOOL( "SideButtons", true );
     SET_GROUP( "HTML Settings" );
     bool changeCursor = READ_BOOL("ChangeCursor", KDE_DEFAULT_CHANGECURSOR);
     bool underlineLinks = READ_BOOL("UnderlineLinks", DEFAULT_UNDERLINELINKS);
@@ -217,6 +234,7 @@
     m_pAutoRedirectCheckBox->setChecked( bAutoRedirect );
     m_pOpenMiddleClick->setChecked( bOpenMiddleClick );
     m_pBackRightClick->setChecked( bBackRightClick );
+    m_pSideButtons->setChecked( bSideButtons );
 
     // we use two keys for link underlining so that this config file
     // is backwards compatible with KDE 2.0.  the HoverLink setting
@@ -268,6 +286,7 @@
     m_pConfig->setGroup( "MainView Settings" );
     m_pConfig->writeEntry( "OpenMiddleClick", m_pOpenMiddleClick->isChecked() );
     m_pConfig->writeEntry( "BackRightClick", m_pBackRightClick->isChecked() );
+    m_pConfig->writeEntry( "SideButtons", m_pSideButtons->isChecked() );
     m_pConfig->setGroup( "HTML Settings" );
     m_pConfig->writeEntry( "ChangeCursor", m_cbCursor->isChecked() );
     m_pConfig->writeEntry( "AutoLoadImages", m_pAutoLoadImagesCheckBox->isChecked() \
                );
Index: kcontrol/konqhtml/htmlopts.h
===================================================================
RCS file: /home/kde/kdebase/kcontrol/konqhtml/htmlopts.h,v
retrieving revision 1.34
diff -U3 -r1.34 htmlopts.h
--- kcontrol/konqhtml/htmlopts.h	13 Jun 2004 11:56:12 -0000	1.34
+++ kcontrol/konqhtml/htmlopts.h	14 Jul 2004 20:23:30 -0000
@@ -56,6 +56,7 @@
     QCheckBox* m_pAutoRedirectCheckBox;
     QCheckBox* m_pOpenMiddleClick;
     QCheckBox* m_pBackRightClick;
+    QCheckBox* m_pSideButtons;
     QCheckBox* m_pShowMMBInTabs;
     QCheckBox* m_pFormCompletionCheckBox;
     QCheckBox* m_pDynamicTabbarHide;
Index: konqueror/konq_mainwindow.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_mainwindow.cc,v
retrieving revision 1.1337
diff -U3 -r1.1337 konq_mainwindow.cc
--- konqueror/konq_mainwindow.cc	29 Jun 2004 09:59:08 -0000	1.1337
+++ konqueror/konq_mainwindow.cc	14 Jul 2004 20:23:42 -0000
@@ -257,6 +257,7 @@
   m_bHTMLAllowed = config->readBoolEntry( "HTMLAllowed", false );
   m_sViewModeForDirectory = config->readEntry( "ViewMode" );
   m_bBackRightClick = config->readBoolEntry( "BackRightClick", false );
+  m_bSideButtons = config->readBoolEntry( "SideButtons", true );
 
   m_ptaUseHTML->setChecked( m_bHTMLAllowed );
   m_paSaveViewPropertiesLocally->setChecked( m_bSaveViewPropertiesLocally );
@@ -4389,6 +4390,7 @@
   KConfig *config = KGlobal::config();
   KConfigGroupSaver cgs(config,"MainView Settings");
   m_bBackRightClick = config->readBoolEntry( "BackRightClick", false );
+  m_bSideButtons = config->readBoolEntry( "SideButtons", true );
   m_bSaveViewPropertiesLocally = config->readBoolEntry( "SaveViewPropertiesLocally", \
false );  m_bHTMLAllowed = config->readBoolEntry( "HTMLAllowed", false );
   m_sViewModeForDirectory = config->readEntry( "ViewMode" );
Index: konqueror/konq_mainwindow.h
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_mainwindow.h,v
retrieving revision 1.436
diff -U3 -r1.436 konq_mainwindow.h
--- konqueror/konq_mainwindow.h	12 Jun 2004 22:13:09 -0000	1.436
+++ konqueror/konq_mainwindow.h	14 Jul 2004 20:23:43 -0000
@@ -226,6 +226,8 @@
 
   bool isBackRightClickEnabled() const { return m_bBackRightClick; }
 
+  bool isSideButtonsEnabled() const { return m_bSideButtons; }
+
   bool saveViewPropertiesLocally() const { return m_bSaveViewPropertiesLocally; }
 
   static QPtrList<KonqMainWindow> *mainWindowList() { return s_lstViews; }
@@ -709,6 +711,8 @@
 
   bool m_bBackRightClick;
 
+  bool m_bSideButtons;
+
   static bool s_preloaded;
   static KonqMainWindow* s_preloadedWindow;
   static int s_initialMemoryUsage;
Index: konqueror/konq_view.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_view.cc,v
retrieving revision 1.353
diff -U3 -r1.353 konq_view.cc
--- konqueror/konq_view.cc	13 Mar 2004 13:15:52 -0000	1.353
+++ konqueror/konq_view.cc	14 Jul 2004 20:23:46 -0000
@@ -95,6 +95,7 @@
   m_bPopupMenuEnabled = true;
   m_browserIface = new KonqBrowserInterface( this, "browseriface" );
   m_bBackRightClick = m_pMainWindow->isBackRightClickEnabled();
+  m_bSideButtons = m_pMainWindow->isSideButtonsEnabled();
   m_bFollowActive = false;
   m_bBuiltinView = false;
   m_bURLDropHandling = false;
@@ -1104,6 +1105,7 @@
              m_pMainWindow, SLOT( slotPopupMenu( KXMLGUIClient *, const QPoint &, \
const KURL &, const QString &, mode_t ) ) );  }
   enableBackRightClick( m_bBackRightClick );
+  enableSideButtons( m_bSideButtons );
 }
 
 // caller should ensure that this is called only when b changed, or for new parts
@@ -1111,24 +1113,49 @@
 {
     m_bBackRightClick = b;
     if ( b )
+    {
         connect( this, SIGNAL( backRightClick() ),
                  m_pMainWindow, SLOT( slotBack() ) );
+    }
     else
+    {
         disconnect( this, SIGNAL( backRightClick() ),
                     m_pMainWindow, SLOT( slotBack() ) );
+    }
+}
+
+void KonqView::enableSideButtons( bool b )
+{
+    m_bSideButtons = b;
+    if ( b )
+    {
+        connect( this, SIGNAL( back() ),
+                 m_pMainWindow, SLOT( slotBack() ) );
+        connect( this, SIGNAL( forward() ),
+                 m_pMainWindow, SLOT( slotForward() ) );
+    }
+    else
+    {
+        disconnect( this, SIGNAL( back() ),
+                    m_pMainWindow, SLOT( slotBack() ) );
+        disconnect( this, SIGNAL( forward() ),
+                    m_pMainWindow, SLOT( slotForward() ) );
+    }
 }
 
 void KonqView::reparseConfiguration()
 {
     callExtensionMethod( "reparseConfiguration()" );
     bool b = m_pMainWindow->isBackRightClickEnabled();
-    if ( m_bBackRightClick != b )
+    bool c = m_pMainWindow->isSideButtonsEnabled();
+    if ( m_bBackRightClick != b || m_bSideButtons != c )
     {
         if (m_bBackRightClick && m_pPart->widget()->inherits("QScrollView") )
         {
             (static_cast<QScrollView \
*>(m_pPart->widget()))->viewport()->installEventFilter( this );  }
         enableBackRightClick( b );
+        enableSideButtons( c );
     }
 }
 
@@ -1176,6 +1203,22 @@
         if ( ok && ext && lstDragURLs.first().isValid() )
             emit ext->openURLRequest( lstDragURLs.first() ); // this will call \
m_pMainWindow::slotOpenURLRequest delayed  }
+    
+    if ( m_bSideButtons )
+    {
+        if ( e->type() == QEvent::Wheel )
+        {
+            QWheelEvent *ev = static_cast<QWheelEvent *>( e );
+    
+            if ( ev->orientation() == Horizontal )
+            {
+                if ( ev->delta() > 0 )
+                    emit back();
+                else
+                    emit forward();
+            }
+        }
+    }
 
     if ( m_bBackRightClick )
     {
Index: konqueror/konq_view.h
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_view.h,v
retrieving revision 1.169
diff -U3 -r1.169 konq_view.h
--- konqueror/konq_view.h	24 Feb 2004 11:30:13 -0000	1.169
+++ konqueror/konq_view.h	14 Jul 2004 20:23:47 -0000
@@ -309,6 +309,12 @@
    * Emitted only if the option backRightClick is activated
    */
   void backRightClick();
+  
+  /**
+   * Emitted only if the option sideButtons is activated
+   */
+  void back();
+  void forward();
 
 public slots:
   /**
@@ -351,6 +357,8 @@
 
 private:
   void enableBackRightClick( bool b );
+  
+  void enableSideButtons( bool b );
   /**
    * Replace the current view with a new view, created by @p viewFactory.
    */
@@ -432,8 +440,9 @@
   QString m_caption;
   KonqViewIface * m_dcopObject;
   KonqBrowserInterface *m_browserIface;
-  bool m_bBackRightClick;
-  bool m_bHierarchicalView;
+  bool m_bBackRightClick:1;
+  bool m_bSideButtons:1;
+  bool m_bHierarchicalView:1;
   int m_randID;
 };
 



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

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