Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit fe2be784 authored by Robert Knight's avatar Robert Knight

Animated entry of color schemes in the list.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=677729
parent daa85d19
......@@ -31,6 +31,8 @@
#include <QtGui/QLinearGradient>
#include <QtGui/QRadialGradient>
#include <QtCore/QTimeLine>
// KDE
#include <kcodecaction.h>
#include <KFontDialog>
......@@ -314,7 +316,15 @@ void EditProfileDialog::setupAppearancePage(const Profile* info)
// setup color list
updateColorSchemeList();
_ui->colorSchemeList->setItemDelegate(new ColorSchemeViewDelegate(this));
ColorSchemeViewDelegate* delegate = new ColorSchemeViewDelegate(this);
QTimeLine* timeLine = new QTimeLine( 1000 , this );
delegate->setEntryTimeLine(timeLine);
connect( timeLine , SIGNAL(valueChanged(qreal)) , this ,
SLOT(colorSchemeAnimationUpdate()) );
_ui->colorSchemeList->setItemDelegate(delegate);
_ui->colorSchemeList->setMouseTracking(true);
_ui->colorSchemeList->installEventFilter(this);
......@@ -341,6 +351,16 @@ void EditProfileDialog::setupAppearancePage(const Profile* info)
SLOT(setFontSize(int)) );
connect( _ui->editFontButton , SIGNAL(clicked()) , this ,
SLOT(showFontDialog()) );
// start entry animation
timeLine->start();
}
void EditProfileDialog::colorSchemeAnimationUpdate()
{
QAbstractItemModel* model = _ui->colorSchemeList->model();
for ( int i = model->rowCount() ; i >= 0 ; i-- )
_ui->colorSchemeList->update( model->index(i,0) );
}
void EditProfileDialog::updateFontPreviewLabel(const QFont& font)
{
......@@ -926,9 +946,30 @@ QWidget* ColorSchemeViewDelegate::createEditor(QWidget* parent, const QStyleOpti
}
#endif
void ColorSchemeViewDelegate::setEntryTimeLine(QTimeLine* timeLine)
{
_entryTimeLine = timeLine;
}
void ColorSchemeViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
// entry animation
//
// note that the translation occurs for each item drawn, but the
// painter is not reset between painting items. this means that when
// the items are painted in order ( as occurs when the list is first
// shown ), there is a visually pleasing staggering of items as they
// enter.
if ( _entryTimeLine != 0 )
{
qreal value = 1.0-_entryTimeLine->currentValue();
painter->translate( value *
option.rect.width() , 0 );
painter->setOpacity( _entryTimeLine->currentValue() );
}
const ColorScheme* scheme = index.data(Qt::UserRole + 1).value<const ColorScheme*>();
Q_ASSERT(scheme);
......
......@@ -25,12 +25,14 @@
#include <QtCore/QPair>
#include <QtCore/QHash>
#include <QtCore/QSet>
#include <QtCore/QPointer>
// KDE
#include <KDialog>
class QAbstractButton;
class QTextCodec;
class QTimeLine;
namespace Ui
{
......@@ -121,6 +123,8 @@ private slots:
void fontSelected(const QFont&);
//void previewFont(const QFont&);
void colorSchemeAnimationUpdate();
// scrolling page
void noScrollBack();
void fixedScrollBack();
......@@ -204,6 +208,8 @@ private:
*/
class ColorSchemeViewDelegate : public QAbstractItemDelegate
{
Q_OBJECT
public:
ColorSchemeViewDelegate(QObject* parent = 0);
......@@ -213,6 +219,19 @@ public:
virtual QSize sizeHint( const QStyleOptionViewItem& option,
const QModelIndex& index) const;
/**
* Sets the timeline used to control the entry animation
* for this delegate.
*
* During a call to paint(), the value of the timeLine is used to
* determine how to render the item ( with 0 being the beginning
* of the animation and 1.0 being the end )
*/
void setEntryTimeLine( QTimeLine* timeLine );
private:
QPointer<QTimeLine> _entryTimeLine;
// virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
// const QModelIndex& index) const;
// virtual bool editorEvent(QEvent* event,QAbstractItemModel* model,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment