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