diff options
| author | Peter Penz <[email protected]> | 2009-06-10 10:04:33 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2009-06-10 10:04:33 +0000 |
| commit | 26b6d3b8ffd1071a615e95a2871096ae85dd6f93 (patch) | |
| tree | 8344e5658061f643f99f963808eef6dd779fe24d /src/panels/information/commentwidget.cpp | |
| parent | 950d61feda059bddf11ef5549077c3bd02b4e6a5 (diff) | |
fixed resizing issues when having long comments:
* 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: [email protected]
svn path=/trunk/KDE/kdebase/apps/; revision=979621
Diffstat (limited to 'src/panels/information/commentwidget.cpp')
| -rw-r--r-- | src/panels/information/commentwidget.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/panels/information/commentwidget.cpp b/src/panels/information/commentwidget.cpp index 586be63aa..93bbad84f 100644 --- a/src/panels/information/commentwidget.cpp +++ b/src/panels/information/commentwidget.cpp @@ -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() ) ); } |
