mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #2737 from thunder2/post-title-clickable
Make post title in board clickable after change to ElidedLabel
This commit is contained in:
commit
9a23e3acdf
@ -23,6 +23,7 @@
|
|||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
|
||||||
#include "rshare.h"
|
#include "rshare.h"
|
||||||
#include "BoardPostDisplayWidget.h"
|
#include "BoardPostDisplayWidget.h"
|
||||||
@ -214,8 +215,6 @@ void BoardPostDisplayWidgetBase::baseSetup()
|
|||||||
// The only combination that seems to work: load as EncodedUrl, extract toEncoded().
|
// The only combination that seems to work: load as EncodedUrl, extract toEncoded().
|
||||||
QByteArray urlarray(mPost.mLink.c_str());
|
QByteArray urlarray(mPost.mLink.c_str());
|
||||||
QUrl url = QUrl::fromEncoded(urlarray.trimmed());
|
QUrl url = QUrl::fromEncoded(urlarray.trimmed());
|
||||||
QString urlstr = "Invalid Link";
|
|
||||||
QString sitestr = "Invalid Link";
|
|
||||||
|
|
||||||
bool urlOkay = url.isValid();
|
bool urlOkay = url.isValid();
|
||||||
if (urlOkay)
|
if (urlOkay)
|
||||||
@ -227,25 +226,24 @@ void BoardPostDisplayWidgetBase::baseSetup()
|
|||||||
&& (scheme != "retroshare"))
|
&& (scheme != "retroshare"))
|
||||||
{
|
{
|
||||||
urlOkay = false;
|
urlOkay = false;
|
||||||
sitestr = "Invalid Link Scheme";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ElidedLabel *label = titleLabel();
|
||||||
|
label->setText( QString::fromUtf8(mPost.mMeta.mMsgName.c_str()) );
|
||||||
|
|
||||||
if (urlOkay)
|
if (urlOkay)
|
||||||
{
|
{
|
||||||
urlstr = QString("<a href=\"");
|
|
||||||
urlstr += QString(url.toEncoded());
|
|
||||||
urlstr += QString("\" ><span style=\" text-decoration: underline; color:#2255AA;\"> ");
|
|
||||||
urlstr += QString::fromUtf8(mPost.mMeta.mMsgName.c_str());
|
|
||||||
urlstr += QString(" </span></a>");
|
|
||||||
|
|
||||||
QString siteurl = url.toEncoded();
|
QString siteurl = url.toEncoded();
|
||||||
|
|
||||||
titleLabel()->setText(urlstr);
|
label->setStyleSheet("text-decoration: underline; color:#2255AA;");
|
||||||
titleLabel()->setToolTip(siteurl);
|
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);
|
//QString score = "Hot" + QString::number(post.mHotScore);
|
||||||
|
Loading…
Reference in New Issue
Block a user