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

List:       kde-commits
Subject:    kpdf_annotations: kdegraphics/kpdf/ui
From:       Enrico Ros <rosenric () dei ! unipd ! it>
Date:       2005-03-25 8:32:27
Message-ID: 20050325083227.8AC953C3 () office ! kde ! org
[Download RAW message or body]

CVS commit by eros: 

Apply fix for 102117 to this branch too.


  M +24 -9     propertiesdialog.cpp   1.5.2.1


--- kdegraphics/kpdf/ui/propertiesdialog.cpp  #1.5:1.5.2.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 );
 }


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

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