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

List:       kde-devel
Subject:    Patch for KDesktop
From:       Andrea Bergia <andreabergia () yahoo ! it>
Date:       2003-05-15 16:53:05
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi. I made a patch for KDesktop to allow it to auto - line up the icons. When 
an user moves an icon, with this patch the icon is automatically lined up 
into the grid (as he rclicked on the desktop, selected icons, and then line 
up). Of course there's a check box in the right menu to allow the user to 
disable it. What do you think? Will you apply it?

PS: It's made in a bit strange format I think, because my Kate thrown away 
some tabs, and I fixed the patch created from CVS manually... hope it will 
works anyway. Bye

- -- 
Andrea Bergia - studente              Linux Registered User #281550
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+w8Xx/QsGXRtKyZkRAl88AJ0Z0NBdyXgrg3fe9TWWmHaZuYh34ACeLtMG
AimopEazXsNLpbc/Itp1vZ8=
=toDp
-----END PGP SIGNATURE-----

["icons-auto-line-up.patch" (text/x-diff)]

Index: desktop.cc
===================================================================
RCS file: /home/kde/kdebase/kdesktop/desktop.cc,v
retrieving revision 1.272
diff -u -r1.272 desktop.cc
--- desktop.cc	8 May 2003 13:50:35 -0000	1.272
+++ desktop.cc	15 May 2003 16:39:38 -0000
@@ -600,6 +600,10 @@
         m_pIconView->slotSaveIconPositions();
     if ( m_miniCli )
         m_miniCli->saveConfig();
+
+    // Save the auto-lineup setting
+    if ( KRootWm::self() )
+        KRootWm::self()->saveConfig();
 }
 
 // don't hide when someone presses Alt-F4 on us
Index: kdiconview.cc
===================================================================
RCS file: /home/kde/kdebase/kdesktop/kdiconview.cc,v
retrieving revision 1.76
diff -u -r1.76 kdiconview.cc
--- kdiconview.cc	13 May 2003 15:34:44 -0000	1.76
+++ kdiconview.cc	15 May 2003 16:39:41 -0000
@@ -438,6 +438,12 @@
     KonqIconViewWidget::wheelEvent( e );
 }
 
+void KDIconView::startDrag()
+{
+    KonqIconViewWidget::startDrag();
+    emit iconMoved();
+}
+
 void KDIconView::slotMouseButtonPressed(int _button, QIconViewItem* _item, const \
QPoint& _global)  {
     //kdDebug(1204) << "KDIconView::slotMouseButtonPressed" << endl;
Index: kdiconview.h
===================================================================
RCS file: /home/kde/kdebase/kdesktop/kdiconview.h,v
retrieving revision 1.23
diff -u -r1.23 kdiconview.h
--- kdiconview.h	8 May 2003 11:48:41 -0000	1.23
+++ kdiconview.h	15 May 2003 16:39:41 -0000
@@ -57,10 +57,14 @@
      * Re-arrange the desktop icons without confirmation.
      */
     void rearrangeIcons();
+
+public slots:
     /**
      * Lineup the desktop icons.
      */
     void lineupIcons();
+
+public:
     void lineupIcons(QIconView::Arrangement);
 
     void refreshIcons();
@@ -117,6 +121,7 @@
     void colorDropEvent( QDropEvent *e );
     void imageDropEvent( QDropEvent *e );
     void newWallpaper( const KURL & );
+    void iconMoved();
 
 public slots: // for krootwm
     void slotPaste();
@@ -142,9 +147,12 @@
     virtual void mousePressEvent( QMouseEvent *e );
     virtual void wheelEvent( QWheelEvent* e );
 
+    /** Used to emit a iconMoved event, to auto - line up icons. */
+    virtual void startDrag();
+
 private slots:
     void desktopResized();
-    
+
 private:
     /** Our action collection, parent of all our actions */
     KActionCollection m_actionCollection;
Index: krootwm.cc
===================================================================
RCS file: /home/kde/kdebase/kdesktop/krootwm.cc,v
retrieving revision 1.173
diff -u -r1.173 krootwm.cc
--- krootwm.cc	10 May 2003 17:52:07 -0000	1.173
+++ krootwm.cc	15 May 2003 16:39:43 -0000
@@ -49,6 +49,7 @@
 #include <kmenubar.h>
 #include <kmessagebox.h>
 #include <qfile.h>
+#include <kactionclasses.h>
 
 #include "krootwm.h"
 #include "kdiconview.h"
@@ -153,15 +154,19 @@
      KToggleAction *aSortDirsFirst = new KToggleAction( i18n("Directories First"), \
0, m_actionCollection, "sort_directoriesfirst" );  aSortDirsFirst->setChecked(true);
      //
-     new KAction(i18n("Line Up Horizontally"), 0, 
+     new KAction(i18n("Line Up Horizontally"), 0,
                  this, SLOT( slotLineupIconsHoriz() ),
                  m_actionCollection, "lineupHoriz" );
      new KAction(i18n("Line Up Vertically"), 0,
                  this, SLOT( slotLineupIconsVert() ),
                  m_actionCollection, "lineupVert" );
+
      new KAction(i18n("Align to Grid"), 0,
                  this, SLOT( slotLineupIcons() ),
                  m_actionCollection, "realign" );
+     new KToggleAction(i18n("Automatical align to the Grid"), 0,
+                 this, SLOT( slotAutoLineupIcons() ),
+                 m_actionCollection, "autorealign" );
   }
   if (m_bDesktopEnabled)
   {
@@ -233,9 +238,23 @@
     if (s == s_choices[c])
       { rightButtonChoice = (menuChoice) c; break; }
 
+  // Reset the auto-lineup config - what a horrible C++!
+  (static_cast<KToggleAction*>
+    (m_actionCollection->action("autorealign")))->setChecked(
+    kconfig->readBoolEntry("AutoLineUpIcons", false));
+  slotAutoLineupIcons();
+
   buildMenus();
 }
 
+void KRootWm::saveConfig()
+{
+    // Save the auto-lineup config
+    KConfig *kconfig = KGlobal::config();
+    kconfig->writeEntry("AutoLineUpIcons", (static_cast<KToggleAction*>
+        (m_actionCollection->action("autorealign")))->isChecked());
+}
+
 void KRootWm::buildMenus()
 {
 //    kdDebug() << "KRootWm::buildMenus" << endl;
@@ -277,6 +296,7 @@
         m_actionCollection->action( "lineupVert" )->plug( pLineupMenu );
         pLineupMenu->insertSeparator();
         m_actionCollection->action( "realign" )->plug( pLineupMenu );
+        m_actionCollection->action( "autorealign" )->plug( pLineupMenu );
     }
 
     if (menuBar) {
@@ -586,6 +607,30 @@
     }
 }
 
+void KRootWm::slotAutoLineupIcons() {
+    if (m_bDesktopEnabled)
+    {
+        bool arr = (dynamic_cast <KToggleAction*>
+            (m_actionCollection->action("autorealign")))->isChecked();
+        m_actionCollection->action("realign")->setEnabled(! arr);
+
+        if (arr)
+        {
+            // Line up now, and set to do it automatically
+            m_pDesktop->iconView()->lineupIcons();
+
+            connect (m_pDesktop->iconView(), SIGNAL (iconMoved()),
+                m_pDesktop->iconView(), SLOT (lineupIcons()));
+        }
+        else
+        {
+            // Stop
+            disconnect (m_pDesktop->iconView(), SIGNAL (iconMoved()),
+                m_pDesktop->iconView(), SLOT (lineupIcons()));
+        }
+    }
+}
+
 void KRootWm::slotRefreshDesktop() {
     if (m_bDesktopEnabled)
     {
Index: krootwm.h
===================================================================
RCS file: /home/kde/kdebase/kdesktop/krootwm.h,v
retrieving revision 1.50
diff -u -r1.50 krootwm.h
--- krootwm.h	3 Oct 2002 11:45:59 -0000	1.50
+++ krootwm.h	15 May 2003 16:39:44 -0000
@@ -88,6 +88,11 @@
    */
   void initConfig();
 
+  /**
+   * Save some settings. By now saves only the auto-lineup setting
+  */
+  void saveConfig();
+
 public slots:
   void slotArrangeByNameCS();
   void slotArrangeByNameCI();
@@ -96,6 +101,7 @@
   void slotLineupIconsHoriz();
   void slotLineupIconsVert();
   void slotLineupIcons();
+  void slotAutoLineupIcons();
   void slotRefreshDesktop();
   void slotConfigureDesktop();
   void slotToggleDesktopMenu();



>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


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

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