From 7941ef591edfb692d22c34d076edb25774d434e1 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 5 Feb 2010 13:44:33 +0000 Subject: [PATCH] changes for LinksDialog: disabled bold text, added a Label to display each Link in html format git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2197 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/LinksDialog.cpp | 93 +++++++++++++--- retroshare-gui/src/gui/LinksDialog.h | 74 ++++++------- retroshare-gui/src/gui/LinksDialog.ui | 141 +++++++++++++++++++------ 3 files changed, 229 insertions(+), 79 deletions(-) diff --git a/retroshare-gui/src/gui/LinksDialog.cpp b/retroshare-gui/src/gui/LinksDialog.cpp index 073525a4b..75168ec07 100644 --- a/retroshare-gui/src/gui/LinksDialog.cpp +++ b/retroshare-gui/src/gui/LinksDialog.cpp @@ -90,26 +90,25 @@ LinksDialog::LinksDialog(QWidget *parent) connect( ui.anonBox, SIGNAL( stateChanged ( int ) ), this, SLOT( checkAnon ( void ) ) ); + connect( ui.linklabel, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &))); mStart = 0; - /* hide the Tree +/- */ -// ui.linkTreeWidget -> setRootIsDecorated( false ); - /* Set header resize modes and initial section sizes */ QHeaderView * _header = ui.linkTreeWidget->header () ; -// _header->setResizeMode (0, QHeaderView::Custom); - _header->setResizeMode (0, QHeaderView::Interactive); + _header->setResizeMode (0, QHeaderView::Interactive); _header->setResizeMode (1, QHeaderView::Interactive); _header->setResizeMode (2, QHeaderView::Interactive); _header->resizeSection ( 0, 400 ); - _header->resizeSection ( 1, 50 ); + _header->resizeSection ( 1, 60 ); _header->resizeSection ( 2, 150 ); ui.linkTreeWidget->setSortingEnabled(true); + + ui.linklabel->setMinimumWidth(20); /* Set a GUI update timer - much cleaner than @@ -366,10 +365,10 @@ void LinksDialog::updateLinks() { item -> setText(0, QString::fromStdWString(detail.title)); /* Bold and bigger */ - QFont font = item->font(0); + /*QFont font = item->font(0); font.setBold(true); font.setPointSize(font.pointSize() + 2); - item->setFont(0, font); + item->setFont(0, font);*/ } /* (1) Rank */ @@ -378,22 +377,31 @@ void LinksDialog::updateLinks() out << 100 * (detail.rank / (maxRank + 0.01)); item -> setText(1, QString::fromStdString(out.str())); /* Bold and bigger */ - QFont font = item->font(1); - //font.setBold(true); + /*QFont font = item->font(1); + font.setBold(true); font.setPointSize(font.pointSize() + 2); - item->setFont(1, font); + item->setFont(1, font);*/ } /* (2) Link */ { item -> setText(2, QString::fromStdWString(detail.link)); /* Bold and bigger */ - QFont font = item->font(2); + /*QFont font = item->font(2); font.setBold(true); font.setPointSize(font.pointSize() + 2); - item->setFont(2, font); + item->setFont(2, font);*/ } + + /* (3) Date */ + /*{ + QDateTime qtime; + qtime.setTime_t(it->lastPost); + QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss"); + item -> setText(3, timestamp); + }*/ + /* (4) rid */ item -> setText(4, QString::fromStdString(detail.rid)); @@ -654,6 +662,8 @@ void LinksDialog::updateComments(std::string rid, std::string pid) /* set Link details */ ui.titleLineEdit->setText(QString::fromStdWString(detail.title)); ui.linkLineEdit->setText(QString::fromStdWString(detail.link)); + ui.linklabel->setHtml(" " + QString::fromStdWString(detail.link) +""); + if (mLinkId == rid) { @@ -998,3 +1008,60 @@ void LinksDialog::downloadSelected() rsFiles->FileRequest(item.getName().toStdString(), item.getHash().toStdString(), item.getSize().toULong(), "", 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 srcIds; + + if(rsFiles->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); + mb.setButtonText( QMessageBox::Ok, "OK" ); + 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); + mb.setButtonText( QMessageBox::Ok, "OK" ); + mb.exec(); + } + } + else + { + QMessageBox mb(tr("File Request Error"), tr("The file link is malformed."),QMessageBox::Information,QMessageBox::Ok,0,0); + mb.setButtonText( QMessageBox::Ok, "OK" ); + 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)); + } +} diff --git a/retroshare-gui/src/gui/LinksDialog.h b/retroshare-gui/src/gui/LinksDialog.h index d4871568d..ff6662f5f 100644 --- a/retroshare-gui/src/gui/LinksDialog.h +++ b/retroshare-gui/src/gui/LinksDialog.h @@ -17,30 +17,30 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - ****************************************************************/ - + ****************************************************************/ + #ifndef _LINKS_DIALOG_H -#define _LINKS_DIALOG_H - +#define _LINKS_DIALOG_H + #include -#include "mainpage.h" -#include "ui_LinksDialog.h" - +#include "mainpage.h" +#include "ui_LinksDialog.h" -class LinksDialog : public MainPage -{ - Q_OBJECT - -public: - /** Default Constructor */ - LinksDialog(QWidget *parent = 0); - /** Default Destructor */ + +class LinksDialog : public MainPage +{ + Q_OBJECT + +public: + /** Default Constructor */ + LinksDialog(QWidget *parent = 0); + /** Default Destructor */ void insertExample(); -private slots: - /** Create the context popup menu and it's submenus */ +private slots: + /** Create the context popup menu and it's submenus */ void linkTreeWidgetCostumPopupMenu( QPoint point ); void voteup_anon(); @@ -52,20 +52,22 @@ private slots: void voteup_m2(); void downloadSelected(); -void changedSortRank( int index ); -void changedSortPeriod( int index ); -void changedSortFrom( int index ); -void changedSortTop( int index ); + void changedSortRank( int index ); + void changedSortPeriod( int index ); + void changedSortFrom( int index ); + void changedSortTop( int index ); -void updateLinks(); -void addLinkComment( void ); -void toggleWindows( void ); + void updateLinks(); + void addLinkComment( void ); + void toggleWindows( void ); -void openLink ( QTreeWidgetItem * item, int column ); -void changedItem(QTreeWidgetItem *curr, QTreeWidgetItem *prev); -void checkAnon(); + void openLink ( QTreeWidgetItem * item, int column ); + void changedItem(QTreeWidgetItem *curr, QTreeWidgetItem *prev); + void checkAnon(); -void checkUpdate(); + void checkUpdate(); + + void anchorClicked (const QUrl &); private: @@ -80,18 +82,18 @@ void updateComments(std::string rid, std::string pid); /* (2) Utility Fns */ QTreeWidgetItem *getCurrentLine(); - /** Define the popup menus for the Context menu */ + /** Define the popup menus for the Context menu */ QMenu* contextMnu; - /** Defines the actions for the context menu */ + /** Defines the actions for the context menu */ QAction* voteupAct; QAction* votedownAct; QAction* downloadAct; QTreeWidget *exampletreeWidget; - - /** Qt Designer generated object */ - Ui::LinksDialog ui; -}; - -#endif + + /** Qt Designer generated object */ + Ui::LinksDialog ui; +}; + +#endif diff --git a/retroshare-gui/src/gui/LinksDialog.ui b/retroshare-gui/src/gui/LinksDialog.ui index 59b4e4677..f4504ccaa 100644 --- a/retroshare-gui/src/gui/LinksDialog.ui +++ b/retroshare-gui/src/gui/LinksDialog.ui @@ -60,7 +60,7 @@ - + @@ -71,7 +71,7 @@ - + Qt::Horizontal @@ -84,7 +84,7 @@ - + @@ -98,11 +98,11 @@ - + - 12 + 11 @@ -114,15 +114,23 @@ Time + + + :/images/kalarm.png:/images/kalarm.png + Ranking + + + :/images/records.png:/images/records.png + - + Qt::Horizontal @@ -135,7 +143,7 @@ - + @@ -149,31 +157,43 @@ - + - 12 + 11 Month + + + :/images/view_calendar_month.png:/images/view_calendar_month.png + Week + + + :/images/view_calendar_week.png:/images/view_calendar_week.png + Day + + + :/images/view_calendar_day.png:/images/view_calendar_day.png + - + Qt::Horizontal @@ -186,7 +206,7 @@ - + @@ -200,26 +220,34 @@ - + - 12 + 11 All Peers + + + :/images/user/friends24.png:/images/user/friends24.png + Own Links + + + :/images/user/identity16.png:/images/user/identity16.png + - + Qt::Horizontal @@ -232,7 +260,7 @@ - + @@ -246,17 +274,21 @@ - + - 12 + 11 Top 100 + + + :/images/records.png:/images/records.png + @@ -285,6 +317,40 @@ + + + + + 16777215 + 22 + + + + QTextBrowser{border: 2px solid #CCCCCC; +border-radius: 10px; +background: white;} + + + Qt::ScrollBarAlwaysOff + + + false + + + + + + + + 75 + true + + + + Link: + + + @@ -308,7 +374,7 @@ - 12 + 11 50 false @@ -322,7 +388,7 @@ - 12 + 11 @@ -338,9 +404,9 @@ - 12 - 75 - true + 10 + 50 + false @@ -352,18 +418,23 @@ - 12 + 11 + + QLineEdit{border: 2px solid #CCCCCC; +border-radius: 10px; +background: white;} + - 12 - 75 - true + 10 + 50 + false @@ -428,9 +499,9 @@ - 12 - 75 - true + 10 + 50 + false @@ -442,9 +513,14 @@ - 12 + 11 + + QLineEdit{border: 2px solid #CCCCCC; +border-radius: 10px; +background: white;} + @@ -468,6 +544,11 @@ 12 + + QTextEdit{border: 2px solid #CCCCCC; +border-radius: 10px; +background: white;} +