--nextPart4562996.JDfoshCzPP Content-Type: multipart/mixed; boundary="Boundary-01=_bx+nJGhPpbuHrLL" Content-Transfer-Encoding: 7bit --Boundary-01=_bx+nJGhPpbuHrLL Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Please review the following patch. Changes related to Qt 4.5 QTabWidget / QTabBar improvements: * Deprecate: * KTabBar/KTabWidget#isTabReorderingEnabled; use QTabBar#setMovable * KTabBar/KTabWidget#setCloseButtonEnabled; use QTabBar#setTabsClosable * KTabBar/KTabWidget#setTabCloseActivatePrevious; use=20 QTabBar#setSelectionBehaviorOnRemove * signal KTabBar#moveTab; port to QTabBar#setMovable and connect to=20 QTabBar#tabMoved * signal KTabBar#closeRequest; connect to QTabBar#tabCloseRequested Remove all the close icon related code; call instead QTabBar code internall= y=20 already. There are some known rendering issues with Qt 4.5 QTabBar which need to be= =20 fixed in Oxygen style. See #184782. Bye urs --Boundary-01=_bx+nJGhPpbuHrLL Content-Type: text/x-patch; charset="UTF-8"; name="ktabbar_ktabwidget_qt45.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ktabbar_ktabwidget_qt45.patch" Index: ktabbar.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- ktabbar.h (revision 929391) +++ ktabbar.h (working copy) @@ -1,6 +1,7 @@ /* This file is part of the KDE libraries Copyright (C) 2003 Stephan Binner Copyright (C) 2003 Zack Rusin + Copyright (C) 2009 Urs Wolfer =20 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -49,13 +50,17 @@ * Sets the tab reordering enabled or disabled. If enabled, * the user can reorder the tabs by drag and drop the tab * headers. + * + * @deprecated Use QTabBar::setMovable() instead. */ =2D void setTabReorderingEnabled( bool enable ); + KDE_DEPRECATED void setTabReorderingEnabled( bool enable ); =20 /** * Returns whether tab reordering is enabled. + * + * @deprecated Use QTabBar::isMovable() instead. */ =2D bool isTabReorderingEnabled() const; + KDE_DEPRECATED bool isTabReorderingEnabled() const; =20 /** * If enabled, a close button is shown above the tab icon. @@ -63,11 +68,11 @@ * close button has been clicked. Note that the tab must have * an icon to use this feature. * =2D * @deprecated Use KTabBar::setCloseButtonEnabled() instead. + * @deprecated Use QTabBar::setTabsClosable() instead. */ KDE_DEPRECATED void setHoverCloseButton( bool ); =20 =2D /** @deprecated Use KTabBar::isCloseButtonEnabled() instead. */ + /** @deprecated Use QTabBar::tabsClosable() instead. */ KDE_DEPRECATED bool hoverCloseButton() const; =20 /** @@ -75,11 +80,11 @@ * minor delay has been passed. This prevents that user * accidentally closes a tab. * =2D * @deprecated Use KTabBar::setCloseButtonEnabled() instead. + * @deprecated Use QTabBar::setTabsClosable() instead. */ KDE_DEPRECATED void setHoverCloseButtonDelayed( bool ); =20 =2D /** @deprecated Use KTabBar::isCloseButtonEnabled() instead. */ + /** @deprecated Use QTabBar::tabsClosable() instead. */ KDE_DEPRECATED bool hoverCloseButtonDelayed() const; =20 /** @@ -88,28 +93,36 @@ * has been clicked. * * @since 4.1 + * + * @deprecated Use QTabBar::setTabsClosable() instead. */ =2D void setCloseButtonEnabled( bool ); + KDE_DEPRECATED void setCloseButtonEnabled( bool ); =20 /** * Returns true if the close button is shown on tabs. * * @since 4.1 + * + * @deprecated Use QTabBar::tabsClosable() instead. */ =2D bool isCloseButtonEnabled() const; + KDE_DEPRECATED bool isCloseButtonEnabled() const; =20 /** * Sets the 'activate previous tab on close' feature enabled * or disabled. If enabled, as soon as you close a tab, the * previously selected tab is activated again. + * + * @deprecated Use QTabBar::setSelectionBehaviorOnRemove() instead. */ =2D void setTabCloseActivatePrevious( bool ); + KDE_DEPRECATED void setTabCloseActivatePrevious( bool ); =20 /** * Returns whether the 'activate previous tab on close' feature * is enabled. + * + * @deprecated Use QTabBar::selectionBehaviorOnRemove() instead. */ =2D bool tabCloseActivatePrevious() const; + KDE_DEPRECATED bool tabCloseActivatePrevious() const; =20 /** * Selects the tab which has a tab header at @@ -135,8 +148,8 @@ void initiateDrag( int ); void testCanDecode( const QDragMoveEvent*, bool& ); void receivedDropEvent( int, QDropEvent* ); =2D void moveTab( int, int ); =2D void closeRequest( int ); + QT_MOC_COMPAT void moveTab( int, int ); + QT_MOC_COMPAT void closeRequest( int ); #ifndef QT_NO_WHEELEVENT void wheelDelta( int ); #endif Index: ktabwidget.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- ktabwidget.cpp (revision 929391) +++ ktabwidget.cpp (working copy) @@ -1,6 +1,7 @@ /* This file is part of the KDE libraries Copyright (C) 2003 Stephan Binner Copyright (C) 2003 Zack Rusin + Copyright (C) 2009 Urs Wolfer =20 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -192,7 +193,7 @@ connect(tabBar(), SIGNAL(testCanDecode(const QDragMoveEvent *, bool & ))= , SIGNAL(testCanDecode(const QDragMoveEvent *, bool & ))); connect(tabBar(), SIGNAL(receivedDropEvent( int, QDropEvent * )), SLOT(r= eceivedDropEvent( int, QDropEvent * ))); connect(tabBar(), SIGNAL(moveTab( int, int )), SLOT(moveTab( int, int ))= ); =2D connect(tabBar(), SIGNAL(closeRequest( int )), SLOT(closeRequest( int = ))); + connect(tabBar(), SIGNAL(tabCloseRequested( int )), SLOT(closeRequest( i= nt ))); connect(tabBar(), SIGNAL(currentChanged( int )), SLOT(currentChanged( in= t ))); #ifndef QT_NO_WHEELEVENT connect(tabBar(), SIGNAL(wheelDelta( int )), SLOT(wheelDelta( int ))); @@ -545,7 +546,7 @@ void KTabWidget::setHoverCloseButton( bool button ) { // deprecated =2D setCloseButtonEnabled( button ); + setTabsClosable( button ); } =20 bool KTabWidget::hoverCloseButton() const @@ -563,17 +564,17 @@ bool KTabWidget::hoverCloseButtonDelayed() const { // deprecated =2D return isCloseButtonEnabled(); + return tabsClosable(); } =20 void KTabWidget::setCloseButtonEnabled( bool enable ) { =2D static_cast( tabBar() )->setCloseButtonEnabled( enable ); + static_cast( tabBar() )->setTabsClosable( enable ); } =20 bool KTabWidget::isCloseButtonEnabled() const { =2D return static_cast( tabBar() )->isCloseButtonEnabled(); + return static_cast( tabBar() )->tabsClosable(); } =20 void KTabWidget::setAutomaticResizeTabs( bool enabled ) Index: ktabbar.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- ktabbar.cpp (revision 929391) +++ ktabbar.cpp (working copy) @@ -1,6 +1,7 @@ /* This file is part of the KDE libraries Copyright (C) 2003 Stephan Binner Copyright (C) 2003 Zack Rusin + Copyright (C) 2009 Urs Wolfer =20 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -44,14 +45,9 @@ : mReorderStartTab( -1 ), mReorderPreviousTab( -1 ), mDragSwitchTab( -1 ), =2D mHoveredCloseIconIndex( -1 ), mActivateDragSwitchTabTimer( 0 ), =2D mHoveredCloseIcon( 0 ), =2D mInactiveCloseIcon( 0 ), =2D mActiveCloseIcon( 0 ), mTabReorderingEnabled( false ), =2D mTabCloseActivatePrevious( false ), =2D mTabCloseButtonClicked( false ) + mTabCloseActivatePrevious( false ) { } =20 @@ -59,16 +55,10 @@ int mReorderStartTab; int mReorderPreviousTab; int mDragSwitchTab; =2D int mHoveredCloseIconIndex; =2D //QTab *mDragSwitchTab; QTimer *mActivateDragSwitchTabTimer; =2D QPixmap *mHoveredCloseIcon; =2D QPixmap *mInactiveCloseIcon; =2D QPixmap *mActiveCloseIcon; =20 bool mTabReorderingEnabled : 1; bool mTabCloseActivatePrevious : 1; =2D bool mTabCloseButtonClicked : 1; =20 }; =20 @@ -82,21 +72,13 @@ d->mActivateDragSwitchTabTimer =3D new QTimer( this ); d->mActivateDragSwitchTabTimer->setSingleShot( true ); connect( d->mActivateDragSwitchTabTimer, SIGNAL( timeout() ), SLOT( acti= vateDragSwitchTab() ) ); + connect( this, SIGNAL(tabCloseRequested(int)), this, SIGNAL(closeRequest= (int))); // just for backward compatibilty, KDE5 remove =20 //connect( this, SIGNAL( layoutChanged() ), SLOT( onLayoutChange() ) ); } =20 KTabBar::~KTabBar() { =2D delete d->mHoveredCloseIcon; =2D d->mHoveredCloseIcon =3D 0; =2D =2D delete d->mInactiveCloseIcon; =2D d->mInactiveCloseIcon =3D 0; =2D =2D delete d->mActiveCloseIcon; =2D d->mActiveCloseIcon =3D 0; =2D delete d; } =20 @@ -113,21 +95,14 @@ emit mouseDoubleClick( tab ); //deprecated emit tabDoubleClicked( tab ); } + + QTabBar::mouseDoubleClickEvent( event ); } =20 void KTabBar::mousePressEvent( QMouseEvent *event ) { if ( event->button() =3D=3D Qt::LeftButton ) { d->mDragStart =3D event->pos(); =2D if ( isCloseButtonEnabled() ) { =2D const QPoint pos =3D event->pos(); =2D const int tabIndex =3D tabAt( pos ); =2D if (closeButtonRect( tabIndex ).contains( pos )) { =2D // the close button is clicked - prevent that the tab gets activ= ated =2D d->mTabCloseButtonClicked =3D true; =2D return; =2D } =2D } } else if( event->button() =3D=3D Qt::RightButton ) { int tab =3D selectTab( event->pos() ); if ( tab !=3D -1 ) { @@ -143,26 +118,6 @@ =20 void KTabBar::mouseMoveEvent( QMouseEvent *event ) { =2D if ( isCloseButtonEnabled() ) { =2D if ( d->mHoveredCloseIconIndex >=3D 0) { =2D // reset previously hovered close button =2D update( closeButtonRect( d->mHoveredCloseIconIndex )); =2D d->mHoveredCloseIconIndex =3D -1; =2D } =2D =2D const QPoint pos =3D event->pos(); =2D const int tabCount =3D count(); =2D for ( int i =3D 0; i < tabCount; ++i ) { =2D const QRect rect =3D closeButtonRect( i ); =2D if (rect.contains( pos )) { =2D // update currently hovered close button =2D d->mHoveredCloseIconIndex =3D i; =2D update( rect ); =2D break; =2D } =2D } =2D } =2D if ( event->buttons() =3D=3D Qt::LeftButton ) { int tab =3D selectTab( event->pos() ); if ( d->mDragSwitchTab && tab !=3D d->mDragSwitchTab ) { @@ -238,16 +193,6 @@ { switch ( event->button() ) { case Qt::LeftButton: =2D if ( isCloseButtonEnabled() ) { =2D update(closeButtonRect( d->mHoveredCloseIconIndex )); =2D =2D const QPoint pos =3D event->pos(); =2D const int tabIndex =3D tabAt( pos ); =2D if (d->mTabCloseButtonClicked && closeButtonRect( tabIndex ).conta= ins( pos )) { =2D d->mHoveredCloseIconIndex =3D -1; =2D emit closeRequest( tabIndex ); =2D } =2D } break; =20 case Qt::MidButton: @@ -269,7 +214,6 @@ break; } =20 =2D d->mTabCloseButtonClicked =3D false; QTabBar::mouseReleaseEvent( event ); } =20 @@ -329,38 +273,16 @@ void KTabBar::paintEvent( QPaintEvent *event ) { QTabBar::paintEvent( event ); =2D =2D if ( isCloseButtonEnabled() ) { =2D QPainter painter( this ); =2D const int tabCount =3D count(); =2D for ( int i =3D 0; i < tabCount; ++i ) { =2D QPixmap icon; =2D if ( i =3D=3D d->mHoveredCloseIconIndex) =2D icon =3D *d->mActiveCloseIcon; =2D else if ( i =3D=3D currentIndex() ) =2D icon =3D *d->mHoveredCloseIcon; =2D else =2D icon =3D *d->mInactiveCloseIcon; =2D =2D painter.drawPixmap( closeButtonPos( i ), icon ); =2D } =2D } } =20 void KTabBar::leaveEvent( QEvent *event ) { QTabBar::leaveEvent( event ); =2D if ( d->mHoveredCloseIconIndex >=3D 0 ) { =2D update( closeButtonRect( d->mHoveredCloseIconIndex )); =2D d->mHoveredCloseIconIndex =3D -1; =2D } } =20 QSize KTabBar::tabSizeHint( int index ) const { QSize size =3D QTabBar::tabSizeHint( index ); =2D if ( isCloseButtonEnabled() ) =2D size.rwidth() +=3D KIconLoader::SizeSmall * 3 / 2; =20 return size; } @@ -399,13 +321,13 @@ void KTabBar::setHoverCloseButton( bool button ) { // deprecated =2D setCloseButtonEnabled( button ); + setTabsClosable(button); } =20 bool KTabBar::hoverCloseButton() const { // deprecated =2D return isCloseButtonEnabled(); + return tabsClosable(); } =20 void KTabBar::setHoverCloseButtonDelayed( bool delayed ) @@ -422,40 +344,12 @@ =20 void KTabBar::setCloseButtonEnabled( bool enable ) { =2D if ( enable =3D=3D isCloseButtonEnabled() ) =2D return; =2D =2D d->mHoveredCloseIconIndex =3D -1; =2D if ( enable ) { =2D Q_ASSERT( d->mHoveredCloseIcon =3D=3D 0 ); =2D Q_ASSERT( d->mInactiveCloseIcon =3D=3D 0 ); =2D Q_ASSERT( d->mActiveCloseIcon =3D=3D 0 ); =2D =2D const QPixmap icon =3D KIconLoader::global()->loadIcon( "dialog-clos= e", KIconLoader::Small ); =2D =2D d->mHoveredCloseIcon =3D new QPixmap( icon ); =2D KIconEffect::semiTransparent( *d->mHoveredCloseIcon ); =2D =2D KIconEffect iconEffect; =2D d->mInactiveCloseIcon =3D new QPixmap( iconEffect.apply( icon, KIcon= Loader::Small, KIconLoader::DisabledState )); =2D =2D KIconEffect::semiTransparent( *d->mInactiveCloseIcon ); =2D d->mActiveCloseIcon =3D new QPixmap( icon ); =2D } else { =2D delete d->mHoveredCloseIcon; =2D d->mHoveredCloseIcon =3D 0; =2D =2D delete d->mInactiveCloseIcon; =2D d->mInactiveCloseIcon =3D 0; =2D =2D delete d->mActiveCloseIcon; =2D d->mActiveCloseIcon =3D 0; =2D } + QTabBar::setTabsClosable(enable); } =20 bool KTabBar::isCloseButtonEnabled() const { =2D return d->mHoveredCloseIcon !=3D 0; + return QTabBar::tabsClosable(); } =20 void KTabBar::tabLayoutChange() @@ -476,41 +370,14 @@ =20 QPoint KTabBar::closeButtonPos( int tabIndex ) const { =2D QPoint buttonPos; =2D if ( tabIndex < 0 ) { =2D return buttonPos; =2D } =2D =2D int availableHeight =3D height(); =2D if ( tabIndex =3D=3D currentIndex() ) { =2D QStyleOption option; =2D option.initFrom(this); =2D availableHeight -=3D style()->pixelMetric( QStyle::PM_TabBarTabShift= Vertical, &option, this ); =2D } =2D =2D const QRect tabBounds =3D tabRect( tabIndex ); =2D const int xInc =3D (height() - KIconLoader::SizeSmall) / 2; =2D =2D if ( layoutDirection() =3D=3D Qt::RightToLeft ) { =2D buttonPos =3D tabBounds.topLeft(); =2D buttonPos.rx() +=3D xInc; =2D } else { =2D buttonPos =3D tabBounds.topRight(); =2D buttonPos.rx() -=3D KIconLoader::SizeSmall + xInc; =2D } =2D buttonPos.ry() +=3D (availableHeight - KIconLoader::SizeSmall) / 2; =2D =2D return buttonPos; + Q_UNUSED(tabIndex); + return QPoint(); } =20 QRect KTabBar::closeButtonRect( int tabIndex ) const { =2D QRect rect; =2D if ( tabIndex >=3D 0 ) { =2D rect.setTopLeft(closeButtonPos( tabIndex )); =2D rect.setSize(QSize( KIconLoader::SizeSmall, KIconLoader::SizeSmall)); =2D } =2D return rect; + Q_UNUSED(tabIndex); + return QRect(); } =20 #include "ktabbar.moc" Index: ktabwidget.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- ktabwidget.h (revision 929391) +++ ktabwidget.h (working copy) @@ -1,6 +1,7 @@ /* This file is part of the KDE libraries Copyright (C) 2003 Stephan Binner Copyright (C) 2003 Zack Rusin + Copyright (C) 2009 Urs Wolfer =20 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -78,6 +79,8 @@ /** * Returns true if tab ordering with the middle mouse button * has been enabled. + * + * @deprecated Use QTabWidget::isMovable() instead. */ bool isTabReorderingEnabled() const; =20 @@ -85,7 +88,7 @@ * Returns true if the close button is shown on tabs * when mouse is hovering over them. * =2D * @deprecated Use KTabWidget::isCloseButtonEnabled() instead. + * @deprecated Use QTabWidget::tabsClosable() instead. */ KDE_DEPRECATED bool hoverCloseButton() const; =20 @@ -93,7 +96,7 @@ * Returns true if the close button is shown on tabs * after a delay. * =2D * @deprecated Use KTabWidget::isCloseButtonEnabled() instead. + * @deprecated Use QTabWidget::setTabsClosable() instead. */ KDE_DEPRECATED bool hoverCloseButtonDelayed() const; =20 @@ -101,14 +104,18 @@ * Returns true if the close button is shown on tabs. * * @since 4.1 + * + * @deprecated Use QTabWidget::tabsClosable() instead. */ =2D bool isCloseButtonEnabled() const; + KDE_DEPRECATED bool isCloseButtonEnabled() const; =20 /** * Returns true if closing the current tab activates the previous * actice tab instead of the one to the right. + * + * @deprecated Use QTabBar::selectionBehaviorOnRemove() instead. */ =2D bool tabCloseActivatePrevious() const; + KDE_DEPRECATED bool tabCloseActivatePrevious() const; =20 /** * Returns true if calling setTitle() will resize tabs @@ -197,15 +204,17 @@ * * You can connect to signal movedTab(int, int) which will notify * you from which index to which index a tab has been moved. + * + * @deprecated Use QTabWidget::setMovable() instead. */ =2D void setTabReorderingEnabled( bool enable ); + QT_MOC_COMPAT void setTabReorderingEnabled( bool enable ); =20 /** * If \a enable is true, a close button will be shown on mouse hover * over tab icons which will emit signal closeRequest( QWidget * ) * when pressed. * =2D * @deprecated Use KTabWidget::setCloseButtonEnabled() instead. + * @deprecated Use QTabWidget::setTabsClosable() instead. */ QT_MOC_COMPAT void setHoverCloseButton( bool enable ); =20 @@ -213,7 +222,7 @@ * If \a delayed is true, a close button will be shown on mouse hover * over tab icons after mouse double click delay else immediately. * =2D * @deprecated Use KTabWidget::setCloseButtonEnabled() instead. + * @deprecated Use QTabWidget::setTabsClosable() instead. */ QT_MOC_COMPAT void setHoverCloseButtonDelayed( bool delayed ); =20 @@ -223,14 +232,18 @@ * has been clicked. * * @since 4.1 + * + * @deprecated Use QTabWidget::setTabsClosable() instead. */ =2D void setCloseButtonEnabled( bool ); + QT_MOC_COMPAT void setCloseButtonEnabled( bool ); =20 /** * If \a previous is true, closing the current tab activates the * previous active tab instead of the one to the right. + * + * @deprecated Use QTabWidget::setSelectionBehaviorOnRemove() instead. */ =2D void setTabCloseActivatePrevious( bool previous ); + QT_MOC_COMPAT void setTabCloseActivatePrevious( bool previous ); =20 /** * If \a enable is true, tabs will be resized to the width of the tab = bar. --Boundary-01=_bx+nJGhPpbuHrLL-- --nextPart4562996.JDfoshCzPP Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEABECAAYFAkmf7FsACgkQooBDqI2Jn8ihKwCdHc17kt1Nc55zM1DyevRTbCpC L94An2Wa42480W6uswguxpop6k1mbJqC =jgok -----END PGP SIGNATURE----- --nextPart4562996.JDfoshCzPP--