┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-06-29 16:42:59 +0000
committerPeter Penz <[email protected]>2008-06-29 16:42:59 +0000
commit85b0ed6a6387e153e9ea205a220fee480ca1d860 (patch)
tree3fc02c788b3de88f3b24d2fcf1aac8f04bc379dd /src
parent5372176640f0d6c114134fa490587c2ce736ad47 (diff)
Don't grey out an invalid preview immediately, but with a small timeout. This prevents a flickering if the new preview can be generated within a small timeframe.
BUG: 165317 svn path=/trunk/KDE/kdebase/apps/; revision=825942
Diffstat (limited to 'src')
-rw-r--r--src/infosidebarpage.cpp39
-rw-r--r--src/infosidebarpage.h9
2 files changed, 39 insertions, 9 deletions
diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp
index 0d0ca48b4..af81ebb29 100644
--- a/src/infosidebarpage.cpp
+++ b/src/infosidebarpage.cpp
@@ -52,6 +52,8 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
SidebarPage(parent),
m_initialized(false),
m_pendingPreview(false),
+ m_infoTimer(0),
+ m_outdatedPreviewTimer(0),
m_shownUrl(),
m_urlCandidate(),
m_fileItem(),
@@ -112,7 +114,7 @@ void InfoSidebarPage::setSelection(const KFileItemList& selection)
if ((count == 1) && !selection.first().url().isEmpty()) {
m_urlCandidate = selection.first().url();
}
- m_infoTimer->start(TimerDelay);
+ m_infoTimer->start();
}
}
@@ -130,12 +132,12 @@ void InfoSidebarPage::requestDelayedItemInfo(const KFileItem& item)
// show information regarding the selection.
if (m_selection.size() > 0) {
m_pendingPreview = false;
- m_infoTimer->start(TimerDelay);
+ m_infoTimer->start();
}
} else if (!item.url().isEmpty()) {
m_urlCandidate = item.url();
m_fileItem = item;
- m_infoTimer->start(TimerDelay);
+ m_infoTimer->start();
}
}
@@ -167,7 +169,7 @@ void InfoSidebarPage::resizeEvent(QResizeEvent* event)
// try to increase the preview as large as possible
m_preview->setSizeHint(QSize(maxWidth, maxWidth));
m_urlCandidate = m_shownUrl; // reset the URL candidate if a resizing is done
- m_infoTimer->start(TimerDelay);
+ m_infoTimer->start();
}
SidebarPage::resizeEvent(event);
@@ -200,9 +202,10 @@ void InfoSidebarPage::showItemInfo()
m_pendingPreview = true;
- KIconEffect iconEffect;
- QPixmap disabledPixmap = iconEffect.apply(m_preview->pixmap(), KIconLoader::Desktop, KIconLoader::DisabledState);
- m_preview->setPixmap(disabledPixmap);
+ // Mark the currently shown preview as outdated. This is done
+ // with a small delay to prevent a flickering when the next preview
+ // can be shown within a short timeframe.
+ m_outdatedPreviewTimer->start();
KIO::PreviewJob* job = KIO::filePreview(list,
m_preview->width(),
@@ -230,8 +233,18 @@ void InfoSidebarPage::slotInfoTimeout()
showItemInfo();
}
+void InfoSidebarPage::markOutdatedPreview()
+{
+ KIconEffect iconEffect;
+ QPixmap disabledPixmap = iconEffect.apply(m_preview->pixmap(),
+ KIconLoader::Desktop,
+ KIconLoader::DisabledState);
+ m_preview->setPixmap(disabledPixmap);
+}
+
void InfoSidebarPage::showIcon(const KFileItem& item)
{
+ m_outdatedPreviewTimer->stop();
m_pendingPreview = false;
if (!applyPlace(item.url())) {
m_preview->setPixmap(item.pixmap(KIconLoader::SizeEnormous));
@@ -241,6 +254,8 @@ void InfoSidebarPage::showIcon(const KFileItem& item)
void InfoSidebarPage::showPreview(const KFileItem& item,
const QPixmap& pixmap)
{
+ m_outdatedPreviewTimer->stop();
+
Q_UNUSED(item);
if (m_pendingPreview) {
m_preview->setPixmap(pixmap);
@@ -453,10 +468,20 @@ void InfoSidebarPage::init()
const int spacing = KDialog::spacingHint();
m_infoTimer = new QTimer(this);
+ m_infoTimer->setInterval(300);
m_infoTimer->setSingleShot(true);
connect(m_infoTimer, SIGNAL(timeout()),
this, SLOT(slotInfoTimeout()));
+ // Initialize timer for disabling an outdated preview with a small
+ // delay. This prevents flickering if the new preview can be generated
+ // within a very small timeframe.
+ m_outdatedPreviewTimer = new QTimer(this);
+ m_outdatedPreviewTimer->setInterval(300);
+ m_outdatedPreviewTimer->setSingleShot(true);
+ connect(m_outdatedPreviewTimer, SIGNAL(timeout()),
+ this, SLOT(markOutdatedPreview()));
+
QVBoxLayout* layout = new QVBoxLayout;
layout->setSpacing(spacing);
diff --git a/src/infosidebarpage.h b/src/infosidebarpage.h
index f2d63de0e..ef451169c 100644
--- a/src/infosidebarpage.h
+++ b/src/infosidebarpage.h
@@ -94,6 +94,12 @@ private slots:
void slotInfoTimeout();
/**
+ * Marks the currently shown preview as outdated
+ * by greying the content.
+ */
+ void markOutdatedPreview();
+
+ /**
* Is invoked if no preview is available for the item. In this
* case the icon will be shown.
*/
@@ -113,8 +119,6 @@ private slots:
void slotLeftDirectory(const QString& directory);
private:
- enum { TimerDelay = 300 };
-
/**
* Checks whether the an URL is repesented by a place. If yes,
* then the place icon and name are shown instead of a preview.
@@ -162,6 +166,7 @@ private:
bool m_initialized;
bool m_pendingPreview;
QTimer* m_infoTimer;
+ QTimer* m_outdatedPreviewTimer;
KUrl m_shownUrl; // URL that is shown as info
KUrl m_urlCandidate; // URL candidate that will replace m_shownURL after a delay
KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null)