Fix a regression compared to 4.3: animating the selection in classic tabbox
svn path=/trunk/KDE/kdebase/workspace/; revision=1069406
This commit is contained in:
parent
051ac73ecc
commit
e4062507f3
4 changed files with 37 additions and 15 deletions
|
@ -119,13 +119,6 @@ void ClientItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& o
|
|||
return;
|
||||
}
|
||||
|
||||
painter->save();
|
||||
if( option.state & QStyle::State_Selected && m_showSelection )
|
||||
{
|
||||
m_frame->resizeFrame( option.rect.size() );
|
||||
m_frame->paintFrame( painter, option.rect.topLeft() );
|
||||
}
|
||||
painter->restore();
|
||||
qreal left, top, right, bottom;
|
||||
m_frame->getMargins( left, top, right, bottom );
|
||||
|
||||
|
|
|
@ -99,13 +99,6 @@ void DesktopItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
|||
{
|
||||
if( !index.isValid() )
|
||||
return;
|
||||
if( option.state & QStyle::State_Selected )
|
||||
{
|
||||
painter->save();
|
||||
m_frame->resizeFrame( option.rect.size() );
|
||||
m_frame->paintFrame( painter, option.rect.topLeft() );
|
||||
painter->restore();
|
||||
}
|
||||
qreal left, top, right, bottom;
|
||||
m_frame->getMargins( left, top, right, bottom );
|
||||
|
||||
|
|
|
@ -35,10 +35,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <QKeyEvent>
|
||||
#include <QSizePolicy>
|
||||
#include <QPainter>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
// KDE
|
||||
#include <kephal/screens.h>
|
||||
#include <Plasma/FrameSvg>
|
||||
#include <KDebug>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -69,7 +71,16 @@ TabBoxView::TabBoxView( QWidget* parent )
|
|||
m_frame->setCacheAllRenderedFrames( true );
|
||||
m_frame->setEnabledBorders( Plasma::FrameSvg::AllBorders );
|
||||
|
||||
m_selectionFrame = new Plasma::FrameSvg( this );
|
||||
m_selectionFrame->setImagePath( "widgets/viewitem" );
|
||||
m_selectionFrame->setElementPrefix( "hover" );
|
||||
m_selectionFrame->setCacheAllRenderedFrames( true );
|
||||
m_selectionFrame->setEnabledBorders( Plasma::FrameSvg::AllBorders );
|
||||
|
||||
m_animation = new QPropertyAnimation( this, "selectedItem", this );
|
||||
|
||||
connect( tabBox, SIGNAL(configChanged()), this, SLOT(configChanged()));
|
||||
connect( m_animation, SIGNAL(valueChanged(QVariant)), SLOT(update()));
|
||||
}
|
||||
|
||||
TabBoxView::~TabBoxView()
|
||||
|
@ -85,9 +96,13 @@ void TabBoxView::paintEvent(QPaintEvent* e)
|
|||
painter.save();
|
||||
painter.setCompositionMode( QPainter::CompositionMode_Source );
|
||||
painter.fillRect( rect(), Qt::transparent );
|
||||
painter.setClipRegion( m_frame->mask() );
|
||||
m_frame->resizeFrame( geometry().size() );
|
||||
painter.setClipRegion( m_frame->mask() );
|
||||
m_frame->paintFrame( &painter );
|
||||
m_selectionFrame->resizeFrame( m_selectedItem.size() );
|
||||
painter.setCompositionMode( QPainter::CompositionMode_SourceOver );
|
||||
m_selectionFrame->paintFrame( &painter,
|
||||
m_tableView->geometry().topLeft() + m_selectedItem.topLeft() );
|
||||
painter.restore();
|
||||
QWidget::paintEvent(e);
|
||||
}
|
||||
|
@ -165,6 +180,16 @@ void TabBoxView::setCurrentIndex( QModelIndex index )
|
|||
if( index.isValid() )
|
||||
{
|
||||
m_tableView->setCurrentIndex( index );
|
||||
if( m_selectedItem.isNull() )
|
||||
m_selectedItem = m_tableView->visualRect( index );
|
||||
if( m_animation->state() == QPropertyAnimation::Running )
|
||||
m_animation->setEndValue( m_tableView->visualRect( index ) );
|
||||
else
|
||||
{
|
||||
m_animation->setStartValue( m_selectedItem );
|
||||
m_animation->setEndValue( m_tableView->visualRect( index ) );
|
||||
m_animation->start();
|
||||
}
|
||||
m_additionalView->setCurrentIndex( index );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* @since 4.4
|
||||
*/
|
||||
|
||||
class QPropertyAnimation;
|
||||
class QModelIndex;
|
||||
namespace Plasma
|
||||
{
|
||||
|
@ -61,6 +62,7 @@ class TabBoxAdditionalView;
|
|||
class TabBoxView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QRect selectedItem READ selectedItem WRITE setSelectedItem )
|
||||
public:
|
||||
TabBoxView( QWidget* parent = 0 );
|
||||
~TabBoxView();
|
||||
|
@ -98,6 +100,9 @@ class TabBoxView : public QWidget
|
|||
void setPreview( bool preview );
|
||||
bool preview() const { return m_preview; }
|
||||
|
||||
QRect selectedItem() const { return m_selectedItem; }
|
||||
void setSelectedItem( const QRect& rect ) { m_selectedItem = rect; }
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* This slot reacts on a changed TabBoxConfig. It changes the used
|
||||
|
@ -134,9 +139,15 @@ class TabBoxView : public QWidget
|
|||
*/
|
||||
Plasma::FrameSvg* m_frame;
|
||||
/**
|
||||
* The FrameSvg to render selected items
|
||||
*/
|
||||
Plasma::FrameSvg* m_selectionFrame;
|
||||
/**
|
||||
* TabBoxView is a preview
|
||||
*/
|
||||
bool m_preview;
|
||||
QPropertyAnimation* m_animation;
|
||||
QRect m_selectedItem;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue