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

List:       kde-core-devel
Subject:    [Patch] Updated patch for permissions dialog
From:       Dominik Seichter <domseichter () web ! de>
Date:       2003-05-16 23:04:08
[Download RAW message or body]

Hello,

I updated my patch for changing the file permissions using octal numbers. A 
screenshot can be viewed at http://krename.sf.net/screenshots/kde-patch2.png
. I changed the label in front of the line edit to "corresponding octal value" 
as it was suggested by Karl-Heinz Zimmer and made the line edit also smaller. 
I hope the dialog looks now a bit better :-).

This patch contains also a What This help for the new widget, because Tim 
Jansen commited What This help to all the other labels and checkboxes in this 
dialog.

The attached patch is tested against CVS HEAD.

CU Dom
-- 
************************************************************
Dominik Seichter - domseichter@web.de
Krename - http://www.krename.net
KBarcode - http://www.kbarcode.net
************************************************************

["kpropertiesdialog-2.diff" (text/x-diff)]

? kspell/Makefile
? kspell/Makefile.in
Index: kio/kfile/kpropertiesdialog.cpp
===================================================================
RCS file: /home/kde/kdelibs/kio/kfile/kpropertiesdialog.cpp,v
retrieving revision 1.244
diff -u -p -r1.244 kpropertiesdialog.cpp
--- kio/kfile/kpropertiesdialog.cpp	15 May 2003 23:23:58 -0000	1.244
+++ kio/kfile/kpropertiesdialog.cpp	16 May 2003 23:01:35 -0000
@@ -86,6 +86,7 @@ extern "C" {
 #include <kmountpoint.h>
 #include <kiconloader.h>
 #include <kmessagebox.h>
+#include <krestrictedline.h>
 #include <kservice.h>
 #include <kcompletion.h>
 #include <klineedit.h>
@@ -1390,11 +1391,35 @@ KFilePermissionsPropsPlugin::KFilePermis
     stickyWhatsThis = i18n("The Sticky flag on a file is ignored on Linux, but may \
be used on some systems");  QWhatsThis::add(l, stickyWhatsThis);
 
+  l = new QLabel(i18n("Corresponding octal value:"), gb);
+  gl->addMultiCellWidget(l, 6, 6, 0, 2 );
+
+  permEdit = new KRestrictedLine( gb, "permEdit", "01234567" );
+  permEdit->setMaxLength( 4 );
+  permEdit->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
+
+  QString permEditWhatsThis = i18n("All permission can also be changed with an octal \
number. Entering a number has the same effect as changing the checkboxes above would \
have."); +  QWhatsThis::add(l, permEditWhatsThis);
+  QWhatsThis::add(permEdit, permEditWhatsThis);
+
+  connect( permEdit, SIGNAL( textChanged( const QString & ) ),
+        this, SIGNAL( changed() ) );
+
+  connect( this, SIGNAL( changed() ),
+        this, SLOT( slotSetPermission() ) );
+
+  gl->addWidget(permEdit, 6, 3);
+
   bool enablePage = (isMyFile || IamRoot) && (!isLink);
+  permEdit->setEnabled( enablePage );
+
   /* Draw Checkboxes */
   for (int row = 0; row < 3 ; ++row) {
     for (int col = 0; col < 4; ++col) {
       QCheckBox *cb = new QCheckBox(gb);
+
+      connect( cb, SIGNAL( clicked() ), this, SLOT( slotUpdatePermissions() ) );
+
       cb->setChecked(permissions & fperm[row][col]);
       if ( d->partialPermissions & fperm[row][col] )
       {
@@ -1583,6 +1608,8 @@ KFilePermissionsPropsPlugin::KFilePermis
     cl[1]->setText(i18n("<b>Group</b>"));
   else
     cl[2]->setText(i18n("<b>Others</b>"));
+
+  slotUpdatePermissions();
 }
 
 // QString KFilePermissionsPropsPlugin::tabName () const
@@ -1612,27 +1639,60 @@ void KFilePermissionsPropsPlugin::slotRe
       permBox[row][col]->setTristate();
 }
 
+
+void KFilePermissionsPropsPlugin::slotSetPermission()
+{
+  QString permission = permEdit->text();
+
+  mode_t perm = permission.toInt( 0, 8 );
+
+  for (int row = 0; row < 3 ; ++row) {
+    for (int col = 0; col < 4; ++col) {
+      permBox[row][col]->setChecked( perm & fperm[row][col]);
+    }
+  }
+}
+
+void KFilePermissionsPropsPlugin::slotUpdatePermissions()
+{
+  mode_t newPermission = 0;
+  mode_t newPartialPermission = 0;
+  mode_t permissionMask = 0;
+
+  calculatePermissions( &newPermission, &newPartialPermission, &permissionMask );
+  QString s;
+  s.sprintf( "%0*o", 4, newPermission );
+  permEdit->setText( s );
+}
+
+void KFilePermissionsPropsPlugin::calculatePermissions( mode_t* newPermission,
+    mode_t* newPartialPermission, mode_t* permissionMask )
+{
+    for (int row = 0;row < 3; ++row)
+        for (int col = 0; col < 4; ++col)
+        {
+            switch (permBox[row][col]->state())
+            {
+                case QCheckBox::On:
+                    *newPermission |= fperm[row][col];
+                    //fall through
+                case QCheckBox::Off:
+                    *permissionMask |= fperm[row][col];
+                    break;
+                default: // NoChange
+                    *newPartialPermission |= fperm[ row ][ col ];
+                    break;
+            }
+        }
+}
+
 void KFilePermissionsPropsPlugin::applyChanges()
 {
   mode_t newPermission = 0;
   mode_t newPartialPermission = 0;
   mode_t permissionMask = 0;
-  for (int row = 0;row < 3; ++row)
-    for (int col = 0; col < 4; ++col)
-    {
-      switch (permBox[row][col]->state())
-      {
-          case QCheckBox::On:
-            newPermission |= fperm[row][col];
-            //fall through
-          case QCheckBox::Off:
-            permissionMask |= fperm[row][col];
-            break;
-          default: // NoChange
-	    newPartialPermission |= fperm[ row ][ col ];
-            break;
-      }
-    }
+
+  calculatePermissions( &newPermission, &newPartialPermission, &permissionMask );
 
   QString owner, group;
   if (usrEdit)
Index: kio/kfile/kpropertiesdialog.h
===================================================================
RCS file: /home/kde/kdelibs/kio/kfile/kpropertiesdialog.h,v
retrieving revision 1.84
diff -u -p -r1.84 kpropertiesdialog.h
--- kio/kfile/kpropertiesdialog.h	9 Dec 2002 12:20:28 -0000	1.84
+++ kio/kfile/kpropertiesdialog.h	16 May 2003 23:01:35 -0000
@@ -44,6 +44,7 @@ class QButton;
 class KIconButton;
 class KPropsDlgPlugin;
 class QComboBox;
+class KRestrictedLine;
 
 #define KPropsPage KPropsDlgPlugin
 
@@ -478,12 +479,17 @@ private slots:
 
   void slotChmodResult( KIO::Job * );
   void slotRecursiveClicked();
+  void slotUpdatePermissions();
+  void slotSetPermission();
 
 private:
+  void calculatePermissions( mode_t* newPermission, mode_t* newPartialPermission, \
mode_t* permissionMask ); +
   QCheckBox *permBox[3][4];
 
   QComboBox *grpCombo;
   KLineEdit *usrEdit, *grpEdit;
+  KRestrictedLine* permEdit;
 
   /**
    * Old permissions



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

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