Merge remote-tracking branch 'origin/KDE/4.7' into origin-frameworks

Conflicts:
	experimental/libkactivities/
	plasma/applet.h
	plasma/theme.cpp
	staging/libkcoreaddons/src/jobs/kjob.cpp
This commit is contained in:
David Faure 2011-12-08 19:05:36 +01:00
commit c7ab521ee7
12 changed files with 116 additions and 89 deletions

View File

@ -58,22 +58,19 @@ AbstractToolBox::~AbstractToolBox()
AbstractToolBox *AbstractToolBox::load(const QString &name, const QVariantList &args, Plasma::Containment *containment)
{
const QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name);
const QString constraint = name.isEmpty() ? QString() : QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name);
KService::List offers = KServiceTypeTrader::self()->query("Plasma/ToolBox", constraint);
if (!offers.isEmpty()) {
KService::Ptr offer = offers.first();
KPluginLoader plugin(*offer);
if (!Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
return 0;
if (Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
return offer->createInstance<AbstractToolBox>(containment, args);
}
return offer->createInstance<AbstractToolBox>(containment, args);
} else {
return 0;
}
return 0;
}
KPluginInfo::List AbstractToolBox::listToolBoxInfo(const QString

View File

@ -1142,6 +1142,8 @@ void Applet::setGlobalShortcut(const KShortcut &shortcut)
foreach (QWidget *w, widgets) {
w->addAction(d->activationAction);
}
} else if (d->activationAction->globalShortcut() == shortcut) {
return;
}
//kDebug() << "before" << shortcut.primary() << d->activationAction->globalShortcut().primary();
@ -1515,6 +1517,7 @@ void Applet::showConfigurationInterface()
#ifndef PLASMA_NO_KUTILS
KCModuleProxy *module = new KCModuleProxy(kcm);
if (module->realModule()) {
connect(module, SIGNAL(changed(bool)), dialog, SLOT(settingsModified(bool)));
dialog->addPage(module, module->moduleInfo().moduleName(), module->moduleInfo().icon());
hasPages = true;
} else {
@ -1621,6 +1624,7 @@ KConfigDialog *AppletPrivate::generateGenericConfigDialog()
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
q->createConfigurationInterface(dialog);
dialog->showButton(KDialog::Default, false);
dialog->showButton(KDialog::Help, false);
QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished()));
QObject::connect(dialog, SIGNAL(okClicked()), q, SLOT(configDialogFinished()));
return dialog;
@ -1644,11 +1648,11 @@ void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog)
if (!shortcutEditor) {
shortcutEditor = new KKeySequenceWidget(page);
QObject::connect(shortcutEditor, SIGNAL(destroyed(QObject*)), q, SLOT(clearShortcutEditorPtr()));
QObject::connect(shortcutEditor.data(), SIGNAL(keySequenceChanged(QKeySequence)), dialog, SLOT(settingsModified()));
}
shortcutEditor->setKeySequence(q->globalShortcut().primary());
layout->addWidget(shortcutEditor);
shortcutEditor.data()->setKeySequence(q->globalShortcut().primary());
layout->addWidget(shortcutEditor.data());
layout->addStretch();
dialog->addPage(page, i18n("Keyboard Shortcut"), "preferences-desktop-keyboard");
@ -1663,7 +1667,9 @@ void AppletPrivate::addPublishPage(KConfigDialog *dialog)
QWidget *page = new QWidget;
publishUI.setupUi(page);
publishUI.publishCheckbox->setChecked(q->isPublished());
QObject::connect(publishUI.publishCheckbox, SIGNAL(clicked(bool)), dialog, SLOT(settingsModified()));
publishUI.allUsersCheckbox->setEnabled(q->isPublished());
QObject::connect(publishUI.allUsersCheckbox, SIGNAL(clicked(bool)), dialog, SLOT(settingsModified()));
QString resourceName =
i18nc("%1 is the name of a plasmoid, %2 the name of the machine that plasmoid is published on",
@ -1689,15 +1695,10 @@ void AppletPrivate::publishCheckboxStateChanged(int state)
}
}
void AppletPrivate::clearShortcutEditorPtr()
{
shortcutEditor = 0;
}
void AppletPrivate::configDialogFinished()
{
if (shortcutEditor) {
QKeySequence sequence = shortcutEditor->keySequence();
QKeySequence sequence = shortcutEditor.data()->keySequence();
if (sequence != q->globalShortcut().primary()) {
q->setGlobalShortcut(KShortcut(sequence));
emit q->configNeedsSaving();
@ -1771,11 +1772,6 @@ void AppletPrivate::updateShortcuts()
void AppletPrivate::propagateConfigChanged()
{
if (script && configLoader) {
configLoader->readConfig();
script->configChanged();
}
if (isContainment) {
Containment *c = qobject_cast<Containment *>(q);
if (c) {
@ -1788,6 +1784,12 @@ void AppletPrivate::propagateConfigChanged()
void Applet::configChanged()
{
if (d->script) {
if (d->configLoader) {
d->configLoader->readConfig();
}
d->script->configChanged();
}
}
void Applet::createConfigurationInterface(KConfigDialog *parent)
@ -2226,7 +2228,6 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
configLoader(0),
actions(AppletPrivate::defaultActions(applet)),
activationAction(0),
shortcutEditor(0),
itemStatus(UnknownStatus),
preferredSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored),
modificationsTimer(0),

View File

@ -992,7 +992,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
Q_PRIVATE_SLOT(d, void cleanUpAndDelete())
Q_PRIVATE_SLOT(d, void selectItemToDestroy())
Q_PRIVATE_SLOT(d, void updateRect(const QRectF& rect))
Q_PRIVATE_SLOT(d, void clearShortcutEditorPtr())
Q_PRIVATE_SLOT(d, void destroyMessageOverlay())
Q_PRIVATE_SLOT(d, void configDialogFinished())
Q_PRIVATE_SLOT(d, void updateShortcuts())
Q_PRIVATE_SLOT(d, void publishCheckboxStateChanged(int state))

View File

@ -155,7 +155,7 @@ void Containment::init()
setCacheMode(NoCache);
setFlag(QGraphicsItem::ItemIsMovable, false);
setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
setAcceptDrops(true);
setAcceptsHoverEvents(true);

View File

@ -517,12 +517,6 @@ void Dialog::keyPressEvent(QKeyEvent *event)
bool Dialog::event(QEvent *event)
{
if (event->type() == QEvent::Paint) {
QPainter p(this);
p.setCompositionMode(QPainter::CompositionMode_Source);
p.fillRect(rect(), Qt::transparent);
}
return QWidget::event(event);
}
@ -738,7 +732,7 @@ void Dialog::animatedHide(Plasma::Direction direction)
return;
}
if (!KWindowSystem::compositingActive()) {
if (!Plasma::Theme::defaultTheme()->windowTranslucencyEnabled()) {
hide();
return;
}
@ -767,7 +761,7 @@ void Dialog::animatedHide(Plasma::Direction direction)
void Dialog::animatedShow(Plasma::Direction direction)
{
if (!KWindowSystem::compositingActive()) {
if (!Plasma::Theme::defaultTheme()->windowTranslucencyEnabled()) {
show();
return;
}
@ -791,7 +785,7 @@ void Dialog::animatedShow(Plasma::Direction direction)
break;
}
if (KWindowSystem::compositingActive()) {
if (Plasma::Theme::defaultTheme()->windowTranslucencyEnabled()) {
Plasma::WindowEffects::slideWindow(this, location);
}

View File

@ -113,7 +113,6 @@ public:
void cleanUpAndDelete();
void addGlobalShortcutsPage(KConfigDialog *dialog);
void addPublishPage(KConfigDialog *dialog);
void clearShortcutEditorPtr();
void configDialogFinished();
KConfigDialog *generateGenericConfigDialog();
void addStandardConfigurationPages(KConfigDialog *dialog);
@ -166,7 +165,7 @@ public:
KAction *activationAction;
// configuration
KKeySequenceWidget *shortcutEditor; //TODO: subclass KConfigDialog and encapsulate this in there
QWeakPointer<KKeySequenceWidget> shortcutEditor; //TODO: subclass KConfigDialog and encapsulate this in there
ItemStatus itemStatus;
KUrl remoteLocation;

View File

@ -58,7 +58,7 @@ bool EffectWatcher::x11Event(XEvent *event)
bool nowEffectActive = isEffectActive();
if (m_effectActive != nowEffectActive) {
m_effectActive = nowEffectActive;
emit blurBehindChanged(m_effectActive);
emit effectChanged(m_effectActive);
}
}
}

View File

@ -41,7 +41,7 @@ protected:
#endif
Q_SIGNALS:
void blurBehindChanged(bool blur);
void effectChanged(bool on);
private:
QString m_property;
@ -50,4 +50,4 @@ private:
}
#endif
#endif

View File

@ -360,10 +360,9 @@ void ToolTip::resizeEvent(QResizeEvent *e)
void ToolTip::paintEvent(QPaintEvent *e)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setClipRect(e->rect());
painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.fillRect(rect(), Qt::transparent);
painter.fillRect(e->rect(), Qt::transparent);
d->background->paintFrame(&painter);
}

View File

@ -84,8 +84,9 @@ public:
defaultWallpaperWidth(DEFAULT_WALLPAPER_WIDTH),
defaultWallpaperHeight(DEFAULT_WALLPAPER_HEIGHT),
pixmapCache(0),
cachesToDiscard(NoCache),
locolor(false),
compositingActive(KWindowSystem::compositingActive()),
compositingActive(KWindowSystem::self()->compositingActive()),
blurActive(false),
isDefault(false),
useGlobal(true),
@ -96,27 +97,32 @@ public:
ThemeConfig config;
cacheTheme = config.cacheTheme();
saveTimer = new QTimer(q);
saveTimer->setSingleShot(true);
saveTimer->setInterval(600);
QObject::connect(saveTimer, SIGNAL(timeout()), q, SLOT(scheduledCacheUpdate()));
updateNotificationTimer = new QTimer(q);
updateNotificationTimer->setSingleShot(true);
updateNotificationTimer->setInterval(500);
QObject::connect(updateNotificationTimer, SIGNAL(timeout()), q, SLOT(notifyOfChanged()));
if (QPixmap::defaultDepth() > 8) {
QObject::connect(KWindowSystem::self(), SIGNAL(compositingChanged(bool)), q, SLOT(compositingChanged(bool)));
#ifdef Q_WS_X11
//watch for blur effect property changes as well
effectWatcher = 0;
effectWatcher = new EffectWatcher("_KDE_NET_WM_BLUR_BEHIND_REGION");
QObject::connect(effectWatcher, SIGNAL(blurBehindChanged(bool)), q, SLOT(blurBehindChanged(bool)));
if (!s_blurEffectWatcher) {
s_blurEffectWatcher = new EffectWatcher("_KDE_NET_WM_BLUR_BEHIND_REGION");
}
QObject::connect(s_blurEffectWatcher, SIGNAL(effectChanged(bool)), q, SLOT(blurBehindChanged(bool)));
#endif
}
saveTimer = new QTimer(q);
saveTimer->setSingleShot(true);
QObject::connect(saveTimer, SIGNAL(timeout()), q, SLOT(scheduledCacheUpdate()));
}
~ThemePrivate()
{
delete pixmapCache;
#ifdef Q_WS_X11
delete effectWatcher;
#endif
}
KConfigGroup &config()
@ -145,6 +151,8 @@ public:
void compositingChanged(bool active);
void discardCache(CacheTypes caches);
void scheduledCacheUpdate();
void scheduleThemeChangeNotification(CacheTypes caches);
void notifyOfChanged();
void colorsChanged();
void blurBehindChanged(bool blur);
bool useCache();
@ -158,6 +166,7 @@ public:
static const char *defaultTheme;
static const char *systemColorsTheme;
static const char *themeRcFile;
static EffectWatcher *s_blurEffectWatcher;
Theme *q;
QString themeName;
@ -181,10 +190,10 @@ public:
QHash<styles, QString> cachedStyleSheets;
QHash<QString, QString> discoveries;
QTimer *saveTimer;
QTimer *updateNotificationTimer;
int toolTipDelay;
CacheTypes cachesToDiscard;
#ifdef Q_WS_X11
EffectWatcher *effectWatcher;
#endif
bool locolor : 1;
bool compositingActive : 1;
bool blurActive : 1;
@ -200,6 +209,7 @@ const char *ThemePrivate::themeRcFile = "plasmarc";
// the system colors theme is used to cache unthemed svgs with colorization needs
// these svgs do not follow the theme's colors, but rather the system colors
const char *ThemePrivate::systemColorsTheme = "internal-system-colors";
EffectWatcher *ThemePrivate::s_blurEffectWatcher = 0;
bool ThemePrivate::useCache()
{
@ -267,8 +277,8 @@ void ThemePrivate::compositingChanged(bool active)
#ifdef Q_WS_X11
if (compositingActive != active) {
compositingActive = active;
discardCache(PixmapCache | SvgElementsCache);
emit q->themeChanged();
//kDebug() << QTime::currentTime();
scheduleThemeChangeNotification(PixmapCache | SvgElementsCache);
}
#endif
}
@ -321,17 +331,31 @@ void ThemePrivate::scheduledCacheUpdate()
void ThemePrivate::colorsChanged()
{
discardCache(PixmapCache);
colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, colors);
buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, colors);
viewColorScheme = KColorScheme(QPalette::Active, KColorScheme::View, colors);
emit q->themeChanged();
scheduleThemeChangeNotification(PixmapCache);
}
void ThemePrivate::blurBehindChanged(bool blur)
{
blurActive = blur;
discardCache(PixmapCache | SvgElementsCache);
if (blurActive != blur) {
blurActive = blur;
scheduleThemeChangeNotification(PixmapCache | SvgElementsCache);
}
}
void ThemePrivate::scheduleThemeChangeNotification(CacheTypes caches)
{
cachesToDiscard |= caches;
updateNotificationTimer->start();
}
void ThemePrivate::notifyOfChanged()
{
//kDebug() << cachesToDiscard;
discardCache(cachesToDiscard);
cachesToDiscard = NoCache;
emit q->themeChanged();
}
@ -496,7 +520,10 @@ void ThemePrivate::settingsFileChanged(const QString &file)
void Theme::settingsChanged()
{
d->setThemeName(d->config().readEntry("name", ThemePrivate::defaultTheme), false);
KConfigGroup cg = d->config();
d->setThemeName(cg.readEntry("name", ThemePrivate::defaultTheme), false);
cg = KConfigGroup(cg.config(), "PlasmaToolTips");
d->toolTipDelay = cg.readEntry("Delay", qreal(0.7));
}
void Theme::setThemeName(const QString &themeName)
@ -631,9 +658,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
cg.sync();
}
discardCache(SvgElementsCache);
emit q->themeChanged();
scheduleThemeChangeNotification(SvgElementsCache);
}
QString Theme::themeName() const
@ -646,9 +671,7 @@ QString Theme::imagePath(const QString &name) const
// look for a compressed svg file in the theme
if (name.contains("../") || name.isEmpty()) {
// we don't support relative paths
#ifndef NDEBUG
kDebug() << "Theme says: bad image path " << name;
#endif
//kDebug() << "Theme says: bad image path " << name;
return QString();
}
@ -908,7 +931,7 @@ void Theme::insertIntoCache(const QString& key, const QPixmap& pix, const QStrin
d->keysToCache.insert(key, id);
d->idsToCache.insert(id, key);
d->saveTimer->start(600);
d->saveTimer->start();
}
}
@ -1032,6 +1055,11 @@ KUrl Theme::homepage() const
return brandConfig.readEntry("homepage", KUrl("http://www.kde.org"));
}
int Theme::toolTipDelay() const
{
return d->toolTipDelay;
}
}
#include <theme.moc>

View File

@ -354,6 +354,11 @@ class PLASMA_EXPORT Theme : public QObject
*/
KUrl homepage() const;
/**
* @return the default tool tip delay; -1 means "no tooltips"
*/
int toolTipDelay() const;
Q_SIGNALS:
/**
* Emitted when the user changes the theme. SVGs should be reloaded at
@ -379,6 +384,7 @@ class PLASMA_EXPORT Theme : public QObject
Q_PRIVATE_SLOT(d, void settingsFileChanged(const QString &))
Q_PRIVATE_SLOT(d, void scheduledCacheUpdate())
Q_PRIVATE_SLOT(d, void onAppExitCleanup())
Q_PRIVATE_SLOT(d, void notifyOfChanged())
};
} // Plasma namespace

View File

@ -139,21 +139,18 @@ void ToolTipManager::show(QGraphicsWidget *widget)
return;
}
qreal delay = 0.0;
ToolTipContent content = d->tooltips[widget];
d->delayedHide = false;
d->hideTimer->stop();
d->showTimer->stop();
const int defaultDelay = Theme::defaultTheme()->toolTipDelay();
if (!content.isInstantPopup()) {
KConfig config("plasmarc");
KConfigGroup cg(&config, "PlasmaToolTips");
delay = cg.readEntry("Delay", qreal(0.7));
if (delay < 0) {
return;
}
if (defaultDelay < 0) {
return;
}
d->hideTimer->stop();
d->delayedHide = false;
d->showTimer->stop();
ToolTipContent content = d->tooltips[widget];
qreal delay = content.isInstantPopup() ? 0.0 : defaultDelay;
d->currentWidget = widget;
if (d->isShown) {
@ -213,6 +210,13 @@ void ToolTipManager::unregisterWidget(QGraphicsWidget *widget)
return;
}
if (widget == d->currentWidget) {
d->currentWidget = 0;
d->showTimer->stop(); // stop the timer to show the tooltip
d->delayedHide = false;
d->hideTipWidget();
}
widget->removeEventFilter(this);
d->removeWidget(widget);
}
@ -345,14 +349,13 @@ void ToolTipManagerPrivate::clearTips()
void ToolTipManagerPrivate::resetShownState()
{
if (currentWidget) {
if (!tipWidget || !tipWidget->isVisible() || delayedHide) {
//One might have moused out and back in again
delayedHide = false;
isShown = false;
currentWidget = 0;
hideTipWidget();
}
if (!tipWidget || !tipWidget->isVisible() || delayedHide) {
//One might have moused out and back in again
showTimer->stop();
delayedHide = false;
isShown = false;
currentWidget = 0;
hideTipWidget();
}
}