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

List:       kde-core-devel
Subject:    Re: [PATCH] KTabWidget / KTabBar changes for Qt 4.5
From:       Urs Wolfer <uwolfer () kde ! org>
Date:       2009-02-28 13:49:11
Message-ID: 200902281449.12607.uwolfer () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


On Saturday 28 February 2009 13:29:11 Urs Wolfer wrote:
> On Friday 27 February 2009 09:57:24 Jos Poortvliet wrote:
> > On Thu, Feb 26, 2009 at 10:20 PM, Albert Astals Cid <aacid@kde.org> wrote:
> > > A Dimecres, 25 de febrer de 2009, Shaun Reich va escriure:
> > > I know i already was told on IRC my opinion was not worth a cent but i
> > > like MMB tab dragging as it's been working since ages in KDE and people
> > > is used to it (you say people is not but you have the same research
> > > behind than i do so i can say yes)
> >
> > Hmmm I would indeed not pay for it ;-)
> > But seriously, I am also used to the mmb tab dragging. However I think
> > I can get used to the lmb dragging as well, and I think most KDE users
> > won't have a big problem with that either. Then again, if it is rather
> > trivial to keep this behavior backwards compattible I see no reson not
> > to do that.
>
> I have looked a bit into it. It's not easy to readd this functionality. LMB
> is hardcoded in qtabbar.cpp :(
>
> Any ideas what would be the best way to readd MMB moving without
> duplicating most of QTabBars tab moving code?
>
> Anyway, the old move code is still available in KTabBar; it's just
> deprecated for the moment.

Ok, I think I have found a solution add this "compatibilty" feature. Please 
look at the attached patch. It seems to work at least with Konqueror (not 
ported to new KTabWidget), Dolphin (ported) and the ktabwidget test app.

Testing and comments are welcome.

Bye
urs

["ktabbar_mmb_tab_move.patch" (text/x-patch)]

Index: ktabbar.cpp
===================================================================
--- ktabbar.cpp	(revision 933253)
+++ ktabbar.cpp	(working copy)
@@ -47,7 +47,8 @@
         mDragSwitchTab( -1 ),
         mActivateDragSwitchTabTimer( 0 ),
         mTabReorderingEnabled( false ),
-        mTabCloseActivatePrevious( false )
+        mTabCloseActivatePrevious( false ),
+        mMiddleMouseTabMoveInProgress( false)
     {
     }
 
@@ -59,9 +60,11 @@
 
     bool mTabReorderingEnabled : 1;
     bool mTabCloseActivatePrevious : 1;
+    bool mMiddleMouseTabMoveInProgress : 1;
 
 };
 
+#include <kdebug.h>
 KTabBar::KTabBar( QWidget *parent )
     : QTabBar( parent ),
       d( new Private )
@@ -111,6 +114,11 @@
       emit emptyAreaContextMenu( mapToGlobal( event->pos() ) );
     }
     return;
+  } else if (QTabBar::isMovable() && event->button() == Qt::MidButton) {
+    // compatibilty feature for old middle mouse tab moving
+    event->accept();
+    QMouseEvent fakedMouseEvent(event->type(), event->pos(), Qt::LeftButton, \
Qt::LeftButton, event->modifiers()); +    QCoreApplication::sendEvent(this, \
&fakedMouseEvent);  }
 
   QTabBar::mousePressEvent( event );
@@ -134,7 +142,7 @@
         return;
       }
     }
-  } else if ( event->buttons() == Qt::MidButton ) {
+  } else if ( event->buttons() == Qt::MidButton && !isMovable() ) {
     if ( d->mReorderStartTab == -1 ) {
       int delay = KGlobalSettings::dndEventDelay();
       QPoint newPos = event->pos();
@@ -162,6 +170,13 @@
         }
       }
     }
+  } else if ( event->button() == Qt::NoButton && event->buttons() == Qt::MidButton \
&& isMovable() ) { +    // compatibilty feature for old middle mouse tab moving
+    d->mMiddleMouseTabMoveInProgress = true;
+    event->accept();
+    QMouseEvent fakedMouseEvent(event->type(), event->pos(), event->button(), \
Qt::LeftButton, event->modifiers()); +    QCoreApplication::sendEvent(this, \
&fakedMouseEvent); +    return;
   }
 
   QTabBar::mouseMoveEvent( event );
@@ -196,6 +211,14 @@
     break;
 
   case Qt::MidButton:
+    if (d->mMiddleMouseTabMoveInProgress && QTabBar::isMovable()) {
+      // compatibilty feature for old middle mouse tab moving
+      d->mMiddleMouseTabMoveInProgress = false;
+      event->accept();
+      QMouseEvent fakedMouseEvent(event->type(), event->pos(), Qt::LeftButton, \
Qt::LeftButton, event->modifiers()); +      QCoreApplication::sendEvent(this, \
&fakedMouseEvent); +      return;
+    }
     if ( d->mReorderStartTab == -1 ) {
       int tab = selectTab( event->pos() );
       if ( tab != -1 ) {


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

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

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