Drop file opens it, command line arguments

This commit is contained in:
Jakub Melka
2020-11-07 12:03:43 +01:00
parent 08d069ce32
commit 8d9b9cb493
4 changed files with 56 additions and 3 deletions

View File

@ -102,6 +102,8 @@ PDFViewerMainWindow::PDFViewerMainWindow(QWidget* parent) :
{
ui->setupUi(this);
setAcceptDrops(true);
// Initialize toolbar icon size
QSize iconSize = pdf::PDFWidgetUtils::scaleDPI(this, QSize(24, 24));
ui->mainToolBar->setIconSize(iconSize);
@ -1503,4 +1505,42 @@ void PDFViewerMainWindow::saveDocument(const QString& fileName)
}
}
void PDFViewerMainWindow::dragEnterEvent(QDragEnterEvent* event)
{
if (event->mimeData()->hasUrls())
{
event->setDropAction(Qt::LinkAction);
event->accept();
}
}
void PDFViewerMainWindow::dragMoveEvent(QDragMoveEvent* event)
{
if (event->mimeData()->hasUrls())
{
event->setDropAction(Qt::LinkAction);
event->accept();
}
}
void PDFViewerMainWindow::dragLeaveEvent(QDragLeaveEvent* event)
{
}
void PDFViewerMainWindow::dropEvent(QDropEvent* event)
{
if (event->mimeData()->hasUrls())
{
QList<QUrl> urls = event->mimeData()->urls();
if (urls.size() == 1)
{
openDocument(urls.front().toLocalFile());
event->acceptProposedAction();
}
}
}
} // namespace pdfviewer