tsuibin
23rd February 2016, 07:45
I was created a app ui, a file or program, represented by an icon,
I want draging a icon to github, and then the file upload to github
my drag code like this
QMimeData* mimeData = new QMimeData;
QList<QUrl> urls;
foreach (DesktopItemPointer pCheckedItem, m_checkedDesktopItems) {
urls.append(pCheckedItem->getRawUrl());
}
mimeData->setUrls(urls);
if (m_checkedDesktopItems.length() > 0){
QPixmap dragPixmap = getCheckedPixmap();
QDrag* pDrag = new QDrag(this);
pDrag->setMimeData(mimeData);
pDrag->setPixmap(dragPixmap);
QRect borderRect = getCheckedBorderRect();
pDrag->setHotSpot(QPoint(-borderRect.x() + QCursor::pos().x(), -borderRect.y() + QCursor::pos().y() ));
Qt::DropAction action = pDrag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction);
code on github: https://github.com/linuxdeepin/dde-desktop/blob/master/views/desktopframe.cpp#L514
but the file can't upload, I suspect that the problem is with mimedata ...
github support drag file to upload
"File uploading is now available
You can now drag and drop files into your repositories. "
learn more https://help.github.com/articles/adding-a-file-to-a-repository/
I want draging a icon to github, and then the file upload to github
my drag code like this
QMimeData* mimeData = new QMimeData;
QList<QUrl> urls;
foreach (DesktopItemPointer pCheckedItem, m_checkedDesktopItems) {
urls.append(pCheckedItem->getRawUrl());
}
mimeData->setUrls(urls);
if (m_checkedDesktopItems.length() > 0){
QPixmap dragPixmap = getCheckedPixmap();
QDrag* pDrag = new QDrag(this);
pDrag->setMimeData(mimeData);
pDrag->setPixmap(dragPixmap);
QRect borderRect = getCheckedBorderRect();
pDrag->setHotSpot(QPoint(-borderRect.x() + QCursor::pos().x(), -borderRect.y() + QCursor::pos().y() ));
Qt::DropAction action = pDrag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction);
code on github: https://github.com/linuxdeepin/dde-desktop/blob/master/views/desktopframe.cpp#L514
but the file can't upload, I suspect that the problem is with mimedata ...
github support drag file to upload
"File uploading is now available
You can now drag and drop files into your repositories. "
learn more https://help.github.com/articles/adding-a-file-to-a-repository/