Fixing some regressions in the layout preview widget introduced due to the animation.
This change also includes some visual updates which fixes the black corners issue for non composited tabbox (no idea why), the hughe black border in the prview is still visible (also no idea why). svn path=/trunk/KDE/kdebase/workspace/; revision=1070114
This commit is contained in:
parent
10e6e014d9
commit
608f5fab7a
2 changed files with 47 additions and 10 deletions
|
@ -49,6 +49,7 @@ namespace TabBox
|
|||
|
||||
TabBoxView::TabBoxView( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, m_previewUpdate( false )
|
||||
{
|
||||
setWindowFlags( Qt::X11BypassWindowManagerHint );
|
||||
setAttribute( Qt::WA_TranslucentBackground );
|
||||
|
@ -82,6 +83,7 @@ TabBoxView::TabBoxView( QWidget* parent )
|
|||
|
||||
connect( tabBox, SIGNAL(configChanged()), this, SLOT(configChanged()));
|
||||
connect( m_animation, SIGNAL(valueChanged(QVariant)), SLOT(update()));
|
||||
connect( m_tableView, SIGNAL(activated(QModelIndex)), SLOT(setCurrentIndex(QModelIndex)));
|
||||
}
|
||||
|
||||
TabBoxView::~TabBoxView()
|
||||
|
@ -94,9 +96,13 @@ void TabBoxView::paintEvent(QPaintEvent* e)
|
|||
QPainter painter( this );
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setClipRect(e->rect());
|
||||
m_frame->resizeFrame( geometry().size() );
|
||||
m_frame->paintFrame( &painter );
|
||||
// and the selection item
|
||||
if( m_previewUpdate )
|
||||
{
|
||||
m_previewUpdate = false;
|
||||
setCurrentIndex( m_tableView->currentIndex() );
|
||||
}
|
||||
m_selectionFrame->paintFrame( &painter,
|
||||
m_tableView->geometry().topLeft() + m_selectedItem.topLeft() );
|
||||
QWidget::paintEvent(e);
|
||||
|
@ -113,6 +119,13 @@ bool TabBoxView::event( QEvent* event )
|
|||
return QWidget::event( event );
|
||||
}
|
||||
|
||||
void TabBoxView::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
m_frame->resizeFrame( event->size() );
|
||||
setMask( m_frame->mask() );
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void TabBoxView::updateGeometry()
|
||||
{
|
||||
if( m_tableView->model()->columnCount() == 0 || m_tableView->model()->rowCount() == 0 )
|
||||
|
@ -123,10 +136,6 @@ void TabBoxView::updateGeometry()
|
|||
int y = screenRect.y() + screenRect.height() * 0.5 - hint.height() * 0.5;
|
||||
|
||||
setGeometry( x, y, hint.width(), hint.height() );
|
||||
qreal left, top, right, bottom;
|
||||
m_frame->getMargins( left, top, right, bottom );
|
||||
m_frame->resizeFrame( hint + QSizeF( left + right, top + bottom ) );
|
||||
setMask( m_frame->mask() );
|
||||
}
|
||||
|
||||
QSize TabBoxView::sizeHint() const
|
||||
|
@ -323,6 +332,8 @@ void TabBoxView::configChanged()
|
|||
}
|
||||
}
|
||||
setLayout( layout );
|
||||
if( m_preview )
|
||||
m_previewUpdate = true;
|
||||
}
|
||||
|
||||
QModelIndex TabBoxView::indexAt( QPoint pos )
|
||||
|
@ -386,6 +397,13 @@ QSize TabBoxMainView::sizeHint() const
|
|||
rowHeight * model()->rowCount() );
|
||||
}
|
||||
|
||||
QModelIndex TabBoxMainView::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
Q_UNUSED( cursorAction )
|
||||
Q_UNUSED( modifiers )
|
||||
return currentIndex();
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* TabBoxAdditonalView
|
||||
********************************************************/
|
||||
|
@ -434,6 +452,18 @@ QSize TabBoxAdditionalView::sizeHint() const
|
|||
return QSize( columnWidth, rowHeight );
|
||||
}
|
||||
|
||||
QModelIndex TabBoxAdditionalView::moveCursor( QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers )
|
||||
{
|
||||
Q_UNUSED( cursorAction )
|
||||
Q_UNUSED( modifiers )
|
||||
return currentIndex();
|
||||
}
|
||||
|
||||
void TabBoxAdditionalView::wheelEvent( QWheelEvent* event )
|
||||
{
|
||||
Q_UNUSED( event )
|
||||
}
|
||||
|
||||
} // namespace Tabbox
|
||||
} // namespace KWin
|
||||
|
||||
|
|
|
@ -68,14 +68,10 @@ class TabBoxView : public QWidget
|
|||
~TabBoxView();
|
||||
virtual void paintEvent( QPaintEvent* e );
|
||||
virtual bool event( QEvent* event );
|
||||
virtual void resizeEvent( QResizeEvent* event );
|
||||
virtual QSize sizeHint() const;
|
||||
void updateGeometry();
|
||||
|
||||
/**
|
||||
* Sets the current index in the two views.
|
||||
* @param index The new index
|
||||
*/
|
||||
void setCurrentIndex( QModelIndex index );
|
||||
/**
|
||||
* Returns the index at the given position of the main view widget.
|
||||
* @param pos The widget position
|
||||
|
@ -104,6 +100,13 @@ class TabBoxView : public QWidget
|
|||
QRect selectedItem() const { return m_selectedItem; }
|
||||
void setSelectedItem( const QRect& rect ) { m_selectedItem = rect; }
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* Sets the current index in the two views.
|
||||
* @param index The new index
|
||||
*/
|
||||
void setCurrentIndex( QModelIndex index );
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* This slot reacts on a changed TabBoxConfig. It changes the used
|
||||
|
@ -149,6 +152,7 @@ class TabBoxView : public QWidget
|
|||
bool m_preview;
|
||||
QPropertyAnimation* m_animation;
|
||||
QRect m_selectedItem;
|
||||
bool m_previewUpdate;
|
||||
|
||||
};
|
||||
|
||||
|
@ -166,6 +170,7 @@ class TabBoxMainView : public QTableView
|
|||
~TabBoxMainView();
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
virtual QModelIndex moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers );
|
||||
};
|
||||
/**
|
||||
* This class is the additional widget of the TabBoxView.
|
||||
|
@ -181,6 +186,8 @@ class TabBoxAdditionalView : public QTableView
|
|||
~TabBoxAdditionalView();
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
virtual QModelIndex moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers );
|
||||
virtual void wheelEvent( QWheelEvent* event );
|
||||
};
|
||||
|
||||
} // namespace Tabbox
|
||||
|
|
Loading…
Reference in a new issue