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

List:       kde-core-devel
Subject:    [patch] enhanced file properties dialog
From:       Martin Koller <m.koller () surfeu ! at>
Date:       2004-10-10 19:05:36
Message-ID: 200410102105.42624.m.koller () surfeu ! at
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Hi all,

I've seen that the current file/directory properties dialog shows also the 
disk free/usage from the file system on which the given file is on.

The problem I see here is, that usability wise this information should not be 
intermixed with the properties belonging to the file itself.
Currently it is between the size of the file and the modification time.

The attached patch fixes this by placing this information below the file-time 
stamps (delimited by a separator).
In addition I show a graphical representation of the disk usage (progressbar).

OK to commit ?

-- 
Best regards/Schöne Grüße

Martin    ()  ascii ribbon campaign - against html mail 
          /\                        - against microsoft attachments

       Some operating systems are called 'user friendly',
             Linux however is 'expert friendly'.

["props.patch" (text/x-diff)]

Index: kpropertiesdialog.cpp
===================================================================
RCS file: /home/kde/kdelibs/kio/kfile/kpropertiesdialog.cpp,v
retrieving revision 1.321
diff -u -3 -p -r1.321 kpropertiesdialog.cpp
--- kpropertiesdialog.cpp	4 Oct 2004 22:17:19 -0000	1.321
+++ kpropertiesdialog.cpp	10 Oct 2004 18:56:58 -0000
@@ -66,6 +66,7 @@ extern "C" {
 #include <qwhatsthis.h>
 #include <qtooltip.h>
 #include <qstyle.h>
+#include <qprogressbar.h>
 
 #include <kapplication.h>
 #include <kdialog.h>
@@ -597,6 +598,8 @@ public:
   {
     dirSizeJob = 0L;
     dirSizeUpdateTimer = 0L;
+    m_freeSpaceLabel = 0;
+    m_freeSpaceBar = 0;
     m_lined = 0;
   }
   ~KFilePropsPluginPrivate()
@@ -613,6 +616,7 @@ public:
   bool bKDesktopMode;
   bool bDesktopFile;
   QLabel *m_freeSpaceLabel;
+  QProgressBar *m_freeSpaceBar;
   QString mimeType;
   QString oldFileName;
   KLineEdit* m_lined;
@@ -916,33 +920,6 @@ KFilePropsPlugin::KFilePropsPlugin( KPro
       m_sizeStopButton->setEnabled( false );
   }
 
-  if ( isLocal )
-  {
-      QString mountPoint = KIO::findPathMountPoint( properties->item()->url().path() );
-
-      if (mountPoint != "/")
-      {
-          l = new QLabel(i18n("Mounted on:"), d->m_frame );
-          grid->addWidget(l, curRow, 0);
-
-          l = new KSqueezedTextLabel( mountPoint, d->m_frame );
-          grid->addWidget( l, curRow++, 2 );
-      }
-
-      l = new QLabel(i18n("Free disk space:"), d->m_frame );
-      grid->addWidget(l, curRow, 0);
-
-      d->m_freeSpaceLabel = new QLabel( d->m_frame );
-      grid->addWidget( d->m_freeSpaceLabel, curRow++, 2 );
-
-      KDiskFreeSp * job = new KDiskFreeSp;
-      connect( job, SIGNAL( foundMountPoint( const unsigned long&, const unsigned long&,
-					     const unsigned long&, const QString& ) ),
-               this, SLOT( slotFoundMountPoint( const unsigned long&, const unsigned long&,
-						const unsigned long&, const QString& ) ) );
-      job->readDF( mountPoint );
-  }
-
   if (!d->bMultiple && item->isLink()) {
     l = new QLabel(i18n("Points to:"), d->m_frame );
     grid->addWidget(l, curRow, 0);
@@ -953,8 +930,6 @@ KFilePropsPlugin::KFilePropsPlugin( KPro
 
   if (!d->bMultiple) // Dates for multiple don't make much sense...
   {
-    sep = new KSeparator( KSeparator::HLine, d->m_frame);
-    grid->addMultiCellWidget(sep, curRow, curRow, 0, 2);
     ++curRow;
 
     QDateTime dt;
@@ -991,6 +966,42 @@ KFilePropsPlugin::KFilePropsPlugin( KPro
       grid->addWidget(l, curRow++, 2);
     }
   }
+
+  if ( isLocal )
+  {
+    sep = new KSeparator( KSeparator::HLine, d->m_frame);
+    grid->addMultiCellWidget(sep, curRow, curRow, 0, 2);
+
+    curRow++;
+
+    QString mountPoint = KIO::findPathMountPoint( properties->item()->url().path() );
+
+    if (mountPoint != "/")
+    {
+        l = new QLabel(i18n("Mounted on:"), d->m_frame );
+        grid->addWidget(l, curRow, 0);
+
+        l = new KSqueezedTextLabel( mountPoint, d->m_frame );
+        grid->addWidget( l, curRow++, 2 );
+    }
+
+    l = new QLabel(i18n("Free disk space:"), d->m_frame );
+    grid->addWidget(l, curRow, 0);
+
+    d->m_freeSpaceLabel = new QLabel( d->m_frame );
+    grid->addWidget( d->m_freeSpaceLabel, curRow++, 2 );
+
+    d->m_freeSpaceBar = new QProgressBar( d->m_frame );
+    grid->addMultiCellWidget(d->m_freeSpaceBar, curRow, curRow, 0, 2);
+
+    KDiskFreeSp * job = new KDiskFreeSp;
+    connect( job, SIGNAL( foundMountPoint( const unsigned long&, const unsigned long&,
+                                           const unsigned long&, const QString& ) ),
+             this, SLOT( slotFoundMountPoint( const unsigned long&, const unsigned long&,
+                                              const unsigned long&, const QString& ) ) );
+    job->readDF( mountPoint );
+  }
+
   vbl->addStretch(1);
 }
 
@@ -1069,11 +1080,15 @@ void KFilePropsPlugin::slotFoundMountPoi
 					    unsigned long /*kBUsed*/,
 					    unsigned long kBAvail )
 {
+    int percUsed = 100 - (int)(100.0 * kBAvail / kBSize);
+
     d->m_freeSpaceLabel->setText(
 	i18n("Available space out of total partition size (percent used)", "%1 out of %2 (%3% used)")
 	.arg(KIO::convertSizeFromKB(kBAvail))
 	.arg(KIO::convertSizeFromKB(kBSize))
-	.arg( 100 - (int)(100.0 * kBAvail / kBSize) ));
+	.arg(percUsed));
+
+    d->m_freeSpaceBar->setProgress(percUsed, 100);
 }
 
 // attention: copy&paste below, due to compiler bug
@@ -1083,11 +1098,15 @@ void KFilePropsPlugin::slotFoundMountPoi
 					    const unsigned long& kBAvail,
 					    const QString& )
 {
+    int percUsed = 100 - (int)(100.0 * kBAvail / kBSize);
+
     d->m_freeSpaceLabel->setText(
 	i18n("Available space out of total partition size (percent used)", "%1 out of %2 (%3% used)")
 	.arg(KIO::convertSizeFromKB(kBAvail))
 	.arg(KIO::convertSizeFromKB(kBSize))
 	.arg( 100 - (int)(100.0 * kBAvail / kBSize) ));
+
+    d->m_freeSpaceBar->setProgress(percUsed, 100);
 }
 
 void KFilePropsPlugin::slotDirSizeUpdate()

[Attachment #6 (application/pgp-signature)]

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

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