Resolved some issues related to the drag and drop from an external browser on Mac

preferencesAboutTextFull
Didier 13 years ago
parent 408b16d123
commit 0a329e6602
  1. 13
      src/core/UBApplication.cpp
  2. 31
      src/gui/UBLibPathViewer.cpp
  3. 1
      src/gui/UBLibraryWidget.cpp

@ -643,15 +643,22 @@ QString UBApplication::globalStyleSheet()
QString UBApplication::urlFromHtml(QString html)
{
qDebug() << "HTML: " << html.remove(QRegExp("[\\0]"));
QString url;
QDomDocument domDoc;
domDoc.setContent(html.remove(QRegExp("[\\0]")));
QDomElement rootElem = domDoc.documentElement();
url = rootElem.attribute("src");
// QUICKFIX: Here we have to check rootElem. Sometimes it can be a <meta> tag
// In such a case we will not be able to retrieve the src value
if(rootElem.tagName().toLower().contains("meta")){
qDebug() << rootElem.firstChildElement().tagName();
// In that case we get the next element
url = rootElem.firstChildElement().attribute("src");
}else{
url = rootElem.attribute("src");
}
qDebug() << "The URL is: " << url;
return url;
}

@ -478,9 +478,8 @@ void UBPathScene::dropEvent(QGraphicsSceneDragDropEvent *event)
}
bAccept = true;
}
else if(NULL != event->mimeData() && event->mimeData()->hasUrls()){
QList<QUrl> urls = event->mimeData()->urls();
}else if(NULL != pMimeData && pMimeData->hasUrls()){
QList<QUrl> urls = pMimeData->urls();
foreach(QUrl eachUrl, urls){
QString sUrl = eachUrl.toString();
if(!sUrl.startsWith("uniboardTool://") && !sUrl.startsWith("file://") && !sUrl.startsWith("/")){
@ -503,11 +502,10 @@ void UBPathScene::dropEvent(QGraphicsSceneDragDropEvent *event)
}
}
bAccept = true;
}
else if(NULL != event->mimeData() && event->mimeData()->hasText()){
}else if(NULL != pMimeData && pMimeData->hasText()){
// The user can only drop an Url in this location so if the text is not an Url,
// we discard it.
QString qsTxt = event->mimeData()->text().remove(QRegExp("[\\0]"));
QString qsTxt = pMimeData->text().remove(QRegExp("[\\0]"));
if(qsTxt.startsWith("http")){
// Show the download palette if it is hidden
UBApplication::boardController->paletteManager()->startDownloads();
@ -524,6 +522,27 @@ void UBPathScene::dropEvent(QGraphicsSceneDragDropEvent *event)
UBDownloadManager::downloadManager()->addFileToDownload(desc);
bAccept = true;
}
}else if(NULL != pMimeData && pMimeData->hasHtml()){
QString html = pMimeData->html();
QString url = UBApplication::urlFromHtml(html);
if("" != url)
{
bAccept = true;
// Show the download palette if it is hidden
UBApplication::boardController->paletteManager()->startDownloads();
// Add the dropped url to the download list
sDownloadFileDesc desc;
desc.currentSize = 0;
desc.id = 0;
desc.isBackground = false;
desc.modal = false;
desc.name = QFileInfo(url).fileName();
desc.totalSize = 0;
desc.url = url;
UBDownloadManager::downloadManager()->addFileToDownload(desc);
}
}
if(bAccept){
event->accept();

@ -385,6 +385,7 @@ void UBLibraryWidget::dropEvent(QDropEvent *event)
else if (pMimeData->hasHtml()){
qDebug() << "hasHtml";
QString html = pMimeData->html();
qDebug() << html;
QString url = UBApplication::urlFromHtml(html);
if("" != url)
{

Loading…
Cancel
Save