| 1764 | } |
| 1765 | |
| 1766 | void MainWindowViewer::dropEvent(QDropEvent *event) |
| 1767 | { |
| 1768 | QList<QUrl> urlList; |
| 1769 | QString fName; |
| 1770 | QFileInfo info; |
| 1771 | |
| 1772 | if (event->mimeData()->hasUrls()) { |
| 1773 | urlList = event->mimeData()->urls(); |
| 1774 | |
| 1775 | if (urlList.size() > 0) { |
| 1776 | fName = urlList[0].toLocalFile(); // convert first QUrl to local path |
| 1777 | info.setFile(fName); // information about file |
| 1778 | if (info.isFile()) { |
| 1779 | QStringList imageSuffixs = Comic::getSupportedImageLiteralFormats(); |
| 1780 | if (imageSuffixs.contains(info.suffix())) // image dropped |
| 1781 | openFolderFromPath(info.absoluteDir().absolutePath(), info.fileName()); |
| 1782 | else |
| 1783 | openComicFromPath(fName); // if is file, setText |
| 1784 | } else if (info.isDir()) |
| 1785 | openFolderFromPath(fName); |
| 1786 | |
| 1787 | isClient = false; |
| 1788 | } |
| 1789 | } |
| 1790 | |
| 1791 | event->acceptProposedAction(); |
| 1792 | } |
| 1793 | void MainWindowViewer::dragEnterEvent(QDragEnterEvent *event) |
| 1794 | { |
| 1795 | // accept just text/uri-list mime format |