KIconDialog extensions (was: Re: Icon choosing in kedittoolbar)

Rob Kaper cap at capsi.com
Fri May 7 17:38:32 BST 2004


On Wed, Apr 28, 2004 at 04:01:42PM +0200, David Faure wrote:
> It's a somewhat particular case, so I don't think it should be an argument in the
> convenience static method; but you seem to be using the normal constructor
> and setFoo() methods, so a new method for this is OK, IMHO.

Here's an untested patch.

Rob
-- 
Rob Kaper     | 5/11 Ghost of the Robot AMSTERDAM, 5/14 Disney PARIS
cap at capsi.com | 7/19 COPENHAGEN-MALMÖ, 7/21 STOCKHOLM-KÖPING, 8/1 OSLO
www.capsi.com | 9/27 The Rasmus LILLE
-------------- next part --------------
Index: kicondialog.cpp
===================================================================
RCS file: /home/kde/kdelibs/kio/kfile/kicondialog.cpp,v
retrieving revision 1.36
diff -u -3 -p -r1.36 kicondialog.cpp
--- kicondialog.cpp	8 Mar 2004 15:07:48 -0000	1.36
+++ kicondialog.cpp	7 May 2004 16:36:28 -0000
@@ -182,9 +182,11 @@ class KIconDialog::KIconDialogPrivate
   public:
     KIconDialogPrivate() {
         m_bStrictIconSize = true;
+	m_bLockUser = false;
+	m_bLockCustomDir = false;
     }
     ~KIconDialogPrivate() {}
-    bool m_bStrictIconSize;
+    bool m_bStrictIconSize, m_bLockUser, m_bLockCustomDir;
     QString custom;
     QString customLocation;
 };
@@ -341,15 +343,20 @@ QString KIconDialog::selectIcon(KIcon::G
 #endif
 
 void KIconDialog::setup(KIcon::Group group, KIcon::Context context,
-                        bool strictIconSize, int iconSize, bool user )
+                        bool strictIconSize, int iconSize, bool user,
+                        bool lockUser, bool lockCustomDir)
 {
     d->m_bStrictIconSize = strictIconSize;
+    d->m_bLockUser = lockUser;
+    d->m_bLockCustomDir = lockCustomDir;
     mGroupOrSize = (iconSize == 0) ? group : -iconSize;
     mType = user ? 1 : 0;
     mpRb1->setChecked(!user);
+    mpRb1->setEnabled( !lockUser || !user );
     mpRb2->setChecked(user);
+    mpRb2->setEnabled( !lockUser || user );
     mpCombo->setEnabled(!user);
-    mpBrowseBut->setEnabled(user);
+    mpBrowseBut->setEnabled( user && !lockCustomDir );
     mContext = context;
     mpCombo->setCurrentItem(mContext-1);
 }
@@ -436,7 +443,7 @@ void KIconDialog::slotButtonClicked(int 
         if(mType!=1)
         {
             mType = 1;
-            mpBrowseBut->setEnabled(true);
+            mpBrowseBut->setEnabled( !d->m_bLockCustomDir );
             mpCombo->setEnabled(false);
             showIcons();
         }
Index: kicondialog.h
===================================================================
RCS file: /home/kde/kdelibs/kio/kfile/kicondialog.h,v
retrieving revision 1.25
diff -u -3 -p -r1.25 kicondialog.h
--- kicondialog.h	7 Mar 2004 23:35:45 -0000	1.25
+++ kicondialog.h	7 May 2004 16:36:28 -0000
@@ -149,12 +149,15 @@ public:
 
     /**
      * Allows you to set the same parameters as in the class method
-     * getIcon().
+     * getIcon(). Since KDE 3.3 it allows two additional parameters to lock
+     * the choice between system and user dirs and to lock the custom user
+     * dir itself.
      */
     void setup( KIcon::Group group,
                 KIcon::Context context = KIcon::Application,
                 bool strictIconSize = false, int iconSize = 0,
-                bool user = false );
+                bool user = false, bool lockUser = false,
+                bool lockCustomDir = false );
 
     /**
      * exec()utes this modal dialog and returns the name of the selected icon,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20040507/4e2393b0/attachment.sig>


More information about the kde-core-devel mailing list