mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-24 22:30:42 -04:00
added "copy http link" action to board posts when possible
This commit is contained in:
parent
24dd71d15f
commit
5ca3b15188
2 changed files with 39 additions and 0 deletions
|
@ -22,6 +22,7 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "retroshare/rsgxscircles.h"
|
#include "retroshare/rsgxscircles.h"
|
||||||
|
@ -72,6 +73,7 @@ static const int POSTED_TABS_POSTS = 1;
|
||||||
//
|
//
|
||||||
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
||||||
#define IMAGE_AUTHOR ":/images/user/personal64.png"
|
#define IMAGE_AUTHOR ":/images/user/personal64.png"
|
||||||
|
#define IMAGE_COPYHTTP ":/images/emblem-web.png"
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(RsPostedPost);
|
Q_DECLARE_METATYPE(RsPostedPost);
|
||||||
|
|
||||||
|
@ -340,7 +342,18 @@ void PostedListWidgetWithModel::postContextMenu(const QPoint& point)
|
||||||
|
|
||||||
// 2 - generate the menu for that post.
|
// 2 - generate the menu for that post.
|
||||||
|
|
||||||
|
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
|
||||||
|
|
||||||
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink()))->setData(index);
|
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink()))->setData(index);
|
||||||
|
|
||||||
|
QByteArray urlarray(post.mLink.c_str());
|
||||||
|
QUrl url = QUrl::fromEncoded(urlarray.trimmed());
|
||||||
|
|
||||||
|
std::cerr << "Using link: \"" << post.mLink << "\"" << std::endl;
|
||||||
|
|
||||||
|
if(url.scheme()=="http" || url.scheme()=="https")
|
||||||
|
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYHTTP), tr("Copy http Link"), this, SLOT(copyHttpLink()))->setData(index);
|
||||||
|
|
||||||
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_AUTHOR), tr("Show author in People tab"), this, SLOT(showAuthorInPeople()))->setData(index);
|
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_AUTHOR), tr("Show author in People tab"), this, SLOT(showAuthorInPeople()))->setData(index);
|
||||||
|
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
|
@ -456,6 +469,31 @@ void PostedListWidgetWithModel::showAuthorInPeople()
|
||||||
MainWindow::showWindow(MainWindow::People);
|
MainWindow::showWindow(MainWindow::People);
|
||||||
idDialog->navigate(RsGxsId(post.mMeta.mAuthorId));
|
idDialog->navigate(RsGxsId(post.mMeta.mAuthorId));
|
||||||
}
|
}
|
||||||
|
void PostedListWidgetWithModel::copyHttpLink()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (groupId().isNull())
|
||||||
|
throw std::runtime_error("No channel currently selected!");
|
||||||
|
|
||||||
|
QModelIndex index = qobject_cast<QAction*>(QObject::sender())->data().toModelIndex();
|
||||||
|
|
||||||
|
if(!index.isValid())
|
||||||
|
throw std::runtime_error("No post under mouse!");
|
||||||
|
|
||||||
|
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
|
||||||
|
|
||||||
|
if(post.mMeta.mMsgId.isNull())
|
||||||
|
throw std::runtime_error("Post has empty MsgId!");
|
||||||
|
|
||||||
|
QApplication::clipboard()->setText(QString::fromStdString(post.mLink)) ;
|
||||||
|
QMessageBox::information(NULL,tr("information"),tr("The Retrohare link was copied to your clipboard.")) ;
|
||||||
|
}
|
||||||
|
catch(std::exception& e)
|
||||||
|
{
|
||||||
|
QMessageBox::critical(NULL,tr("Link creation error"),tr("Link could not be created: ")+e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
void PostedListWidgetWithModel::copyMessageLink()
|
void PostedListWidgetWithModel::copyMessageLink()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -147,6 +147,7 @@ private slots:
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
void postPostLoad();
|
void postPostLoad();
|
||||||
void copyMessageLink();
|
void copyMessageLink();
|
||||||
|
void copyHttpLink();
|
||||||
void nextPosts();
|
void nextPosts();
|
||||||
void prevPosts();
|
void prevPosts();
|
||||||
void filterItems(QString s);
|
void filterItems(QString s);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue