Added to send own Shared File as link to Public Chat

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2169 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-02-01 14:47:54 +00:00
parent 1600831e16
commit 309e88e6b7
6 changed files with 299 additions and 1 deletions

View File

@ -146,6 +146,7 @@ HEADERS += rshare.h \
gui/RemoteDirModel.h \
gui/RetroShareLinkAnalyzer.h \
gui/SearchTreeWidget.h \
gui/SendLinkDialog.h \
gui/SearchDialog.h \
gui/SharedFilesDialog.h \
gui/ShareManager.h \
@ -260,6 +261,7 @@ FORMS += gui/StartDialog.ui \
gui/MessengerWindow.ui \
gui/PeersDialog.ui \
gui/SearchDialog.ui \
gui/SendLinkDialog.ui \
gui/SharedFilesDialog.ui \
gui/ShareManager.ui \
gui/MessagesDialog.ui \
@ -331,6 +333,7 @@ SOURCES += main.cpp \
gui/RetroShareLinkAnalyzer.cpp \
gui/SearchTreeWidget.cpp \
gui/SearchDialog.cpp \
gui/SendLinkDialog.cpp \
gui/AddLinksDialog.cpp \
gui/SharedFilesDialog.cpp \
gui/ShareManager.cpp \

View File

@ -0,0 +1,76 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006 - 2009, RetroShre Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "SendLinkDialog.h"
#include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsdisc.h"
#include "rsiface/rsmsgs.h"
#include <QTime>
#include <sstream>
#include <iomanip>
/** Default constructor */
SendLinkDialog::SendLinkDialog(QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags)
{
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(ui.sendButton, SIGNAL(clicked()), this, SLOT(sendLinktoChat()));
}
/** Destructor. */
SendLinkDialog::~SendLinkDialog()
{
}
void SendLinkDialog::closeEvent (QCloseEvent * event)
{
QDialog::closeEvent(event);
}
void SendLinkDialog::insertHtmlText(std::string msg)
{
ui.linkText->setHtml(QString("<a href='") + QString::fromStdString(std::string(msg + "'> ") ) + QString::fromStdString(std::string(msg)) + "</a>") ;
}
void SendLinkDialog::sendLinktoChat()
{
ChatInfo ci;
ci.msg = ui.linkText->toHtml().toStdWString();
ci.chatflags = RS_CHAT_PUBLIC;
rsMsgs -> ChatSend(ci);
close();
}

View File

@ -0,0 +1,63 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006 - 2010, RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _SENDLINKDIALOG_H
#define _SENDLINKDIALOG_H
#include <QDialog>
#include <gui/settings/rsharesettings.h>
#include "ui_SendLinkDialog.h"
class SendLinkDialog : public QDialog
{
Q_OBJECT
public:
/** Default constructor */
SendLinkDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */
~SendLinkDialog();
void insertHtmlText(std::string msg);
protected:
void closeEvent (QCloseEvent * event);
private slots:
void sendLinktoChat();
private:
/** A RshareSettings object used for saving/loading settings */
//RshareSettings* _settings;
/** Qt Designer generated object */
Ui::SendLinkDialog ui;
};
#endif

View File

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SendLinkDialog</class>
<widget class="QDialog" name="SendLinkDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>477</width>
<height>212</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1000</width>
<height>1000</height>
</size>
</property>
<property name="windowTitle">
<string>Send RetroShare link</string>
</property>
<property name="windowIcon">
<iconset resource="images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QFrame" name="frame_2">
<property name="styleSheet">
<string notr="true">QFrame#frame_2{
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #FEFEFE, stop:1 #E8E8E8);
border: 1px solid #CCCCCC;}
</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QTextEdit" name="linkText"/>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="sendButton">
<property name="text">
<string>Send</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="styleSheet">
<string notr="true">QFrame#frame{background-image: url(:/images/connect/connectFriendBanner.png);}
</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/ktorrent.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:22pt; color:#ffffff;&quot;&gt;Send RetroShare Link&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -19,18 +19,20 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "rshare.h"
#include "SharedFilesDialog.h"
#include "settings/AddFileAssociationDialog.h"
#include "rsiface/rsiface.h"
#include "rsiface/rsmsgs.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsfiles.h"
#include "util/RsAction.h"
#include "msgs/ChanMsgDialog.h"
#include "settings/rsharesettings.h"
#include "AddLinksDialog.h"
#include "SendLinkDialog.h"
#ifndef RETROSHARE_LINK_ANALYZER
#include "RetroShareLinkAnalyzer.h"
@ -363,6 +365,18 @@ void SharedFilesDialog::sendHtmlLinkTo( )
nMsgDialog->show();
}
void SharedFilesDialog::sendLinktoChat()
{
copyLinkLocal ();
static SendLinkDialog *slinkDialog = new SendLinkDialog(this);
slinkDialog->insertHtmlText(QApplication::clipboard()->text().toStdString());
slinkDialog->show();
}
void SharedFilesDialog::sendLinkToCloud()
{
copyLinkLocal ();
@ -648,6 +662,9 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
sendhtmllinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link (html)" ), this );
connect( sendhtmllinkAct , SIGNAL( triggered() ), this, SLOT( sendHtmlLinkTo( ) ) );
sendchatlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link to Chat" ), this );
connect( sendchatlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinktoChat( ) ) );
sendlinkCloudAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link to Cloud" ), this );
connect( sendlinkCloudAct , SIGNAL( triggered() ), this, SLOT( sendLinkToCloud( ) ) );
@ -676,6 +693,7 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
contextMnu2.addAction( copylinklocalAct);
contextMnu2.addAction( sendlinkAct);
contextMnu2.addAction( sendhtmllinkAct);
contextMnu2.addAction( sendchatlinkAct);
contextMnu2.addSeparator();
contextMnu2.addAction( sendlinkCloudAct);
contextMnu2.addAction( addlinkCloudAct);

View File

@ -69,6 +69,7 @@ private slots:
void sendHtmlLinkTo();
void sendLinkToCloud();
void addLinkToCloud();
void sendLinktoChat();
void showFrame(bool show);
void showFrameRemote(bool show);
@ -114,6 +115,7 @@ private:
QAction* sendhtmllinkAct;
QAction* sendlinkCloudAct;
QAction* addlinkCloudAct;
QAction* sendchatlinkAct;
QTreeView *shareddirtreeview;
QMovie *movie;