mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-01 10:05:10 -05:00
069b72e0b2
This brings a huge amount of goodness into the trunk, but there is still a big chunk todo before it can be released. * GXS Backend. * GXS Services: - Identities. - Circles - Photos - Wiki - GxsForums - Posted. * SSH no-gui server. See branch commits for more info. To switch on GXS stuff, enable CONFIG += gxs in both libretroshare.pro and retroshare-gui.pro git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5996 b45a01b8-16f6-495d-af2f-9b41ad6348cc
62 lines
1.6 KiB
C++
62 lines
1.6 KiB
C++
#include <QDesktopServices>
|
|
#include <QPainter>
|
|
|
|
#include "LinkTextBrowser.h"
|
|
|
|
LinkTextBrowser::LinkTextBrowser(QWidget *parent) :
|
|
QTextBrowser(parent)
|
|
{
|
|
setOpenExternalLinks(true);
|
|
setOpenLinks(false);
|
|
|
|
connect(this, SIGNAL(anchorClicked(QUrl)), this, SLOT(linkClicked(QUrl)));
|
|
}
|
|
|
|
void LinkTextBrowser::linkClicked(const QUrl &url)
|
|
{
|
|
// some links are opened directly in the QTextBrowser with open external links set to true,
|
|
// so we handle links by our own
|
|
|
|
#ifdef TO_DO
|
|
// If we want extra file links to be anonymous, we need to insert the actual source here.
|
|
if(url.host() == HOST_EXTRAFILE)
|
|
{
|
|
std::cerr << "Extra file link detected. Adding parent id " << _target_sslid << " to sourcelist" << std::endl;
|
|
|
|
RetroShareLink link ;
|
|
link.fromUrl(url) ;
|
|
|
|
link.createExtraFile( link.name(),link.size(),link.hash(), _target_ssl_id) ;
|
|
|
|
QDesktopServices::openUrl(link.toUrl());
|
|
}
|
|
else
|
|
#endif
|
|
QDesktopServices::openUrl(url);
|
|
}
|
|
|
|
void LinkTextBrowser::setPlaceholderText(const QString &text)
|
|
{
|
|
placeholderText = text;
|
|
viewport()->repaint();
|
|
}
|
|
|
|
void LinkTextBrowser::paintEvent(QPaintEvent *event)
|
|
{
|
|
QTextBrowser::paintEvent(event);
|
|
|
|
if (placeholderText.isEmpty() == false && document()->isEmpty()) {
|
|
QWidget *vieportWidget = viewport();
|
|
QPainter painter(vieportWidget);
|
|
|
|
QPen pen = painter.pen();
|
|
QColor color = pen.color();
|
|
color.setAlpha(128);
|
|
pen.setColor(color);
|
|
painter.setPen(pen);
|
|
|
|
painter.drawText(QRect(QPoint(), vieportWidget->size()), Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextWordWrap, placeholderText);
|
|
}
|
|
}
|
|
|