From e46f1c285cebe56d5b489b82ceb840518f7b3e5c Mon Sep 17 00:00:00 2001 From: thunder2 Date: Mon, 22 May 2023 06:58:50 +0200 Subject: [PATCH] Make post title in board clickable after change to ElidedLabel --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 37062e098..541cecac0 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "rshare.h" #include "BoardPostDisplayWidget.h" @@ -214,8 +215,6 @@ void BoardPostDisplayWidgetBase::baseSetup() // The only combination that seems to work: load as EncodedUrl, extract toEncoded(). QByteArray urlarray(mPost.mLink.c_str()); QUrl url = QUrl::fromEncoded(urlarray.trimmed()); - QString urlstr = "Invalid Link"; - QString sitestr = "Invalid Link"; bool urlOkay = url.isValid(); if (urlOkay) @@ -227,25 +226,24 @@ void BoardPostDisplayWidgetBase::baseSetup() && (scheme != "retroshare")) { urlOkay = false; - sitestr = "Invalid Link Scheme"; } } + ElidedLabel *label = titleLabel(); + label->setText( QString::fromUtf8(mPost.mMeta.mMsgName.c_str()) ); + if (urlOkay) { - urlstr = QString(" "); - urlstr += QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); - urlstr += QString(" "); - QString siteurl = url.toEncoded(); - titleLabel()->setText(urlstr); - titleLabel()->setToolTip(siteurl); + label->setStyleSheet("text-decoration: underline; color:#2255AA;"); + label->setCursor(QCursor(Qt::PointingHandCursor)); + label->setToolTip(siteurl); + + connect(label, &ElidedLabel::clicked, this, [url] () { + QDesktopServices::openUrl(url); + }, Qt::QueuedConnection); } - else - titleLabel()->setText( QString::fromUtf8(mPost.mMeta.mMsgName.c_str()) ); } //QString score = "Hot" + QString::number(post.mHotScore);