mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-14 00:49:41 -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
@ -117,6 +117,9 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
|||||||
ui.textunderlineButton->setCheckable(true);
|
ui.textunderlineButton->setCheckable(true);
|
||||||
ui.textitalicButton->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 */
|
/*Disabled style Button when will switch chat style RetroShare will crash need to be fix */
|
||||||
//ui.styleButton->setEnabled(false);
|
//ui.styleButton->setEnabled(false);
|
||||||
|
|
||||||
@ -707,6 +710,11 @@ void PopupChatDialog::addExtraFile()
|
|||||||
std::string filePath = qfile.toStdString();
|
std::string filePath = qfile.toStdString();
|
||||||
if (filePath != "")
|
if (filePath != "")
|
||||||
{
|
{
|
||||||
|
PopupChatDialog::addAttachment(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupChatDialog::addAttachment(std::string filePath) {
|
||||||
/* add a SubFileItem to the attachment section */
|
/* add a SubFileItem to the attachment section */
|
||||||
std::cerr << "PopupChatDialog::addExtraFile() hashing file.";
|
std::cerr << "PopupChatDialog::addExtraFile() hashing file.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -723,8 +731,6 @@ void PopupChatDialog::addExtraFile()
|
|||||||
} else {
|
} else {
|
||||||
QObject::connect(file,SIGNAL(fileFinished(SubFileItem *)), SLOT(fileHashingFinished(SubFileItem *))) ;
|
QObject::connect(file,SIGNAL(fileFinished(SubFileItem *)), SLOT(fileHashingFinished(SubFileItem *))) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatDialog::fileHashingFinished(SubFileItem* file) {
|
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,6 +85,9 @@ public slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent (QCloseEvent * event);
|
void closeEvent (QCloseEvent * event);
|
||||||
|
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||||
|
virtual void dropEvent(QDropEvent *event);
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addExtraFile();
|
void addExtraFile();
|
||||||
@ -105,6 +108,7 @@ private:
|
|||||||
void colorChanged(const QColor &c);
|
void colorChanged(const QColor &c);
|
||||||
void updatePeerAvatar(const std::string&);
|
void updatePeerAvatar(const std::string&);
|
||||||
void updateAvatar();
|
void updateAvatar();
|
||||||
|
void addAttachment(std::string);
|
||||||
|
|
||||||
QAction *actionTextBold;
|
QAction *actionTextBold;
|
||||||
QAction *actionTextUnderline;
|
QAction *actionTextUnderline;
|
||||||
@ -127,6 +131,7 @@ private:
|
|||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::PopupChatDialog ui;
|
Ui::PopupChatDialog ui;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user