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 68971272 authored by Robert Knight's avatar Robert Knight

Delay the live preview of color schemes slightly. The cursor now has to hover...

Delay the live preview of color schemes slightly.  The cursor now has to hover above the same item for 300ms to make it trigger.  This (hopefully) solves the bug report about the automatic preview being inadvertantly triggered while trying to do other things in the dialog.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=711856
parent d15e0ce4
......@@ -31,6 +31,7 @@
#include <QtGui/QLinearGradient>
#include <QtGui/QRadialGradient>
#include <QtCore/QTimer>
#include <QtCore/QTimeLine>
// KDE
......@@ -58,12 +59,13 @@ using namespace Konsole;
EditProfileDialog::EditProfileDialog(QWidget* parent)
: KDialog(parent)
, _colorSchemeAnimationTimeLine(0)
, _delayedPreviewTimer(new QTimer(this))
{
setCaption(i18n("Edit Profile"));
setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply | KDialog::Default );
connect( this , SIGNAL(applyClicked()) , this , SLOT(save()) );
connect( _delayedPreviewTimer , SIGNAL(timeout()) , this , SLOT(delayedPreviewActivate()) );
_ui = new Ui::EditProfileDialog();
_ui->setupUi(mainWidget());
......@@ -518,6 +520,9 @@ bool EditProfileDialog::eventFilter( QObject* watched , QEvent* event )
}
void EditProfileDialog::unpreviewAll()
{
_delayedPreviewTimer->stop();
_delayedPreviewProperties.clear();
QHash<Profile::Property,QVariant> map;
QHashIterator<int,QVariant> iter(_previewedProperties);
while ( iter.hasNext() )
......@@ -532,19 +537,43 @@ void EditProfileDialog::unpreviewAll()
}
void EditProfileDialog::unpreview(int property)
{
_delayedPreviewProperties.remove(property);
if (!_previewedProperties.contains(property))
return;
QHash<Profile::Property,QVariant> map;
map.insert((Profile::Property)property,_previewedProperties[property]);
SessionManager::instance()->changeProfile(_profileKey,map,false);
_previewedProperties.remove(property);
}
void EditProfileDialog::delayedPreview(int property , const QVariant& value)
{
_delayedPreviewProperties.insert(property,value);
QTimer* timer = new QTimer(this);
timer->setSingleShot(true);
_delayedPreviewTimer->stop();
_delayedPreviewTimer->start(300);
}
void EditProfileDialog::delayedPreviewActivate()
{
Q_ASSERT( qobject_cast<QTimer*>(sender()) );
QMutableHashIterator<int,QVariant> iter(_delayedPreviewProperties);
if ( iter.hasNext() )
{
iter.next();
preview(iter.key(),iter.value());
}
}
void EditProfileDialog::preview(int property , const QVariant& value)
{
QHash<Profile::Property,QVariant> map;
map.insert((Profile::Property)property,value);
_delayedPreviewProperties.remove(property);
const Profile* original = lookupProfile();
......@@ -558,7 +587,7 @@ void EditProfileDialog::previewColorScheme(const QModelIndex& index)
{
const QString& name = index.data(Qt::UserRole+1).value<const ColorScheme*>()->name();
preview( Profile::ColorScheme , name );
delayedPreview( Profile::ColorScheme , name );
}
void EditProfileDialog::removeColorScheme()
{
......
......@@ -164,6 +164,9 @@ private slots:
void wordCharactersChanged(const QString&);
void setDefaultCodec(QTextCodec*);
// apply the first previewed changes stored up by delayedPreview()
void delayedPreviewActivate();
private:
// initialize various pages of the dialog
void setupGeneralPage(const Profile* info);
......@@ -183,6 +186,7 @@ private:
void changeCheckedItem( QAbstractItemModel* mode, const QModelIndex& to );
void preview(int property , const QVariant& value);
void delayedPreview(int property , const QVariant& value);
void unpreview(int property);
void unpreviewAll();
......@@ -217,8 +221,11 @@ private:
// after an update by a call to ensurePageLoaded()
QVector<bool> _pageNeedsUpdate;
QHash<int,QVariant> _previewedProperties;
QTimeLine* _colorSchemeAnimationTimeLine;
QHash<int,QVariant> _delayedPreviewProperties;
QTimer* _delayedPreviewTimer;
};
/**
......
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