From cfc17398dd85519d67144f26852620b7b1a3c368 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 6 Aug 2010 12:30:06 +0000 Subject: [PATCH] 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 --- .../src/gui/chat/PopupChatDialog.cpp | 55 +++++++-- retroshare-gui/src/gui/chat/PopupChatDialog.h | 3 +- .../src/gui/chat/PopupChatDialog.ui | 105 +++++++++++++----- .../src/gui/feeds/AttachFileItem.cpp | 2 + retroshare-gui/src/gui/feeds/AttachFileItem.h | 3 + 5 files changed, 129 insertions(+), 39 deletions(-) diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index f1f0c50a5..10439cf7a 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -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"<getPeerDetails(id, detail)) { return; } - + if (detail.isOnlyGPGdetail) { //let's get the ssl child details, and open all the chat boxes std::list sslIds; @@ -453,9 +455,9 @@ std::cout << "PopupChatDialog:addChatMsg message : " << message.toStdString() << message.replace(code, ""); } } - 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+="FilePath().c_str(); + message+="\" width=\"100\" height=\"100\">"; + message+="
"; + } - 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); } } } diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.h b/retroshare-gui/src/gui/chat/PopupChatDialog.h index 6093ecef2..9797649a1 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.h @@ -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; diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.ui b/retroshare-gui/src/gui/chat/PopupChatDialog.ui index 513ebcdc7..0974e31c6 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.ui +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.ui @@ -47,6 +47,13 @@ 0 + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style="-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;"></p></body></html> + true @@ -337,7 +344,7 @@ p, li { white-space: pre-wrap; } - C:/Dokumente und Einstellungen/Linux/.designer/backupC:/Dokumente und Einstellungen/Linux/.designer/backup + ../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup false @@ -366,7 +373,7 @@ p, li { white-space: pre-wrap; } - C:/Dokumente und Einstellungen/Linux/.designer/backupC:/Dokumente und Einstellungen/Linux/.designer/backup + ../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup false @@ -395,7 +402,7 @@ p, li { white-space: pre-wrap; } - C:/Dokumente und Einstellungen/Linux/.designer/backupC:/Dokumente und Einstellungen/Linux/.designer/backup + ../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup false @@ -424,7 +431,7 @@ p, li { white-space: pre-wrap; } - C:/Dokumente und Einstellungen/Linux/.designer/backupC:/Dokumente und Einstellungen/Linux/.designer/backup + ../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup false @@ -453,7 +460,7 @@ p, li { white-space: pre-wrap; } - + @@ -500,6 +507,70 @@ border: 1px solid #CCCCCC; + + + + + 28 + 28 + + + + + 28 + 28 + + + + Attach a Picture + + + + + + + :/images/add_image24.png:/images/add_image24.png + + + + 24 + 24 + + + + true + + + + + + + + 28 + 28 + + + + Add a File for your Friend + + + + + + + :/images/add-share24.png:/images/add-share24.png + + + + 24 + 24 + + + + true + + + @@ -524,26 +595,6 @@ border: 1px solid #CCCCCC; 2 - - - - Add a File for your Friend - - - - - - - :/images/add-share24.png:/images/add-share24.png - - - - 24 - 24 - - - - @@ -567,7 +618,7 @@ border: 1px solid #CCCCCC; - + @@ -613,7 +664,7 @@ border: 1px solid #CCCCCC; - :/images/add_image24.png:/images/add_image24.png + :/images/no_avatar_70.png:/images/no_avatar_70.png Avatar diff --git a/retroshare-gui/src/gui/feeds/AttachFileItem.cpp b/retroshare-gui/src/gui/feeds/AttachFileItem.cpp index 7a8ea01b7..3073fd956 100644 --- a/retroshare-gui/src/gui/feeds/AttachFileItem.cpp +++ b/retroshare-gui/src/gui/feeds/AttachFileItem.cpp @@ -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))) diff --git a/retroshare-gui/src/gui/feeds/AttachFileItem.h b/retroshare-gui/src/gui/feeds/AttachFileItem.h index 32c69e65b..929b846a5 100644 --- a/retroshare-gui/src/gui/feeds/AttachFileItem.h +++ b/retroshare-gui/src/gui/feeds/AttachFileItem.h @@ -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;