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

List:       kde-panel-devel
Subject:    Mouse wheel support for the activity widget
From:       Simone Gaiarin <simone.gaiarin () gmail ! com>
Date:       2011-12-26 19:53:52
Message-ID: CAO-ExudETJemcUzE9tnn7y1bfrLwiKGF+td5HPcGpZG1KTcngg () mail ! gmail ! com
[Download RAW message or body]

Hi,
I've implemented the functionality for changing the activity rolling
the mouse wheel over the showActivityManager plasmoid.
I like this functionality because I can put the widget on the panel
and change the activity without doing 'show desktop>roll over desktop'
or 'open activity panel > select activity > close activity panel',
I've attached a patch to the email. If you like it maybe you can merge
it upstream.
Bye

Simone Gaiarin

["wheel.patch" (application/octet-stream)]

diff -cr showActivityManager/showActivityManager.cpp \
                showActivityManager-new/showActivityManager.cpp
*** showActivityManager/showActivityManager.cpp	2011-12-21 \
                01:40:37.000000000 +0100
--- showActivityManager-new/showActivityManager.cpp	2011-12-26 \
                20:12:04.222375295 +0100
***************
*** 20,25 ****
--- 20,26 ----
  #include "showActivityManager.h"
  
  #include <QGraphicsLinearLayout>
+ #include <QGraphicsSceneWheelEvent>
  #include <QDBusConnection>
  #include <QDBusMessage>
  
***************
*** 70,75 ****
--- 71,115 ----
      QDBusConnection::sessionBus().call(message, QDBus::NoBlock);
  }
  
+ void ShowActivityManager::wheelEvent(QGraphicsSceneWheelEvent *e)
+ {
+     QDBusMessage message;
+     QDBusMessage reply;
+     message = QDBusMessage::createMethodCall("org.kde.kactivitymanagerd",
+                                                           \
"/ActivityManager", +                                                       \
QString(), +                                                           \
"ListActivities");     +     reply = \
QDBusConnection::sessionBus().call(message); +     QStringList activities = \
reply.arguments()[0].toStringList(); +     
+     message = QDBusMessage::createMethodCall("org.kde.kactivitymanagerd",
+                                                           \
"/ActivityManager", +                                                       \
QString(), +                                                           \
"CurrentActivity");     +     reply = \
QDBusConnection::sessionBus().call(message); +     QString currentActivity \
= reply.arguments()[0].toString(); +     
+     int currentIndex = activities.indexOf(currentActivity);
+     int nextIndex;
+     if(e->delta() < 0) 
+         nextIndex = (currentIndex + 1) % activities.size();
+     else
+         if(currentIndex - 1 < 0)
+             nextIndex = activities.size() - 1;
+         else
+             nextIndex = currentIndex - 1;
+ 
+     QString nextActivity = activities[nextIndex];    
+     message = QDBusMessage::createMethodCall("org.kde.kactivitymanagerd",
+                                                           \
"/ActivityManager", +                                                       \
QString(), +                                                           \
"SetCurrentActivity"); +     QList<QVariant> args;
+     args.append(nextActivity);
+     message.setArguments(args);
+     QDBusConnection::sessionBus().call(message);
+ }
+ 
  K_EXPORT_PLASMA_APPLET(showactivitymanager, ShowActivityManager)
  
  #include "showActivityManager.moc"
diff -cr showActivityManager/showActivityManager.h \
                showActivityManager-new/showActivityManager.h
*** showActivityManager/showActivityManager.h	2011-12-21 01:40:37.000000000 \
                +0100
--- showActivityManager-new/showActivityManager.h	2011-12-26 \
                19:32:42.628502480 +0100
***************
*** 36,45 ****
  
  public Q_SLOTS:
      void configChanged();
! 
  protected Q_SLOTS:
      void showManager();
! 
  private:
      Plasma::IconWidget *m_icon;
  };
--- 36,46 ----
  
  public Q_SLOTS:
      void configChanged();
!     
  protected Q_SLOTS:
      void showManager();
!     virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
!     
  private:
      Plasma::IconWidget *m_icon;
  };



_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


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

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