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

List:       kde-commits
Subject:    Re: [kde-runtime] nepomuk/controller: Fix for the rapid change in
From:       Sebastian TrĂ¼g <trueg () kde ! org>
Date:       2011-10-13 15:43:54
Message-ID: 4E97073A.6020809 () kde ! org
[Download RAW message or body]

Hi Smit,

you did push all the whitespace changes! Please take care to avoid that
the next time.
Also please revert it. :)

Cheers,
Sebastian

On 10/13/2011 05:12 PM, Smit Shah wrote:
> Git commit 928855452437f4bf609cad1614ec497f336b0f08 by Smit Shah.
> Committed on 13/10/2011 at 17:09.
> Pushed by smitshah into branch 'master'.
> 
> Fix for the rapid change in state of nepomukcontroller
> 
> Currently nepomukcontroller tray icon becomes active
> even if the indexing takes less than a second thus
> it goes from active to inactive state again and again
> for small amounts of indexing , this patch adds a timer
> so it will only make the tray icon active if its
> indexing for more than 3 mins using QTimer.
> 
> REVIEW: 102726
> 
> M  +28   -10   nepomuk/controller/systray.cpp
> M  +26   -22   nepomuk/controller/systray.h
> 
> http://commits.kde.org/kde-runtime/928855452437f4bf609cad1614ec497f336b0f08
> 
> diff --git a/nepomuk/controller/systray.cpp b/nepomuk/controller/systray.cpp
> index b67eb6c..3dac44a 100644
> --- a/nepomuk/controller/systray.cpp
> +++ b/nepomuk/controller/systray.cpp
> @@ -65,9 +65,9 @@ Nepomuk::SystemTray::SystemTray( QObject* parent )
> 
> // connect to the file indexer service
> m_service = new org::kde::nepomuk::FileIndexer( \
>                 QLatin1String("org.kde.nepomuk.services.nepomukfileindexer"),
> -                                               \
>                 QLatin1String("/nepomukfileindexer"),
> -                                               QDBusConnection::sessionBus(),
> -                                               this );
> +                                                    \
> QLatin1String("/nepomukfileindexer"), +                                             \
> QDBusConnection::sessionBus(), +                                                    \
> this ); m_serviceControl = new org::kde::nepomuk::ServiceControl( \
> QLatin1String("org.kde.nepomuk.services.nepomukfileindexer"), \
> QLatin1String("/servicecontrol"), QDBusConnection::sessionBus(),
> @@ -84,7 +84,12 @@ Nepomuk::SystemTray::SystemTray( QObject* parent )
> connect( dbusServiceWatcher, SIGNAL( serviceUnregistered( QString ) ),
> this, SLOT( slotUpdateFileIndexerStatus()) );
> 
> +    connect( &m_updateTimer, SIGNAL( timeout() ),
> +             this, SLOT( slotActiveStatusTimeout()) );
> +
> slotUpdateFileIndexerStatus();
> +    m_updateTimer.setSingleShot(true);
> +
> }
> 
> 
> @@ -95,16 +100,25 @@ Nepomuk::SystemTray::~SystemTray()
> 
> void Nepomuk::SystemTray::slotUpdateFileIndexerStatus()
> {
> -    // make sure we do not update the systray icon all the time
> -
> ItemStatus newStatus = status();
> +
> +    // make sure we do not update the systray icon all the time
> const bool fileIndexerInitialized =
> QDBusConnection::sessionBus().interface()->isServiceRegistered(m_service->service()) \
> && m_serviceControl->isInitialized();
> 
> // a manually suspended service should not be passive
> -    if( fileIndexerInitialized )
> -        newStatus = m_service->isIndexing() || m_suspendedManually ? Active : \
> Passive; +    if ( fileIndexerInitialized ) {
> +        if ( m_service->isIndexing() || m_suspendedManually) {
> +            if (!m_updateTimer.isActive()) {
> +                m_updateTimer.start(3000);
> +            }
> +        }
> +        else {
> +            m_updateTimer.stop();
> +            newStatus = Passive;
> +        }
> +    }
> else
> newStatus = Passive;
> if ( newStatus != status() ) {
> @@ -151,8 +165,8 @@ static QRect screenRect( QWidget *widget, int screen )
> KConfig gc( "kdeglobals", KConfig::NoGlobals );
> KConfigGroup cg(&gc, "Windows" );
> if ( desktop->isVirtualDesktop() &&
> -            cg.readEntry( "XineramaEnabled", true ) &&
> -            cg.readEntry( "XineramaPlacementEnabled", true ) ) {
> +         cg.readEntry( "XineramaEnabled", true ) &&
> +         cg.readEntry( "XineramaPlacementEnabled", true ) ) {
> 
> if ( screen < 0 || screen >= desktop->numScreens() ) {
> if ( screen == -1 )
> @@ -178,11 +192,15 @@ void Nepomuk::SystemTray::slotActivateRequested()
> 
> const QRect rect = screenRect( 0, -3 );
> m_statusWidget->move( rect.center().x() - m_statusWidget->width() / 2,
> -                             rect.center().y() - m_statusWidget->height() / 2 );
> +                              rect.center().y() - m_statusWidget->height() / 2 );
> }
> else {
> m_statusWidget->hide();
> }
> }
> 
> +void Nepomuk::SystemTray::slotActiveStatusTimeout()
> +{
> +    setStatus(Active);
> +} 
> #include "systray.moc"
> diff --git a/nepomuk/controller/systray.h b/nepomuk/controller/systray.h
> index 06261b7..e41b5a7 100644
> --- a/nepomuk/controller/systray.h
> +++ b/nepomuk/controller/systray.h
> @@ -20,6 +20,7 @@
> #define _NEPOMUK_CONTROLLER_SYSTRAY_H_
> 
> #include <KStatusNotifierItem>
> +#include <QtCore/QTimer>
> #include "fileindexerinterface.h"
> #include "servicecontrol.h"
> 
> @@ -27,36 +28,39 @@ class KToggleAction;
> 
> namespace Nepomuk {
> 
> -    class FileIndexer;
> -    class StatusWidget;
> +class FileIndexer;
> +class StatusWidget;
> 
> -    class SystemTray : public KStatusNotifierItem
> -    {
> -        Q_OBJECT
> +class SystemTray : public KStatusNotifierItem
> +{
> +    Q_OBJECT
> 
> -    public:
> -        SystemTray( QObject* parent );
> -        ~SystemTray();
> +public:
> +    SystemTray( QObject* parent );
> +    ~SystemTray();
> 
> -    private Q_SLOTS:
> -        void slotUpdateFileIndexerStatus();
> -        void slotConfigure();
> -        void slotSuspend( bool suspended );
> +private Q_SLOTS:
> +    void slotUpdateFileIndexerStatus();
> +    void slotConfigure();
> +    void slotSuspend( bool suspended );
> 
> -        void slotActivateRequested();
> +    void slotActivateRequested();
> +    void slotActiveStatusTimeout();
> 
> -    private:
> -        KToggleAction* m_suspendResumeAction;
> +private:
> +    KToggleAction* m_suspendResumeAction;
> 
> -        org::kde::nepomuk::FileIndexer* m_service;
> -        org::kde::nepomuk::ServiceControl* m_serviceControl;
> -        bool m_suspendedManually;
> +    org::kde::nepomuk::FileIndexer* m_service;
> +    org::kde::nepomuk::ServiceControl* m_serviceControl;
> +    bool m_suspendedManually;
> 
> -        StatusWidget* m_statusWidget;
> +    StatusWidget* m_statusWidget;
> 
> -        // used to prevent endless status updates
> -        QString m_prevStatus;
> -    };
> +    // used to prevent endless status updates
> +    QString m_prevStatus;
> +    QTimer m_updateTimer;
> +
> +};
> }
> 
> #endif
> 
> 


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

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