mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 07:59:35 -05:00
add the drag'n drop file to popup chat, still a bug when adding a directory
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1216 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3698fc5a2c
commit
63be32ba4d
@ -116,6 +116,9 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||
ui.textboldButton->setCheckable(true);
|
||||
ui.textunderlineButton->setCheckable(true);
|
||||
ui.textitalicButton->setCheckable(true);
|
||||
|
||||
setAcceptDrops(true);
|
||||
ui.chattextEdit->setAcceptDrops(false);
|
||||
|
||||
/*Disabled style Button when will switch chat style RetroShare will crash need to be fix */
|
||||
//ui.styleButton->setEnabled(false);
|
||||
@ -707,6 +710,11 @@ void PopupChatDialog::addExtraFile()
|
||||
std::string filePath = qfile.toStdString();
|
||||
if (filePath != "")
|
||||
{
|
||||
PopupChatDialog::addAttachment(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
void PopupChatDialog::addAttachment(std::string filePath) {
|
||||
/* add a SubFileItem to the attachment section */
|
||||
std::cerr << "PopupChatDialog::addExtraFile() hashing file.";
|
||||
std::cerr << std::endl;
|
||||
@ -723,8 +731,6 @@ void PopupChatDialog::addExtraFile()
|
||||
} else {
|
||||
QObject::connect(file,SIGNAL(fileFinished(SubFileItem *)), SLOT(fileHashingFinished(SubFileItem *))) ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void PopupChatDialog::fileHashingFinished(SubFileItem* file) {
|
||||
@ -819,3 +825,77 @@ void PopupChatDialog::anchorClicked (const QUrl& link ) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PopupChatDialog::dropEvent(QDropEvent *event)
|
||||
{
|
||||
if (!(Qt::CopyAction & event->possibleActions()))
|
||||
{
|
||||
std::cerr << "PopupChatDialog::dropEvent() Rejecting uncopyable DropAction";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* can't do it */
|
||||
return;
|
||||
}
|
||||
|
||||
std::cerr << "PopupChatDialog::dropEvent() Formats";
|
||||
std::cerr << std::endl;
|
||||
QStringList formats = event->mimeData()->formats();
|
||||
QStringList::iterator it;
|
||||
for(it = formats.begin(); it != formats.end(); it++)
|
||||
{
|
||||
std::cerr << "Format: " << (*it).toStdString();
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
if (event->mimeData()->hasUrls())
|
||||
{
|
||||
std::cerr << "GeneralMsgDialog::dropEvent() Urls:";
|
||||
std::cerr << std::endl;
|
||||
|
||||
QList<QUrl> urls = event->mimeData()->urls();
|
||||
QList<QUrl>::iterator uit;
|
||||
for(uit = urls.begin(); uit != urls.end(); uit++)
|
||||
{
|
||||
std::string localpath = uit->toLocalFile().toStdString();
|
||||
std::cerr << "Whole URL: " << uit->toString().toStdString();
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "or As Local File: " << localpath;
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (localpath.size() > 0)
|
||||
{
|
||||
|
||||
PopupChatDialog::addAttachment(localpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event->setDropAction(Qt::CopyAction);
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void PopupChatDialog::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
/* print out mimeType */
|
||||
std::cerr << "PopupChatDialog::dragEnterEvent() Formats";
|
||||
std::cerr << std::endl;
|
||||
QStringList formats = event->mimeData()->formats();
|
||||
QStringList::iterator it;
|
||||
for(it = formats.begin(); it != formats.end(); it++)
|
||||
{
|
||||
std::cerr << "Format: " << (*it).toStdString();
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
if (event->mimeData()->hasUrls())
|
||||
{
|
||||
std::cerr << "PopupChatDialog::dragEnterEvent() Accepting Urls";
|
||||
std::cerr << std::endl;
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "PopupChatDialog::dragEnterEvent() No Urls";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,10 @@ public slots:
|
||||
|
||||
protected:
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||
virtual void dropEvent(QDropEvent *event);
|
||||
|
||||
|
||||
private slots:
|
||||
void addExtraFile();
|
||||
void showAvatarFrame(bool show);
|
||||
@ -105,7 +108,8 @@ private:
|
||||
void colorChanged(const QColor &c);
|
||||
void updatePeerAvatar(const std::string&);
|
||||
void updateAvatar();
|
||||
|
||||
void addAttachment(std::string);
|
||||
|
||||
QAction *actionTextBold;
|
||||
QAction *actionTextUnderline;
|
||||
QAction *actionTextItalic;
|
||||
@ -127,6 +131,7 @@ private:
|
||||
/** Qt Designer generated object */
|
||||
Ui::PopupChatDialog ui;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user