]> git.sur5r.net Git - minitube/commitdiff
Clickable links and better ellipsis
authorFlavio Tordini <flavio.tordini@gmail.com>
Fri, 24 Jul 2015 07:35:08 +0000 (09:35 +0200)
committerFlavio Tordini <flavio.tordini@gmail.com>
Fri, 24 Jul 2015 07:35:08 +0000 (09:35 +0200)
src/loadingwidget.cpp

index 2b2a5e517c855591d94eb6fc762099a69fb02119..0f030d983e467f0ac100cd90f29e08632f20207d 100644 (file)
@@ -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+)"), "<a style='color:white' href=\"\\1\">\\1</a>");
     QFont descFont(titleFont);
     descFont.setPixelSize(descFont.pixelSize() / 2);
-    descFont.setHintingPreference(QFont::PreferNoHinting);
     descriptionLabel->setFont(descFont);
     descriptionLabel->setText(videoDesc);
     bool hiddenDesc = height() < 400;