From kde-core-devel Sun Aug 11 23:06:18 2002 From: Nadeem Hasan Date: Sun, 11 Aug 2002 23:06:18 +0000 To: kde-core-devel Subject: [PATCH] Shift-Wheel zoom support in KHTML X-MARC-Message: https://marc.info/?l=kde-core-devel&m=102910736310534 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_q3uV9dcB7yfOuI5" --Boundary-00=_q3uV9dcB7yfOuI5 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8bit Content-Disposition: inline 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/ --Boundary-00=_q3uV9dcB7yfOuI5 Content-Type: text/x-diff; charset="us-ascii"; name="khtml1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="khtml1.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(); --Boundary-00=_q3uV9dcB7yfOuI5--