mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Drop file opens it, command line arguments
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user