added Picture Preview Thumbnail patch for Privat Chat from xiaohan and fixed little design improvements

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3344 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-08-06 12:30:06 +00:00
parent 09d5014df5
commit cfc17398dd
5 changed files with 129 additions and 39 deletions

View File

@ -1,4 +1,5 @@
/****************************************************************
*
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
@ -96,6 +97,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
connect(ui.textboldButton, SIGNAL(clicked()), this, SLOT(setFont()));
connect(ui.textunderlineButton, SIGNAL(clicked()), this, SLOT(setFont()));
connect(ui.textitalicButton, SIGNAL(clicked()), this, SLOT(setFont()));
connect(ui.attachPictureButton, SIGNAL(clicked()), this, SLOT(addExtraPicture()));
connect(ui.fontButton, SIGNAL(clicked()), this, SLOT(getFont()));
connect(ui.colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
connect(ui.emoteiconButton, SIGNAL(clicked()), this, SLOT(smileyWidget()));
@ -253,14 +255,14 @@ void PopupChatDialog::chatFriend(std::string id)
if (id.empty()){
return;
}
std::cerr<<" popup dialog chat friend 1"<<std::endl;
bool oneLocationConnected = false;
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(id, detail)) {
return;
}
if (detail.isOnlyGPGdetail) {
//let's get the ssl child details, and open all the chat boxes
std::list<std::string> sslIds;
@ -453,9 +455,9 @@ std::cout << "PopupChatDialog:addChatMsg message : " << message.toStdString() <<
message.replace(code, "<img src=\"" + i.value() + "\" />");
}
}
history /*<< nickColor << color << font << fontSize*/ << timestamp << name << message;
QString formatMsg = loadEmptyStyle()/*.replace(nickColor)
.replace(color)
.replace(font)
@ -463,6 +465,7 @@ std::cout << "PopupChatDialog:addChatMsg message : " << message.toStdString() <<
.replace("%timestamp%", timestamp)
.replace("%name%", name)
.replace("%message%", message);
if ((ui.textBrowser->verticalScrollBar()->maximum() - 30) < ui.textBrowser->verticalScrollBar()->value() ) {
ui.textBrowser->append(formatMsg + "\n");
@ -571,7 +574,10 @@ void PopupChatDialog::getFont()
void PopupChatDialog::setFont()
{
mCurrentFont.setBold(ui.textboldButton->isChecked());
// mCurrentFont.setBold(ui.textboldButton->isChecked());
bool flag;
flag=ui.textboldButton->isChecked();
mCurrentFont.setBold(flag);
mCurrentFont.setUnderline(ui.textunderlineButton->isChecked());
mCurrentFont.setItalic(ui.textitalicButton->isChecked());
@ -828,7 +834,7 @@ void PopupChatDialog::updatePeerAvatar(const std::string& peer_id)
#ifdef CHAT_DEBUG
std::cerr << "Got no image" << std::endl ;
#endif
ui.avatarlabel->setPixmap(QPixmap(":/images/no_avatar_70.png"));
ui.avatarlabel->setPixmap(QPixmap(":/images/no_avatar.png"));
return ;
}
@ -897,19 +903,34 @@ void PopupChatDialog::addExtraFile()
std::string filePath = qfile.toStdString();
if (filePath != "")
{
PopupChatDialog::addAttachment(filePath);
PopupChatDialog::addAttachment(filePath,0);
}
}
void PopupChatDialog::addAttachment(std::string filePath)
void PopupChatDialog::addExtraPicture()
{
// select a picture file
QString qfile = QFileDialog::getOpenFileName(this, "Load Picture File", QDir::homePath(), "Pictures (*.png *.xpm *.jpg)",0,
QFileDialog::DontResolveSymlinks);
std::string filePath=qfile.toStdString();
if(filePath!="")
{
PopupChatDialog::addAttachment(filePath,1); //picture
}
}
void PopupChatDialog::addAttachment(std::string filePath,int flag)
{
/* add a AttachFileItem to the attachment section */
std::cerr << "PopupChatDialog::addExtraFile() hashing file.";
std::cerr << std::endl;
/* add widget in for new destination */
AttachFileItem *file = new AttachFileItem(filePath);
AttachFileItem *file = new AttachFileItem(filePath);
//file->
if(flag==1)
file->setPicFlag(1);
ui.vboxLayout->addWidget(file, 1, 0);
@ -921,6 +942,8 @@ void PopupChatDialog::addAttachment(std::string filePath)
}
}
void PopupChatDialog::fileHashingFinished(AttachFileItem* file)
{
std::cerr << "PopupChatDialog::fileHashingFinished() started.";
@ -945,14 +968,24 @@ void PopupChatDialog::fileHashingFinished(AttachFileItem* file)
rsiface->unlockData(); /* Unlock Interface */
}
QString message;
if(file->getPicFlag()==1){
message+="<img src=\"file:///";
message+=file->FilePath().c_str();
message+="\" width=\"100\" height=\"100\">";
message+="<br>";
}
QString message = RetroShareLink(QString::fromStdString(file->FileName()),file->FileSize(),QString::fromStdString(file->FileHash())).toHtml();
message+= RetroShareLink(QString::fromStdString(file->FileName()),file->FileSize(),QString::fromStdString(file->FileHash())).toHtml();
#ifdef CHAT_DEBUG
std::cerr << "PopupChatDialog::anchorClicked message : " << message.toStdString() << std::endl;
#endif
ci.msg = message.toStdWString();
ci.msg = message.toStdWString();
ci.chatflags = RS_CHAT_PRIVATE;
addChatMsg(&ci);
@ -1026,7 +1059,7 @@ void PopupChatDialog::dropEvent(QDropEvent *event)
mb.setButtonText( QMessageBox::Ok, "OK" );
mb.exec();
} else {
PopupChatDialog::addAttachment(localpath);
PopupChatDialog::addAttachment(localpath,false);
}
}
}

View File

@ -89,6 +89,7 @@ protected:
private slots:
void addExtraFile();
void addExtraPicture();
void showAvatarFrame(bool show);
void setColor();
@ -110,7 +111,7 @@ private slots:
private:
void colorChanged(const QColor &c);
void addAttachment(std::string);
void addAttachment(std::string,int flag);
QAction *actionTextBold;
QAction *actionTextUnderline;

View File

@ -47,6 +47,13 @@
<height>0</height>
</size>
</property>
<property name="html">
<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;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
@ -337,7 +344,7 @@ p, li { white-space: pre-wrap; }
</property>
<property name="icon">
<iconset>
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
<normaloff>../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup</normaloff>../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup</iconset>
</property>
<property name="checkable">
<bool>false</bool>
@ -366,7 +373,7 @@ p, li { white-space: pre-wrap; }
</property>
<property name="icon">
<iconset>
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
<normaloff>../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup</normaloff>../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup</iconset>
</property>
<property name="checkable">
<bool>false</bool>
@ -395,7 +402,7 @@ p, li { white-space: pre-wrap; }
</property>
<property name="icon">
<iconset>
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
<normaloff>../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup</normaloff>../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup</iconset>
</property>
<property name="checkable">
<bool>false</bool>
@ -424,7 +431,7 @@ p, li { white-space: pre-wrap; }
</property>
<property name="icon">
<iconset>
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
<normaloff>../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup</normaloff>../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup</iconset>
</property>
<property name="checkable">
<bool>false</bool>
@ -453,7 +460,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="8">
<item row="0" column="10">
<widget class="QPushButton" name="pushtoolsButton">
<property name="minimumSize">
<size>
@ -500,6 +507,70 @@ border: 1px solid #CCCCCC;
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QToolButton" name="attachPictureButton">
<property name="minimumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>Attach a Picture</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QToolButton" name="addFileButton">
<property name="minimumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>Add a File for your Friend</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -524,26 +595,6 @@ border: 1px solid #CCCCCC;
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QPushButton" name="addFileButton">
<property name="toolTip">
<string>Add a File for your Friend</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
@ -567,7 +618,7 @@ border: 1px solid #CCCCCC;
</layout>
</item>
<item row="4" column="0">
<layout class="QVBoxLayout"/>
<layout class="QVBoxLayout" name="vboxLayout"/>
</item>
</layout>
</widget>
@ -613,7 +664,7 @@ border: 1px solid #CCCCCC;
<action name="actionAvatar">
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
<normaloff>:/images/no_avatar_70.png</normaloff>:/images/no_avatar_70.png</iconset>
</property>
<property name="text">
<string>Avatar</string>

View File

@ -72,6 +72,7 @@ AttachFileItem::AttachFileItem(std::string hash, std::string name, uint64_t size
mMode = flags & AFI_MASK_STATE;
mType = flags & AFI_MASK_TYPE;
mPicFlag=0;
if (mMode == AFI_STATE_EXTRA)
{
@ -99,6 +100,7 @@ AttachFileItem::AttachFileItem(std::string path)
mMode = AFI_STATE_EXTRA;
mType = AFI_TYPE_ATTACH;
mPicFlag=0;
/* ask for Files to hash/prepare it for us */
if ((!rsFiles) || (!rsFiles->ExtraFileHash(path, AFI_DEFAULT_PERIOD, 0)))

View File

@ -55,6 +55,8 @@ public:
std::string FileName() { return mFileName; }
uint64_t FileSize() { return mFileSize; }
std::string FilePath() { return mPath; }
int getPicFlag() { return mPicFlag;}
void setPicFlag(int flag) { mPicFlag=flag;}
void updateItemStatic();
@ -81,6 +83,7 @@ private:
uint64_t mFileSize;
std::string mSrcId;
uint32_t mPicFlag;
uint32_t mMode;
uint32_t mType;
uint64_t mDivisor;