diff --git a/retroshare-gui/src/gui/AddLinksDialog.cpp b/retroshare-gui/src/gui/AddLinksDialog.cpp index 0b205e653..adb3c2943 100644 --- a/retroshare-gui/src/gui/AddLinksDialog.cpp +++ b/retroshare-gui/src/gui/AddLinksDialog.cpp @@ -22,6 +22,7 @@ #include "common/vmessagebox.h" #include "AddLinksDialog.h" +#include "RetroShareLinkAnalyzer.h" #include "rsiface/rsrank.h" /* Images for context menu icons */ @@ -33,7 +34,7 @@ #define IMAGE_BADLINK ":/images/filerating1.png" /** Constructor */ -AddLinksDialog::AddLinksDialog(QWidget *parent) +AddLinksDialog::AddLinksDialog(QString url, QWidget *parent) : QDialog(parent) { /* Invoke the Qt Designer generated object setup routine */ @@ -44,6 +45,20 @@ AddLinksDialog::AddLinksDialog(QWidget *parent) connect(ui.closepushButton, SIGNAL(clicked()), this, SLOT(close())); ui.linkLineEdit->setReadOnly(true); + ui.linkLineEdit->setText(url); + + RetroShareLinkAnalyzer analyzer(url); + QVector linkList; + analyzer.getFileInformation(linkList); + if (!linkList.isEmpty()) + { /* set title as first name from list */ + RetroShareLinkData item = linkList.first(); + ui.titleLineEdit->setText(item.getName()); + } + else + { + ui.titleLineEdit->setText("New File"); + } /* Hide platform specific features */ #ifdef Q_WS_WIN @@ -91,13 +106,3 @@ void AddLinksDialog::addLinkComment() close(); } - -void AddLinksDialog::insertTitleText(std::string title) -{ - ui.titleLineEdit->setText(QString::fromStdString(title)); -} - -void AddLinksDialog::insertLinkText(std::string link) -{ - ui.linkLineEdit->setText(QString::fromStdString(link)); -} diff --git a/retroshare-gui/src/gui/AddLinksDialog.h b/retroshare-gui/src/gui/AddLinksDialog.h index 52a68060e..b53e47328 100644 --- a/retroshare-gui/src/gui/AddLinksDialog.h +++ b/retroshare-gui/src/gui/AddLinksDialog.h @@ -30,12 +30,9 @@ class AddLinksDialog : public QDialog public: /** Default Constructor */ - AddLinksDialog(QWidget *parent = 0); + AddLinksDialog(QString url, QWidget *parent = 0); /** Default Destructor */ - void insertTitleText(std::string title); - void insertLinkText(std::string link); - static int IndexToScore(int index); public slots: diff --git a/retroshare-gui/src/gui/SharedFilesDialog.cpp b/retroshare-gui/src/gui/SharedFilesDialog.cpp index f274d626e..f54e0bfc0 100644 --- a/retroshare-gui/src/gui/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/SharedFilesDialog.cpp @@ -341,10 +341,7 @@ void SharedFilesDialog::sendLinkToCloud() { copyLinkLocal (); - AddLinksDialog *nAddLinksDialog = new AddLinksDialog(); - - nAddLinksDialog->insertTitleText("New File"); - nAddLinksDialog->insertLinkText(QApplication::clipboard()->text().toStdString()); + AddLinksDialog *nAddLinksDialog = new AddLinksDialog(QApplication::clipboard()->text()); nAddLinksDialog->addLinkComment(); nAddLinksDialog->close(); @@ -354,10 +351,7 @@ void SharedFilesDialog::addLinkToCloud() { copyLinkLocal (); - AddLinksDialog *nAddLinksDialog = new AddLinksDialog(this); - - nAddLinksDialog->insertTitleText("New File"); - nAddLinksDialog->insertLinkText(QApplication::clipboard()->text().toStdString()); + AddLinksDialog *nAddLinksDialog = new AddLinksDialog(QApplication::clipboard()->text()); nAddLinksDialog->show(); }