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

List:       kde-core-devel
Subject:    [PATCH] Shift-Wheel zoom support in KHTML
From:       Nadeem Hasan <nhasan () nadmm ! com>
Date:       2002-08-11 23:06:18
[Download RAW message or body]

Hi all,

The attached patch implements zoom actions using Shift-Wheel. Its very
minimal and trivial. Ok to commit?

BTW, zooming as implemented in KHTML is buggy. Try it with bugsy and you
will see what I mean.

Cheers,
-- 
Nadeem Hasan
nhasan@nadmm.com
http://www.nadmm.com/


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

? .khtml_part.cpp.swp
? .khtmlview.h.swp
Index: khtml_part.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_part.cpp,v
retrieving revision 1.722
diff -u -r1.722 khtml_part.cpp
--- khtml_part.cpp	2002/08/01 14:08:30	1.722
+++ khtml_part.cpp	2002/08/11 23:02:33
@@ -213,6 +213,8 @@
   d->m_bJavaEnabled = KHTMLFactory::defaultHTMLSettings()->isJavaEnabled();
   d->m_bPluginsEnabled = KHTMLFactory::defaultHTMLSettings()->isPluginsEnabled();
 
+  connect( view, SIGNAL( zoomView( int ) ), SLOT( slotZoomView( int ) ) );
+
   connect( this, SIGNAL( completed() ),
            this, SLOT( updateActions() ) );
   connect( this, SIGNAL( completed( bool ) ),
@@ -3656,6 +3658,14 @@
 
   d->m_paDecZoomFactor->setEnabled( d->m_zoomFactor > minZoom );
   d->m_paIncZoomFactor->setEnabled( d->m_zoomFactor < maxZoom );
+}
+
+void KHTMLPart::slotZoomView( int delta )
+{
+  if ( delta < 0 )
+    slotIncZoom();
+  else
+    slotDecZoom();
 }
 
 void KHTMLPart::setStatusBarText( const QString& text, StatusBarPriority p)
Index: khtml_part.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_part.h,v
retrieving revision 1.191
diff -u -r1.191 khtml_part.h
--- khtml_part.h	2002/07/28 10:49:20	1.191
+++ khtml_part.h	2002/08/11 23:02:33
@@ -993,6 +993,11 @@
    */
   void slotClearSelection();
 
+  /**
+   * @internal
+   */
+  void slotZoomView( int );
+
 private:
 
   enum StatusBarPriority { BarDefaultText, BarHoverText, BarOverrideText };
Index: khtmlview.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.cpp,v
retrieving revision 1.481
diff -u -r1.481 khtmlview.cpp
--- khtmlview.cpp	2002/08/01 15:08:21	1.481
+++ khtmlview.cpp	2002/08/11 23:02:34
@@ -1498,7 +1498,13 @@
 
 void KHTMLView::viewportWheelEvent(QWheelEvent* e)
 {
-    if ( d->ignoreWheelEvents && !verticalScrollBar()->isVisible() && m_part->parentPart() ) {
+    if ( ( e->state() & ShiftButton ) == ShiftButton )
+    {
+        emit zoomView( e->delta() );
+        e->accept();
+    }
+    else if ( d->ignoreWheelEvents && !verticalScrollBar()->isVisible() 
+                && m_part->parentPart() ) {
         if ( m_part->parentPart()->view() )
             m_part->parentPart()->view()->wheelEvent( e );
         e->ignore();
Index: khtmlview.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.h,v
retrieving revision 1.162
diff -u -r1.162 khtmlview.h
--- khtmlview.h	2002/07/31 18:11:43	1.162
+++ khtmlview.h	2002/08/11 23:02:34
@@ -144,6 +144,7 @@
 
 signals:
     void cleared();
+    void zoomView( int );
 
 protected:
     void clear();


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

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