add file button to general message; add extra file sending from chat dialog; Add a link when sending a file; Add a link for downloading in the reciever chat dialog; Little gui improvement

Merge branch 'extraFile'


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1181 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2009-05-06 21:15:12 +00:00
parent e34173759e
commit 8e6f082025
8 changed files with 441 additions and 269 deletions

View File

@ -48,6 +48,8 @@ GeneralMsgDialog::GeneralMsgDialog(QWidget *parent, uint32_t type)
connect(buttonBox, SIGNAL(accepted()), this, SLOT(sendMsg()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(cancelMsg()));
connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
/* set the type to ...
* const uint32_t GMD_TYPE_MESSAGE_IDX = 0;
* const uint32_t GMD_TYPE_FORUM_IDX = 1;
@ -289,6 +291,23 @@ void GeneralMsgDialog::addAttachment(std::string hash, std::string fname, uint64
}
void GeneralMsgDialog::addExtraFile()
{
/* add a SubFileItem to the attachment section */
std::cerr << "GeneralMsgDialog::addExtraFile() opening file dialog";
std::cerr << std::endl;
// select a file
QString qfile = QFileDialog::getOpenFileName(this, tr("Add Extra File"), "", "", 0,
QFileDialog::DontResolveSymlinks);
std::string filePath = qfile.toStdString();
if (filePath != "")
{
addAttachment(filePath);
}
}
void GeneralMsgDialog::addAttachment(std::string path)
{
/* add a SubFileItem to the attachment section */

View File

@ -54,6 +54,7 @@ virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dropEvent(QDropEvent *event);
private slots:
void addExtraFile();
void checkAttachmentReady();
void updateGroupId();
void newDestination();

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GeneralMsgDialog</class>
<widget class="QDialog" name="GeneralMsgDialog">
@ -53,7 +54,7 @@
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
@ -69,7 +70,7 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
@ -80,7 +81,7 @@
<item>
<widget class="QPushButton" name="addButton">
<property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -92,7 +93,8 @@
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc" >:/images/loadcert16.png</iconset>
<iconset resource="images.qrc">
<normaloff>:/images/loadcert16.png</normaloff>:/images/loadcert16.png</iconset>
</property>
</widget>
</item>
@ -130,7 +132,7 @@
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
@ -156,7 +158,7 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>271</width>
<height>20</height>
@ -189,9 +191,9 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" >
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" >
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
@ -210,9 +212,9 @@
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<width>13</width>
<height>20</height>
</size>
</property>
@ -236,14 +238,25 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>271</width>
<width>218</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="addFileButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -278,7 +291,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>

View File

@ -36,6 +36,9 @@
#include "rsiface/rspeers.h"
#include "rsiface/rsmsgs.h"
#include "rsiface/rsfiles.h"
#include "gui/feeds/SubFileItem.h"
#define appDir QApplication::applicationDirPath()
@ -76,6 +79,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
connect(ui.chattextEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) ));
connect(ui.sendButton, SIGNAL(clicked( ) ), this, SLOT(sendChat( ) ));
connect(ui.addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(ui.textboldButton, SIGNAL(clicked()), this, SLOT(setFont()));
connect(ui.textunderlineButton, SIGNAL(clicked()), this, SLOT(setFont()));
@ -85,10 +89,13 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
connect(ui.emoteiconButton, SIGNAL(clicked()), this, SLOT(smileyWidget()));
connect(ui.styleButton, SIGNAL(clicked()), SLOT(changeStyle()));
connect(ui.textBrowser, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
// Create the status bar
resetStatusBar() ;
ui.textBrowser->setOpenExternalLinks ( false );
ui.textBrowser->setOpenLinks ( false );
QString title = QString::fromStdString(name) + " :" + tr(" RetroShare - Encrypted Chat") ;
setWindowTitle(title);
@ -678,3 +685,99 @@ void PopupChatDialog::getAvatar()
}
}
void PopupChatDialog::addExtraFile()
{
// select a file
QString qfile = QFileDialog::getOpenFileName(this, tr("Add Extra File"), "", "", 0,
QFileDialog::DontResolveSymlinks);
std::string filePath = qfile.toStdString();
if (filePath != "")
{
/* add a SubFileItem to the attachment section */
std::cerr << "PopupChatDialog::addExtraFile() hashing file.";
std::cerr << std::endl;
/* add widget in for new destination */
SubFileItem *file = new SubFileItem(filePath);
//file->
ui.SendLayout->addWidget(file, 1, 0);
//when the file is local or is finished hashing, call the fileHashingFinished method to send a chat message
if (file->getState() == SFI_STATE_LOCAL) {
fileHashingFinished(file);
} else {
QObject::connect(file,SIGNAL(fileFinished(SubFileItem *)), SLOT(fileHashingFinished(SubFileItem *))) ;
}
}
}
void PopupChatDialog::fileHashingFinished(SubFileItem* file) {
std::cerr << "PopupChatDialog::fileHashingFinished() started.";
std::cerr << std::endl;
ChatInfo ci;
{
rsiface->lockData(); /* Lock Interface */
const RsConfig &conf = rsiface->getConfig();
ci.rsid = conf.ownId;
ci.name = conf.ownName;
rsiface->unlockData(); /* Unlock Interface */
}
//convert fileSize from uint_64 to string for html link
char fileSizeChar [100];
sprintf(fileSizeChar, "%lld", file->FileSize());
std::string fileSize = *(&fileSizeChar);
std::string mesgString = "<a href='file:?fileHash=" + (file->FileHash()) + "&fileName=" + (file->FileName()) + "&fileSize=" + fileSize + "'>" + (file->FileName()) + "</a>";
#ifdef CHAT_DEBUG
std::cerr << "PopupChatDialog::anchorClicked mesgString : " << mesgString << std::endl;
#endif
const char * messageString = mesgString.c_str ();
//convert char massageString to w_char
wchar_t* message;
int requiredSize = mbstowcs(NULL, messageString, 0); // C4996
/* Add one to leave room for the NULL terminator */
message = (wchar_t *)malloc( (requiredSize + 1) * sizeof( wchar_t ));
if (! message)
{
std::cerr << ("Memory allocation failure.\n");
}
int size = mbstowcs( message, messageString, requiredSize + 1); // C4996
if (size == (size_t) (-1))
{
printf("Couldn't convert string--invalid multibyte character.\n");
}
ci.msg = message;
ci.chatflags = RS_CHAT_PRIVATE;
addChatMsg(&ci);
/* put proper destination */
ci.rsid = dialogId;
ci.name = dialogName;
rsMsgs -> ChatSend(ci);
}
void PopupChatDialog::anchorClicked (const QUrl& link ) {
std::string fileName = link.queryItemValue(QString("fileName")).toStdString();
std::string fileHash = link.queryItemValue(QString("fileHash")).toStdString();
uint32_t fileSize = link.queryItemValue(QString("fileSize")).toInt();
#ifdef CHAT_DEBUG
std::cerr << "PopupChatDialog::anchorClicked FileRequest : fileName : " << fileName << ". fileHash : " << fileHash << ". fileSize : " << fileSize;
std::cerr << ". source id : " << dialogId << std::endl;
#endif
std::list<std::string> srcIds;
srcIds.push_front(dialogId);
rsFiles->FileRequest(fileName, fileHash, fileSize, "", 0, srcIds);
}

View File

@ -30,6 +30,7 @@
#include <gui/Preferences/rsharesettings.h>
#include "rsiface/rsiface.h"
#include "gui/feeds/SubFileItem.h"
@ -74,15 +75,19 @@ public slots:
void addSmiley();
void changeStyle();
void fileHashingFinished(SubFileItem* file);
void resetStatusBar() ;
void updateStatusTyping() ;
void updateStatusString(const QString&) ;
void anchorClicked (const QUrl &);
protected:
void closeEvent (QCloseEvent * event);
private slots:
void addExtraFile();
void showAvatarFrame(bool show);
void setColor();
@ -95,7 +100,6 @@ private slots:
void getAvatar();
private:
void colorChanged(const QColor &c);
@ -120,10 +124,9 @@ private:
QStringList history;
QString wholeChat;
/** Qt Designer generated object */
Ui::PopupChatDialog ui;
};
#endif

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PopupChatDialog</class>
<widget class="QMainWindow" name="PopupChatDialog">
@ -20,16 +21,13 @@
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing" >
<number>0</number>
</property>
<property name="verticalSpacing" >
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTextBrowser" name="textBrowser">
<property name="sizePolicy">
<sizepolicy vsizetype="MinimumExpanding" hsizetype="Expanding" >
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -48,7 +46,7 @@
</property>
</widget>
</item>
<item rowspan="4" row="0" column="1" >
<item row="0" column="1" rowspan="4">
<widget class="QFrame" name="avatarframe">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
@ -102,7 +100,7 @@ border-image: url(:/images/mystatus_bg.png);
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>61</width>
<height>141</height>
@ -146,7 +144,7 @@ border-image: url(:/images/mystatus_bg.png);
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>61</width>
<height>30</height>
@ -157,7 +155,7 @@ border-image: url(:/images/mystatus_bg.png);
</layout>
</widget>
</item>
<item rowspan="4" row="0" column="2" >
<item row="0" column="2" rowspan="4">
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="avatarFrameButton">
@ -192,7 +190,7 @@ border-image: url(:/images/mystatus_bg.png);
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>14</width>
<height>321</height>
@ -228,7 +226,7 @@ border-image: url(:/images/mystatus_bg.png);
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>190</width>
<height>25</height>
@ -239,7 +237,7 @@ border-image: url(:/images/mystatus_bg.png);
<item row="0" column="1">
<widget class="QPushButton" name="emoteiconButton">
<property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -282,10 +280,10 @@ border-image: url(:/images/mystatus_bg.png);
</size>
</property>
<property name="toolTip">
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
<string>&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>&lt;/head>&lt;body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Set Chat Window Style&lt;/p>&lt;/body>&lt;/html></string>
&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;Set Chat Window Style&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
@ -319,7 +317,8 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
<iconset>
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
</property>
<property name="checkable">
<bool>false</bool>
@ -347,7 +346,8 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
<iconset>
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
</property>
<property name="checkable">
<bool>false</bool>
@ -375,7 +375,8 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
<iconset>
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
</property>
<property name="checkable">
<bool>false</bool>
@ -403,7 +404,8 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
<iconset>
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
</property>
<property name="checkable">
<bool>false</bool>
@ -438,7 +440,7 @@ p, li { white-space: pre-wrap; }
<item row="2" column="0">
<widget class="QTextEdit" name="chattextEdit">
<property name="sizePolicy">
<sizepolicy vsizetype="Maximum" hsizetype="Expanding" >
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -446,7 +448,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="3" column="0">
<layout class="QGridLayout" >
<layout class="QVBoxLayout" name="SendLayout">
<property name="leftMargin">
<number>0</number>
</property>
@ -456,23 +458,42 @@ p, li { white-space: pre-wrap; }
<property name="bottomMargin">
<number>2</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
<item>
<layout class="QHBoxLayout" name="SendLayout">
<property name="leftMargin">
<number>0</number>
</property>
<item row="0" column="0" >
<property name="topMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QPushButton" name="addFileButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>351</width>
<width>331</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1" >
<item>
<widget class="QPushButton" name="sendButton">
<property name="text">
<string>Send</string>
@ -482,6 +503,8 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
@ -524,7 +547,8 @@ p, li { white-space: pre-wrap; }
</action>
<action name="actionAvatar">
<property name="icon">
<iconset resource="../images.qrc" >:/images/add_image24.png</iconset>
<iconset resource="../images.qrc">
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property>
<property name="text">
<string>Avatar</string>

View File

@ -482,6 +482,7 @@ void SubFileItem::updateItem()
}
uint32_t repeat = 0;
switch (mMode)
{
case SFI_STATE_ERROR:
@ -505,6 +506,7 @@ void SubFileItem::updateItem()
case SFI_STATE_LOCAL:
repeat = 0;
emit fileFinished(this);
break;
case SFI_STATE_UPLOAD:
@ -644,4 +646,6 @@ void SubFileItem::save()
}
}
uint32_t SubFileItem::getState() {
return mMode;
}

View File

@ -63,6 +63,7 @@ public:
bool done();
bool ready();
uint32_t getState();
public slots:
void download();
@ -93,6 +94,10 @@ private:
/* for display purposes */
float amountDone;
signals:
void fileFinished(SubFileItem * subFileItem) const ;
};