Bug 102117

Summary: KPDF - properties window doesn't fit
Product: [Applications] kpdf Reporter: Görkem Çetin <gorkem>
Component: generalAssignee: Albert Astals Cid <aacid>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: RedHat Enterprise Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: An example of kpdf file properties window

Description Görkem Çetin 2005-03-21 19:04:07 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    RedHat RPMs
OS:                Linux

From time to time, if the "subject" of a PDF file is too long, then the 
windows popping up after clicking KPDF file properties menu shows up too 
wide, not fitting the entire screen. 

This can be resolved by trimming the long sentences and showing the actual
(long) sentence with the help of on mouse over action...
Comment 1 Görkem Çetin 2005-03-21 19:06:12 UTC
Created attachment 10249 [details]
An example of kpdf file properties window
Comment 2 Albert Astals Cid 2005-03-24 23:38:31 UTC
CVS commit by aacid: 

Fix for bug 102117 - properties window doesn't fit when some entry is too long
Patch by Enrico Ros
BUG: 102117


  M +24 -9     propertiesdialog.cpp   1.5.4.1


--- kdegraphics/kpdf/ui/propertiesdialog.cpp  #1.5:1.5.4.1
@@ -9,7 +9,9 @@
 
 // qt/kde includes
-#include <klocale.h>
 #include <qlayout.h>
 #include <qlabel.h>
+#include <klocale.h>
+#include <ksqueezedtextlabel.h>
+#include <kglobalsettings.h>
 
 // local includes
@@ -37,11 +39,16 @@ PropertiesDialog::PropertiesDialog(QWidg
 
   int row = 0;
+  int valMaxWidth = 100;
   for ( QDomNode node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
     QDomElement element = node.toElement();
 
-    if ( !element.attribute( "title" ).isEmpty() ) {
-      QLabel *key = new QLabel( i18n( "%1:" ).arg( element.attribute( "title" ) ), page );
-      QLabel *value = new QLabel( element.attribute( "value" ), page );
+    QString titleString = element.attribute( "title" );
+    QString valueString = element.attribute( "value" );
+    if ( titleString.isEmpty() || valueString.isEmpty() )
+        continue;
 
+    // create labels and layout them
+    QLabel *key = new QLabel( i18n( "%1:" ).arg( titleString ), page );
+    QLabel *value = new KSqueezedTextLabel( valueString, page );
       layout->addWidget( key, row, 0, AlignRight );
       layout->addWidget( value, row, 1 );
@@ -46,7 +53,8 @@ PropertiesDialog::PropertiesDialog(QWidg
       layout->addWidget( key, row, 0, AlignRight );
       layout->addWidget( value, row, 1 );
-
       row++;
-    }
+
+    // refine maximum width of 'value' labels
+    valMaxWidth = QMAX( valMaxWidth, fontMetrics().width( valueString ) );
   }
 
@@ -60,3 +68,10 @@ PropertiesDialog::PropertiesDialog(QWidg
     layout->addWidget( value, row, 1 );
   }
+
+  // current width: left columnt + right column + dialog borders
+  int width = layout->minimumSize().width() + valMaxWidth + 30;
+  // stay inside the 2/3 of the screen width
+  QRect screenContainer = KGlobalSettings::desktopGeometry( this );
+  width = QMIN( width, 2*screenContainer.width()/3 );
+  resize( width, 1 );
 }