Do expensive loading operations in the Dolphin Preferences when getting the QShowEvent and not the QPolish event.

svn path=/trunk/KDE/kdebase/apps/; revision=1111143
This commit is contained in:
Peter Penz 2010-04-04 22:51:39 +00:00
parent 110cbf5b27
commit 04a30d8803
4 changed files with 34 additions and 29 deletions

View file

@ -22,15 +22,6 @@
#include "dolphin_generalsettings.h"
#include <QCheckBox>
#include <QEvent>
#include <QGroupBox>
#include <QLabel>
#include <QListWidget>
#include <QRadioButton>
#include <QSlider>
#include <QBoxLayout>
#include <kconfiggroup.h>
#include <kdialog.h>
#include <kglobal.h>
@ -39,7 +30,15 @@
#include <KNumInput>
#include <kservicetypetrader.h>
#include <kservice.h>
#include <kvbox.h>
#include <QCheckBox>
#include <QGroupBox>
#include <QLabel>
#include <QListWidget>
#include <QRadioButton>
#include <QShowEvent>
#include <QSlider>
#include <QBoxLayout>
// default settings
const bool USE_THUMBNAILS = true;
@ -138,22 +137,25 @@ void PreviewsSettingsPage::restoreDefaults()
m_useFileThumbnails->setChecked(USE_THUMBNAILS);
}
bool PreviewsSettingsPage::event(QEvent* event)
void PreviewsSettingsPage::showEvent(QShowEvent* event)
{
if ((event->type() == QEvent::Polish) && !m_initialized) {
// load all available plugins for previews
const KService::List plugins = KServiceTypeTrader::self()->query("ThumbCreator");
foreach (const KSharedPtr<KService>& service, plugins) {
QListWidgetItem* item = new QListWidgetItem(service->name(),
m_previewPluginsList);
item->setData(Qt::UserRole, service->desktopEntryName());
const bool show = m_enabledPreviewPlugins.contains(service->desktopEntryName());
item->setCheckState(show ? Qt::Checked : Qt::Unchecked);
}
if (!event->spontaneous() && !m_initialized) {
QMetaObject::invokeMethod(this, "loadPreviewPlugins", Qt::QueuedConnection);
m_initialized = true;
}
return SettingsPageBase::event(event);
SettingsPageBase::showEvent(event);
}
void PreviewsSettingsPage::loadPreviewPlugins()
{
const KService::List plugins = KServiceTypeTrader::self()->query("ThumbCreator");
foreach (const KSharedPtr<KService>& service, plugins) {
QListWidgetItem* item = new QListWidgetItem(service->name(),
m_previewPluginsList);
item->setData(Qt::UserRole, service->desktopEntryName());
const bool show = m_enabledPreviewPlugins.contains(service->desktopEntryName());
item->setCheckState(show ? Qt::Checked : Qt::Unchecked);
}
}
void PreviewsSettingsPage::loadSettings()

View file

@ -50,7 +50,10 @@ public:
virtual void restoreDefaults();
protected:
virtual bool event(QEvent* event);
virtual void showEvent(QShowEvent* event);
private slots:
void loadPreviewPlugins();
private:
void loadSettings();

View file

@ -34,12 +34,12 @@
#include <kstandarddirs.h>
#include <QCheckBox>
#include <QEvent>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QListWidget>
#include <QPushButton>
#include <QShowEvent>
ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) :
SettingsPageBase(parent),
@ -131,14 +131,14 @@ void ServicesSettingsPage::restoreDefaults()
}
}
bool ServicesSettingsPage::event(QEvent* event)
void ServicesSettingsPage::showEvent(QShowEvent* event)
{
if ((event->type() == QEvent::Polish) && !m_initialized) {
if (!event->spontaneous() && !m_initialized) {
QMetaObject::invokeMethod(this, "loadServices", Qt::QueuedConnection);
QMetaObject::invokeMethod(this, "loadVersionControlSystems", Qt::QueuedConnection);
m_initialized = true;
}
return SettingsPageBase::event(event);
SettingsPageBase::showEvent(event);
}
void ServicesSettingsPage::loadServices()

View file

@ -46,7 +46,7 @@ public:
virtual void restoreDefaults();
protected:
virtual bool event(QEvent* event);
virtual void showEvent(QShowEvent* event);
private slots:
/**