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

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/applets/pager
From:       Loic Marteau <loic.marteau () gmail ! com>
Date:       2009-02-20 12:03:21
Message-ID: 1235131401.222454.16859.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 928901 by lmarteau:

User can now toggle the desktop or the dashboard when he click on the current desktop \
in the pager. UI to select the desired action.
Default is "do nothing".


 M  +49 -0     pager.cpp  
 M  +9 -0      pager.h  
 M  +34 -0     pagerConfig.ui  


--- trunk/KDE/kdebase/workspace/plasma/applets/pager/pager.cpp #928900:928901
@@ -28,6 +28,7 @@
 #include <QGraphicsSceneHoverEvent>
 #include <QTimer>
 #include <QX11Info>
+#include <QDBusInterface>
 
 #include <KDialog>
 #include <KColorScheme>
@@ -57,10 +58,12 @@
 Pager::Pager(QObject *parent, const QVariantList &args)
     : Plasma::Applet(parent, args),
       m_displayedText(None),
+      m_currentDesktopSelected(DoNothing),
       m_showWindowIcons(false),
       m_showOwnBackground(false),
       m_rows(2),
       m_columns(0),
+      m_desktopDown(false),
       m_hoverIndex(-1),
       m_colorScheme(0),
       m_dragId(0),
@@ -92,6 +95,7 @@
     m_displayedText = (DisplayedText)cg.readEntry("displayedText", \
                (int)m_displayedText);
     m_showWindowIcons = cg.readEntry("showWindowIcons", m_showWindowIcons);
     m_rows = globalConfig().readEntry("rows", m_rows);
+    m_currentDesktopSelected = \
(CurrentDesktopSelected)cg.readEntry("currentDesktopSelected", \
(int)m_currentDesktopSelected);  
     if (m_rows < 1) {
         m_rows = 1;
@@ -219,6 +223,20 @@
     ui.showWindowIconsCheckBox->setChecked(m_showWindowIcons);
     ui.spinRows->setValue(m_rows);
     ui.spinRows->setMaximum(m_desktopCount);
+
+    switch (m_currentDesktopSelected){
+        case DoNothing:
+            ui.doNothingRadioButton->setChecked(true);
+            break;
+
+        case ShowDesktop:
+            ui.showDesktopRadioButton->setChecked(true);
+            break;
+
+        case ShowDashboard:
+            ui.showDashboardRadioButton->setChecked(true);
+            break;
+    }
 }
 
 void Pager::recalculateGeometry()
@@ -435,6 +453,22 @@
         changed = true;
     }
 
+    CurrentDesktopSelected currentDesktopSelected;
+
+    if (ui.doNothingRadioButton->isChecked()) {
+        currentDesktopSelected = DoNothing;
+    } else if (ui.showDesktopRadioButton->isChecked()) {
+        currentDesktopSelected = ShowDesktop;
+    } else {
+        currentDesktopSelected = ShowDashboard;
+    }
+
+    if ((int)m_currentDesktopSelected != (int)currentDesktopSelected) {
+        m_currentDesktopSelected = currentDesktopSelected;
+        cg.writeEntry("currentDesktopSelected", (int)m_currentDesktopSelected);
+        changed = true;
+    }
+
     // we need to keep all pager applets consistent since this affects
     // the layout of the desktops as used by the window manager,
     // so we store the row count in the applet global configuration
@@ -467,6 +501,7 @@
 
     m_currentDesktop = desktop;
     m_dirtyDesktop = -1;
+    m_desktopDown = false;
 
     if (!m_timer->isActive()) {
         m_timer->start(FAST_UPDATE_DELAY);
@@ -710,6 +745,20 @@
         // only change the desktop if the user presses and releases the mouse on the \
same desktop  KWindowSystem::setCurrentDesktop(m_dragStartDesktop + 1);
         m_currentDesktop = m_dragStartDesktop + 1;
+    } else if (m_dragStartDesktop != -1 && m_dragStartDesktop < m_rects.size() &&
+               m_rects[m_dragStartDesktop].contains(event->pos()) &&
+               m_currentDesktop == m_dragStartDesktop + 1) {
+        // toogle the desktop or the dashboard
+        // if the user presses and releases the mouse on the current desktop, \
default option is do nothing +        if (m_currentDesktopSelected == ShowDesktop) {
+
+            NETRootInfo info(QX11Info::display(), 0);
+            m_desktopDown = !m_desktopDown;
+            info.setShowingDesktop(m_desktopDown);
+        } else if (m_currentDesktopSelected == ShowDashboard) {
+            QDBusInterface plasmaApp("org.kde.plasma-desktop", "/App");
+            plasmaApp.call("toggleDashboard");
+        }
     }
 
     m_dragId = 0;
--- trunk/KDE/kdebase/workspace/plasma/applets/pager/pager.h #928900:928901
@@ -103,6 +103,13 @@
             None
         };
 
+        enum CurrentDesktopSelected
+        {
+            DoNothing,
+            ShowDesktop,
+            ShowDashboard
+        };
+
         struct AnimInfo
         {
             int animId;
@@ -112,12 +119,14 @@
         };
 
         DisplayedText m_displayedText;
+        CurrentDesktopSelected m_currentDesktopSelected;
         bool m_showWindowIcons;
         bool m_showOwnBackground;
         int m_rows;
         int m_columns;
         int m_desktopCount;
         int m_currentDesktop;
+        bool m_desktopDown;
         qreal m_widthScaleFactor;
         qreal m_heightScaleFactor;
         QSizeF m_size;
--- trunk/KDE/kdebase/workspace/plasma/applets/pager/pagerConfig.ui #928900:928901
@@ -130,6 +130,40 @@
         </property>
        </spacer>
       </item>
+      <item row="5" column="0" >
+       <widget class="QLabel" name="currentLabel" >
+        <property name="text" >
+         <string>Selecting current desktop:</string>
+        </property>
+        <property name="alignment" >
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+        <property name="buddy" >
+         <cstring>spinRows</cstring>
+        </property>
+       </widget>
+      </item>
+     <item row="5" column="1" colspan="2" >
+       <widget class="QRadioButton" name="doNothingRadioButton" >
+        <property name="text" >
+         <string>Do nothing</string>
+        </property>
+       </widget>
+      </item>
+      <item row="6" column="1" colspan="2" >
+       <widget class="QRadioButton" name="showDesktopRadioButton" >
+        <property name="text" >
+         <string>Shows desktops</string>
+        </property>
+       </widget>
+      </item>
+      <item row="7" column="1" colspan="2" >
+       <widget class="QRadioButton" name="showDashboardRadioButton" >
+        <property name="text" >
+         <string>Show the dashboard</string>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>


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

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