Plugin LinksCloud:

- Fixed crash when clicking on the link.
- Fixed process of https links.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5623 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-09-30 13:16:51 +00:00
parent 9aa6478910
commit e7ff4bbab8
5 changed files with 12 additions and 76 deletions

View File

@ -98,7 +98,7 @@ std::string LinksCloudPlugin::getPluginName() const
return QApplication::translate("LinksCloudPlugin", "LinksCloud").toUtf8().constData(); return QApplication::translate("LinksCloudPlugin", "LinksCloud").toUtf8().constData();
} }
QTranslator* LinksCloudPlugin::qt_translator(QApplication *app, const QString& languageCode) const QTranslator* LinksCloudPlugin::qt_translator(QApplication */*app*/, const QString& languageCode) const
{ {
if (languageCode == "en") { if (languageCode == "en") {
return NULL; return NULL;

View File

@ -76,9 +76,6 @@ LinksDialog::LinksDialog(RsPeers *peers, RsFiles *files, QWidget *parent)
connect( ui.anonBox, SIGNAL( stateChanged ( int ) ), this, SLOT( checkAnon ( void ) ) ); connect( ui.anonBox, SIGNAL( stateChanged ( int ) ), this, SLOT( checkAnon ( void ) ) );
connect( ui.linklabel, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
mStart = 0; mStart = 0;
@ -168,7 +165,7 @@ void LinksDialog::linkTreeWidgetCostumPopupMenu( QPoint point )
contextMnu.addSeparator(); contextMnu.addSeparator();
contextMnu.addAction(downloadAct); contextMnu.addAction(downloadAct);
contextMnu.exec(QCursor::pos()); contextMnu.exec(ui.linkTreeWidget->viewport()->mapToGlobal(point));
} }
void LinksDialog::changedSortRank( int index ) void LinksDialog::changedSortRank( int index )
@ -657,7 +654,7 @@ void LinksDialog::updateComments(std::string rid, std::string )
/* set Link details */ /* set Link details */
ui.titleLineEdit->setText(QString::fromStdWString(detail.title)); ui.titleLineEdit->setText(QString::fromStdWString(detail.title));
ui.linkLineEdit->setText(QString::fromStdWString(detail.link)); ui.linkLineEdit->setText(QString::fromStdWString(detail.link));
ui.linklabel->setHtml("<a href='" + QString::fromStdWString(detail.link) + "'> " + QString::fromStdWString(detail.link) +"</a>"); ui.linklabel->setText("<a href='" + QString::fromStdWString(detail.link) + "'> " + QString::fromStdWString(detail.link) +"</a>");
if (mLinkId == rid) if (mLinkId == rid)
@ -992,60 +989,6 @@ void LinksDialog::downloadSelected()
// rsFiles->FileRequest(rslink.name().toStdString(), rslink.hash().toStdString(), rslink.size(), "", 0, srcIds); // rsFiles->FileRequest(rslink.name().toStdString(), rslink.hash().toStdString(), rslink.size(), "", 0, srcIds);
} }
void LinksDialog::anchorClicked (const QUrl& link )
{
#ifdef LINK_DEBUG
std::cerr << "LinksDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl;
#endif
if (link.scheme() == "retroshare")
{
QStringList L = link.toString().split("|") ;
std::string fileName = L.at(1).toStdString() ;
uint64_t fileSize = L.at(2).toULongLong();
std::string fileHash = L.at(3).toStdString() ;
#ifdef LINK_DEBUG
std::cerr << "LinksDialog::anchorClicked FileRequest : fileName : " << fileName << ". fileHash : " << fileHash << ". fileSize : " << fileSize << std::endl;
#endif
if (fileName != "" && fileHash != "")
{
std::list<std::string> srcIds;
if(mFiles->FileRequest(fileName, fileHash, fileSize, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds))
{
QMessageBox mb(tr("File Request Confirmation"), tr("The file has been added to your download list."),QMessageBox::Information,QMessageBox::Ok,0,0,this);
mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
mb.exec();
}
else
{
QMessageBox mb(tr("File Request canceled"), tr("The file has not been added to your download list, because you already have it."),QMessageBox::Information,QMessageBox::Ok,0,0,this);
mb.exec();
}
}
else
{
QMessageBox mb(tr("File Request Error"), tr("The file link is malformed."),QMessageBox::Information,QMessageBox::Ok,0,0,this);
mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
mb.exec();
}
}
else if (link.scheme() == "http")
{
QDesktopServices::openUrl(link);
}
else if (link.scheme() == "")
{
//it's probably a web adress, let's add http:// at the beginning of the link
QString newAddress = link.toString();
newAddress.prepend("http://");
QDesktopServices::openUrl(QUrl(newAddress));
}
}
void LinksDialog::addNewLink() void LinksDialog::addNewLink()
{ {

View File

@ -67,8 +67,6 @@ private slots:
void checkUpdate(); void checkUpdate();
void anchorClicked (const QUrl &);
void addNewLink(); void addNewLink();
private: private:

View File

@ -291,23 +291,18 @@
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="12"> <item row="1" column="1" colspan="12">
<widget class="QTextBrowser" name="linklabel"> <widget class="QLabel" name="linklabel">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
</size>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QTextBrowser{border: 2px solid #CCCCCC; <string notr="true">QLabel{border: 2px solid #CCCCCC;
border-radius: 10px; border-radius: 10px;
background: white;}</string> background: white;
padding:2}</string>
</property> </property>
<property name="verticalScrollBarPolicy"> <property name="openExternalLinks">
<enum>Qt::ScrollBarAlwaysOff</enum> <bool>true</bool>
</property> </property>
<property name="openLinks"> <property name="textInteractionFlags">
<bool>false</bool> <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -157,7 +157,7 @@ std::string VOIPPlugin::getPluginName() const
return QApplication::translate("VOIPPlugin", "VOIP").toUtf8().constData(); return QApplication::translate("VOIPPlugin", "VOIP").toUtf8().constData();
} }
QTranslator* VOIPPlugin::qt_translator(QApplication *app, const QString& languageCode) const QTranslator* VOIPPlugin::qt_translator(QApplication */*app*/, const QString& languageCode) const
{ {
if (languageCode == "en") { if (languageCode == "en") {
return NULL; return NULL;