From a87b37f9956bcd58cffc0d16c8167beafcb6a731 Mon Sep 17 00:00:00 2001 From: Flavio Tordini Date: Fri, 24 Jul 2015 09:35:08 +0200 Subject: [PATCH] Clickable links and better ellipsis --- src/loadingwidget.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/loadingwidget.cpp b/src/loadingwidget.cpp index 2b2a5e5..0f030d9 100644 --- a/src/loadingwidget.cpp +++ b/src/loadingwidget.cpp @@ -45,6 +45,8 @@ LoadingWidget::LoadingWidget(QWidget *parent) : QWidget(parent) { descriptionLabel->setForegroundRole(QPalette::Text); descriptionLabel->setWordWrap(true); descriptionLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Expanding); + descriptionLabel->setTextFormat(Qt::RichText); + descriptionLabel->setOpenExternalLinks(true); layout->addWidget(descriptionLabel); progressBar = new QProgressBar(this); @@ -96,11 +98,15 @@ void LoadingWidget::setVideo(Video *video) { QString videoDesc = video->description(); if (videoDesc.length() > maxDescLength) { videoDesc.truncate(maxDescLength-1); - videoDesc.append("..."); + videoDesc = videoDesc.trimmed(); + videoDesc.append("…"); + } else if (videoDesc.endsWith(QLatin1String(" ..."))) { + videoDesc = videoDesc.left(videoDesc.length() - 4); + videoDesc.append("…"); } + videoDesc.replace(QRegExp("(https?://\\S+)"), "\\1"); QFont descFont(titleFont); descFont.setPixelSize(descFont.pixelSize() / 2); - descFont.setHintingPreference(QFont::PreferNoHinting); descriptionLabel->setFont(descFont); descriptionLabel->setText(videoDesc); bool hiddenDesc = height() < 400; -- 2.39.5