X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/73007f7d632bdd5565b8394043bb2de07bebb336..7eeb8dba6aeba09aa3dfa7fa5f0b00840d4d8317:/src/panels/information/kcommentwidget.cpp diff --git a/src/panels/information/kcommentwidget.cpp b/src/panels/information/kcommentwidget.cpp index 770b6c10c..408e6a873 100644 --- a/src/panels/information/kcommentwidget.cpp +++ b/src/panels/information/kcommentwidget.cpp @@ -23,12 +23,14 @@ #include #include +#include #include #include #include KCommentWidget::KCommentWidget(QWidget* parent) : QWidget(parent), + m_readOnly(false), m_label(0), m_comment() { @@ -51,11 +53,22 @@ KCommentWidget::~KCommentWidget() void KCommentWidget::setText(const QString& comment) { - if (comment.isEmpty()) { - m_label->setText("" + i18nc("@label", "Add Comment...") + ""); + QString text; + if (comment.isEmpty()) { + if (m_readOnly) { + text = "-"; + } else { + text = "" + i18nc("@label", "Add Comment...") + ""; + } } else { - m_label->setText("

" + comment + " " + i18nc("@label", "Change...") + "

"); + if (m_readOnly) { + text = comment; + } else { + text = "

" + comment + " " + i18nc("@label", "Change...") + "

"; + } } + + m_label->setText(text); m_comment = comment; } @@ -64,6 +77,25 @@ QString KCommentWidget::text() const return m_comment; } +void KCommentWidget::setReadOnly(bool readOnly) +{ + m_readOnly = readOnly; + setText(m_comment); +} + +bool KCommentWidget::isReadOnly() const +{ + return m_readOnly; +} + +bool KCommentWidget::event(QEvent* event) +{ + if (event->type() == QEvent::Polish) { + m_label->setForegroundRole(foregroundRole()); + } + return QWidget::event(event); +} + void KCommentWidget::slotLinkActivated(const QString& link) { KDialog dialog(this, Qt::Dialog);