[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs
From:       Rafael Fernández López <ereslibre () kde ! org>
Date:       2008-02-26 0:52:41
Message-ID: 1203987161.642737.23275.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 779389 by ereslibre:

Animations enable/disable system wide


 M  +49 -3     kdeui/kernel/kglobalsettings.cpp  
 M  +29 -0     kdeui/kernel/kglobalsettings.h  
 M  +2 -3      kdeui/widgets/kfadewidgeteffect.cpp  
 M  +11 -0     kdeui/widgets/klineedit.cpp  
 M  +2 -0      kdeui/widgets/klineedit.h  
 M  +37 -10    kdeui/widgets/klineedit_p.h  
 M  +18 -0     kdeui/widgets/kmainwindow.cpp  
 M  +1 -0      kdeui/widgets/kmainwindow.h  
 M  +3 -0      kdeui/widgets/kmainwindow_p.h  
 M  +28 -14    kio/kfile/kimagefilepreview.cpp  
 M  +1 -0      kio/kfile/kimagefilepreview.h  
 M  +8 -1      kio/kio/kfileitemdelegate.cpp  


--- trunk/KDE/kdelibs/kdeui/kernel/kglobalsettings.cpp #779388:779389
@@ -86,6 +86,7 @@
 static QFont *_largeFont = 0;
 static QFont *_smallestReadableFont = 0;
 //static QColor *_buttonBackground = 0;
+static KGlobalSettings::GraphicEffects _graphicEffects = KGlobalSettings::NoEffects;
 
 static KGlobalSettings::KMouseSettings *s_mouseSettings = 0;
 
@@ -126,17 +127,21 @@
          */
         static void initPaths();
         /**
-         * drop cached values for fonts (called by KApplication)
+         * drop cached values for fonts
          */
         static void rereadFontSettings();
         /**
-         * drop cached values for paths (called by KApplication)
+         * drop cached values for paths
          */
         static void rereadPathSettings();
         /**
-         * drop cached values for mouse settings (called by KApplication)
+         * drop cached values for mouse settings
          */
         static void rereadMouseSettings();
+        /**
+         * drop cached values for settings that aren't in any of the previous groups
+         */
+        static void rereadOtherSettings();
 
         KGlobalSettings *q;
 };
@@ -736,6 +741,29 @@
                        KDE_DEFAULT_ICON_ON_PUSHBUTTON);
 }
 
+KGlobalSettings::GraphicEffects KGlobalSettings::graphicEffectsLevel()
+{
+    // This variable stores whether _graphicEffects has the default value because it \
has not been +    // loaded yet, or if it has been loaded from the user settings or \
defaults and contains a valid +    // value.
+    static bool _graphicEffectsInitialized = false;
+
+    if (!_graphicEffectsInitialized) {
+        _graphicEffectsInitialized = true;
+        Private::rereadOtherSettings();
+    }
+
+    return _graphicEffects;
+}
+
+KGlobalSettings::GraphicEffects KGlobalSettings::graphicEffectsLevelDefault()
+{
+    // For now, let always enable animations by default. The plan is to make
+    // this code a bit smarter. (ereslibre)
+
+    return ComplexAnimationEffects;
+}
+
 bool KGlobalSettings::showFilePreview(const KUrl &url)
 {
     KConfigGroup g(KGlobal::config(), "PreviewSettings");
@@ -792,6 +820,7 @@
 
     case SettingsChanged: {
         KGlobal::config()->reparseConfiguration();
+        rereadOtherSettings();
         SettingsCategory category = static_cast<SettingsCategory>(arg);
         if (category == SETTINGS_PATHS) {
             KGlobalSettings::Private::rereadPathSettings();
@@ -988,6 +1017,23 @@
 }
 
 
+void KGlobalSettings::Private::rereadOtherSettings()
+{
+    KConfigGroup g( KGlobal::config(), "KDE-Global GUI Settings" );
+
+    // Asking for hasKey we do not ask for graphicEffectsLevelDefault() that can
+    // contain some very slow code. If we can save that time, do it. (ereslibre)
+
+    if (g.hasKey("GraphicEffectsLevel")) {
+        _graphicEffects = ((GraphicEffects) g.readEntry("GraphicEffectsLevel", \
QVariant((int) NoEffects)).toInt()); +
+        return;
+    }
+
+    _graphicEffects = KGlobalSettings::graphicEffectsLevelDefault();
+}
+
+
 void KGlobalSettings::Private::applyCursorTheme()
 {
 #if defined(Q_WS_X11) && defined(HAVE_XCURSOR)
--- trunk/KDE/kdelibs/kdeui/kernel/kglobalsettings.h #779388:779389
@@ -407,7 +407,34 @@
      */
     static bool showIconsOnPushButtons();
 
+    enum GraphicEffect {
+        NoEffects               = 0x0000, ///< GUI with no effects at all.
+        GradientEffects         = 0x0001, ///< GUI with only gradients enabled.
+        SimpleAnimationEffects  = 0x0002, ///< GUI with simple animations enabled.
+        ComplexAnimationEffects = 0x0006  ///< GUI with complex animations enabled.
+                                          ///< Note that ComplexAnimationsEffects \
implies SimpleAnimationEffects. +    };
+
+    Q_DECLARE_FLAGS(GraphicEffects, GraphicEffect)
+
     /**
+     * This function determines the desired level of effects on the GUI.
+     *
+     * @return Returns true if user wants builtin animations to be enabled.
+     *
+     * @since 4.1
+     */
+    static GraphicEffects graphicEffectsLevel();
+
+    /**
+     * This function determines the default level of effects on the GUI
+     * depending on the system capabilities.
+     *
+     * @since 4.1
+     */
+    static GraphicEffects graphicEffectsLevelDefault();
+
+    /**
      * This function determines if the user wishes to see previews
      * for the selected url
      *
@@ -550,4 +577,6 @@
     Q_PRIVATE_SLOT(d, void _k_slotNotifyChange(int, int))
 };
 
+Q_DECLARE_OPERATORS_FOR_FLAGS(KGlobalSettings::GraphicEffects)
+
 #endif
--- trunk/KDE/kdelibs/kdeui/widgets/kfadewidgeteffect.cpp #779388:779389
@@ -37,9 +37,8 @@
     Q_D(KFadeWidgetEffect);
     d->q_ptr = this;
     Q_ASSERT(destWidget && destWidget->parentWidget());
-    if (!destWidget || !destWidget->parentWidget() || !destWidget->isVisible()
-            //|| !(KGlobalSettings::graphicEffectsLevel() & \
                KGlobalSettings::SimpleAnimationEffects)
-       ) {
+    if (!destWidget || !destWidget->parentWidget() || !destWidget->isVisible() ||
+        !(KGlobalSettings::graphicEffectsLevel() & \
KGlobalSettings::SimpleAnimationEffects)) {  d->disabled = true;
         hide();
         return;
--- trunk/KDE/kdelibs/kdeui/widgets/klineedit.cpp #779388:779389
@@ -89,6 +89,15 @@
 //        delete completionBox;
     }
 
+    void _k_slotSettingsChanged(int category)
+    {
+        Q_UNUSED(category);
+
+        if (clearButton) {
+            clearButton->setAnimationsEnabled(KGlobalSettings::graphicEffectsLevel() \
& KGlobalSettings::SimpleAnimationEffects); +        }
+    }
+
     static bool initialized;
     static bool backspacePerformsCompletion; // Configuration option
 
@@ -186,6 +195,8 @@
                       mode == KGlobalSettings::CompletionAuto);
     connect( this, SIGNAL(selectionChanged()), this, \
SLOT(slotRestoreSelectionColors()));  
+    connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)), this, \
SLOT(_k_slotSettingsChanged(int))); +
     QPalette p = palette();
     if ( !d->previousHighlightedTextColor.isValid() )
       d->previousHighlightedTextColor=p.color(QPalette::Normal,QPalette::HighlightedText);
                
--- trunk/KDE/kdelibs/kdeui/widgets/klineedit.h #779388:779389
@@ -625,6 +625,8 @@
 private:
     class KLineEditPrivate;
     KLineEditPrivate *const d;
+
+    Q_PRIVATE_SLOT( d, void _k_slotSettingsChanged( int category ) );
 };
 
 #endif
--- trunk/KDE/kdelibs/kdeui/widgets/klineedit_p.h #779388:779389
@@ -27,6 +27,8 @@
 #include <QPaintEvent>
 #include <QTimeLine>
 
+#include <kglobalsettings.h>
+
 class KLineEditButton : public QWidget
 {
     Q_OBJECT
@@ -67,8 +69,12 @@
             m_timeline->setDuration(250);
         }
 
-        if (m_timeline->state() != QTimeLine::Running)
-            m_timeline->start();
+        if (KGlobalSettings::graphicEffectsLevel() & \
KGlobalSettings::SimpleAnimationEffects) { +            if (m_timeline->state() != \
QTimeLine::Running) +                m_timeline->start();
+        } else {
+            setVisible(m_timeline->direction() == QTimeLine::Forward);
+        }
     }
 
     void setPixmap(const QPixmap& p)
@@ -81,20 +87,41 @@
         return m_pixmap;
     }
 
+    void setAnimationsEnabled(bool animationsEnabled)
+    {
+        // We need to set the current time in the case that we had the clear
+        // button shown, for it being painted on the paintEvent(). Otherwise
+        // it wont be painted, resulting (m->timeLine->currentTime() == 0) true,
+        // and therefore a bad painting. This is needed for the case that we
+        // come from a non animated widget and want it animated. (ereslibre)
+        if ((KGlobalSettings::graphicEffectsLevel() & \
KGlobalSettings::SimpleAnimationEffects) && +            m_timeline->direction() == \
QTimeLine::Forward) { +            m_timeline->setCurrentTime(150);
+        }
+    }
+
 protected:
     void paintEvent(QPaintEvent *event)
     {
         Q_UNUSED(event)
 
-        if (m_pixmap.isNull() || m_timeline->currentTime() == 0) {
-            return;
+        if (KGlobalSettings::graphicEffectsLevel() & \
KGlobalSettings::SimpleAnimationEffects) { +            if (m_pixmap.isNull() || \
m_timeline->currentTime() == 0) { +                return;
+            }
+
+            QPainter p(this);
+            p.setOpacity(m_timeline->currentValue());
+            p.drawPixmap((width() - m_pixmap.width()) / 2,
+                        (height() - m_pixmap.height()) / 2,
+                        m_pixmap);
+        } else {
+            QPainter p(this);
+            p.setOpacity(1); // make sure
+            p.drawPixmap((width() - m_pixmap.width()) / 2,
+                        (height() - m_pixmap.height()) / 2,
+                        m_pixmap);
         }
-
-        QPainter p(this);
-        p.setOpacity(m_timeline->currentValue());
-        p.drawPixmap((width() - m_pixmap.width()) / 2,
-                     (height() - m_pixmap.height()) / 2,
-                     m_pixmap);
     }
 
 protected slots:
--- trunk/KDE/kdelibs/kdeui/widgets/kmainwindow.cpp #779388:779389
@@ -58,6 +58,7 @@
 #include <ktoolbar.h>
 #include <kwindowsystem.h>
 #include <kconfiggroup.h>
+#include <kglobalsettings.h>
 
 #if defined Q_WS_X11
 #include <qx11info_x11.h>
@@ -224,6 +225,8 @@
 {
     q = _q;
 
+    q->setAnimated(KGlobalSettings::graphicEffectsLevel() & \
KGlobalSettings::SimpleAnimationEffects); +
     q->setAttribute( Qt::WA_DeleteOnClose );
 
     KWhatsThisManager::init ();
@@ -232,6 +235,8 @@
 
     //actionCollection()->setWidget( this );
     QObject::connect(qApp, SIGNAL(aboutToQuit()), q, SLOT(_k_shuttingDown()));
+    QObject::connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)),
+                     q, SLOT(_k_slotSettingsChanged(int)));
 
     // force KMWSessionManager creation - someone a better idea?
     ksm->dummyInit();
@@ -1052,6 +1057,19 @@
     }
 }
 
+void KMainWindowPrivate::_k_slotSettingsChanged(int category)
+{
+    Q_UNUSED(category);
+
+    // This slot will be called when the style KCM changes settings that need
+    // to be set on the already running applications.
+
+    // At this level (KMainWindow) the only thing we need to restore is the
+    // animations setting (whether the user wants builtin animations or not).
+
+    q->setAnimated(KGlobalSettings::graphicEffectsLevel() & \
KGlobalSettings::SimpleAnimationEffects); +}
+
 KToolBar *KMainWindow::toolBar( const QString& name )
 {
     QString childName = name;
--- trunk/KDE/kdelibs/kdeui/widgets/kmainwindow.h #779388:779389
@@ -701,6 +701,7 @@
     KMainWindowPrivate * const k_ptr;
 private:
     Q_PRIVATE_SLOT(k_func(), void _k_shuttingDown())
+    Q_PRIVATE_SLOT(k_func(), void _k_slotSettingsChanged(int))
 };
 
 #define RESTORE(type) { int n = 1;\
--- trunk/KDE/kdelibs/kdeui/widgets/kmainwindow_p.h #779388:779389
@@ -52,6 +52,9 @@
     QString dbusName;
 
     void _k_shuttingDown();
+    // This slot will be called when the style KCM changes settings that need
+    // to be set on the already running applications.
+    void _k_slotSettingsChanged(int category);
 
     void init(KMainWindow *_q);
     void polish(KMainWindow *q);
--- trunk/KDE/kdelibs/kio/kfile/kimagefilepreview.cpp #779388:779389
@@ -2,6 +2,7 @@
  * This file is part of the KDE project
  * Copyright (C) 2001 Martin R. Jones <mjones@kde.org>
  *               2001 Carsten Pfeiffer <pfeiffer@kde.org>
+ *               2008 Rafael Fernández López <ereslibre@kde.org>
  *
  * You can Freely distribute this program under the GNU Library General Public
  * License. See the file "COPYING" for the exact licensing terms.
@@ -19,6 +20,7 @@
 #include <QtCore/QTimeLine>
 
 #include <kapplication.h>
+#include <kglobalsettings.h>
 #include <kconfig.h>
 #include <kglobal.h>
 #include <kiconloader.h>
@@ -176,15 +178,21 @@
 void KImageFilePreview::gotPreview( const KFileItem& item, const QPixmap& pm )
 {
     if (item.url() == d->currentURL) {  // should always be the case
-        if (d->m_timeLine->state() == QTimeLine::Running) {
-            d->m_timeLine->setCurrentTime(0);
+        if (KGlobalSettings::graphicEffectsLevel() & \
KGlobalSettings::SimpleAnimationEffects) { +            if (d->m_timeLine->state() == \
QTimeLine::Running) { +                d->m_timeLine->setCurrentTime(0);
+            }
+    
+            d->m_pmTransition = pm;
+            d->m_pmTransitionOpacity = 0;
+            d->m_pmCurrentOpacity = 1;
+            d->m_timeLine->setDirection(QTimeLine::Forward);
+            d->m_timeLine->start();
         }
-
-        d->m_pmTransition = pm;
-        d->m_pmTransitionOpacity = 0;
-        d->m_pmCurrentOpacity = 1;
-        d->m_timeLine->setDirection(QTimeLine::Forward);
-        d->m_timeLine->start();
+        else
+        {
+            d->imageLabel->setPixmap(pm);
+        }
     }
 }
 
@@ -250,12 +258,18 @@
         return;
     }
 
-    d->m_pmTransition = QPixmap();
-    d->m_timeLine->setCurrentTime(0);
-    d->m_timeLine->setDirection(QTimeLine::Backward);
-    d->m_timeLine->start();
-    d->currentURL = KUrl();
-    d->clear = true;
+    if (KGlobalSettings::graphicEffectsLevel() & \
KGlobalSettings::SimpleAnimationEffects) { +        d->m_pmTransition = QPixmap();
+        d->m_timeLine->setCurrentTime(0);
+        d->m_timeLine->setDirection(QTimeLine::Backward);
+        d->m_timeLine->start();
+        d->currentURL = KUrl();
+        d->clear = true;
+    }
+    else
+    {
+        d->imageLabel->clear();
+    }
 }
 
 #include "kimagefilepreview.moc"
--- trunk/KDE/kdelibs/kio/kfile/kimagefilepreview.h #779388:779389
@@ -3,6 +3,7 @@
  * This file is part of the KDE project.
  * Copyright (C) 2001 Martin R. Jones <mjones@kde.org>
  *               2001 Carsten Pfeiffer <pfeiffer@kde.org>
+ *               2008 Rafael Fernández López <ereslibre@kde.org>
  *
  * You can Freely distribute this program under the GNU Library General Public
  * License. See the file "COPYING" for the exact licensing terms.
--- trunk/KDE/kdelibs/kio/kio/kfileitemdelegate.cpp #779388:779389
@@ -22,7 +22,6 @@
 #include <config.h>
 
 #include "kfileitemdelegate.h"
-#include "kfileitemdelegate.moc"
 
 #include <QApplication>
 #include <QStyle>
@@ -42,6 +41,7 @@
 #include <kdirmodel.h>
 #include <kfileitem.h>
 #include <kcolorscheme.h>
+#include <kglobalsettings.h>
 
 #include "delegateanimationhandler_p.h"
 
@@ -687,6 +687,10 @@
                                                                 const QModelIndex \
                &index,
                                                                 const \
QAbstractItemView *view) const  {
+    if (!(KGlobalSettings::graphicEffectsLevel() & \
KGlobalSettings::SimpleAnimationEffects)) { +        return NULL;
+    }
+
     if (index.column() == KDirModel::Name)
         return animationHandler->animationState(option, index, view);
 
@@ -1335,4 +1339,7 @@
 }
 
 
+#include "kfileitemdelegate.moc"
+
+
 // kate: space-indent on; indent-width 4; replace-tabs on;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic