]> cloud.milkyroute.net Git - dolphin.git/commitdiff
fixed resizing issues when having long comments:
authorPeter Penz <peter.penz19@gmail.com>
Wed, 10 Jun 2009 10:04:33 +0000 (10:04 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 10 Jun 2009 10:04:33 +0000 (10:04 +0000)
* embed the comment label inside a scrollarea
* assure that the "add comment..."/"change comment..." link is always visible
* assure that the maximum width of the meta data widget is set to the panel width (otherwise the panel would be increased in an unlimited way when having a text without spaces)

CCMAIL: trueg@kde.org

svn path=/trunk/KDE/kdebase/apps/; revision=979621

src/panels/information/commentwidget.cpp
src/panels/information/informationpanel.cpp

index 586be63aa757ad11ed7dd871077eb2a4f5c98bcb..93bbad84f9f5f3ee321517297368d727f517a9cb 100644 (file)
@@ -24,6 +24,7 @@
 #include <QtGui/QTextEdit>
 #include <QtGui/QLayout>
 #include <QtGui/QCursor>
+#include <QtGui/QScrollArea>
 #include <QtCore/QEvent>
 
 #include <KLocale>
@@ -39,7 +40,9 @@ public:
     void update();
     void _k_slotEnableEditing();
 
-    QLabel* label;
+    QLabel* commentLabel;
+    QScrollArea* scrollArea;
+    QLabel* commentLink;
     CommentEditWidget* edit;
 
     QString comment;
@@ -51,11 +54,14 @@ private:
 
 void CommentWidget::Private::update()
 {
+    commentLabel->setText( comment );
     if ( comment.isEmpty() ) {
-        label->setText( "<p align=center><a style=\"font-size:small;\" href=\"addComment\">" + i18nc( "@label", "Add Comment..." ) + "</a>" );
+        scrollArea->hide();
+        commentLink->setText( "<p align=center><a style=\"font-size:small;\" href=\"addComment\">" + i18nc( "@label", "Add Comment..." ) + "</a>" );
     }
     else {
-        label->setText( "<p>" + comment + "<p align=center><a style=\"font-size:small;\" href=\"addComment\">" + i18nc( "@label", "Change Comment..." ) + "</a>" );
+        scrollArea->show();
+        commentLink->setText( "<p align=center><a style=\"font-size:small;\" href=\"addComment\">" + i18nc( "@label", "Change Comment..." ) + "</a>" );
     }
 }
 
@@ -77,13 +83,22 @@ CommentWidget::CommentWidget( QWidget* parent )
     : QWidget( parent ),
       d( new Private( this ) )
 {
-    d->label = new QLabel( this );
-    d->label->setWordWrap( true );
+    d->commentLabel = new QLabel( this );
+    d->commentLabel->setWordWrap( true );
+
+    d->scrollArea = new QScrollArea( this );
+    d->scrollArea->setWidget( d->commentLabel );
+    d->scrollArea->setWidgetResizable( true );
+    d->scrollArea->setFrameShape( QFrame::StyledPanel );
+
+    d->commentLink = new QLabel( this );
+
     QVBoxLayout* layout = new QVBoxLayout( this );
     layout->setMargin( 0 );
-    layout->addWidget( d->label );
+    layout->addWidget( d->scrollArea );
+    layout->addWidget( d->commentLink );
     d->update();
-    connect( d->label, SIGNAL( linkActivated( const QString& ) ), this, SLOT( _k_slotEnableEditing() ) );
+    connect( d->commentLink, SIGNAL( linkActivated( const QString& ) ), this, SLOT( _k_slotEnableEditing() ) );
 }
 
 
index affd0b1d320d8cb7f1457aef8d332fa2ac875a45..2c9edcc18b4dd1858de5a14ad9353393e74ddf6c 100644 (file)
@@ -202,6 +202,12 @@ void InformationPanel::resizeEvent(QResizeEvent* event)
         const int maxWidth = event->size().width() - KDialog::spacingHint() * 4;
         m_nameLabel->setMaximumWidth(maxWidth);
 
+        // The metadata widget also contains a text widget which may return
+        // a large preferred width.
+        if (m_metaDataWidget != 0) {
+            m_metaDataWidget->setMaximumWidth(maxWidth);
+        }
+
         // try to increase the preview as large as possible
         m_preview->setSizeHint(QSize(maxWidth, maxWidth));
         m_urlCandidate = m_shownUrl; // reset the URL candidate if a resizing is done
@@ -777,6 +783,7 @@ void InformationPanel::init()
         // rating, comment and tags
         m_metaDataWidget = new MetaDataWidget(this);
         m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+        m_metaDataWidget->setMaximumWidth(KIconLoader::SizeEnormous);
 
         const bool showRating  = InformationPanelSettings::showRating();
         const bool showComment = InformationPanelSettings::showComment();