mirror of https://github.com/JakubMelka/PDF4QT.git
Drop file opens it, command line arguments
This commit is contained in:
parent
08d069ce32
commit
8d9b9cb493
|
@ -43,5 +43,11 @@ int main(int argc, char *argv[])
|
||||||
pdfviewer::PDFViewerMainWindow mainWindow;
|
pdfviewer::PDFViewerMainWindow mainWindow;
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
|
|
||||||
|
QStringList arguments = application.arguments();
|
||||||
|
if (arguments.size() > 1)
|
||||||
|
{
|
||||||
|
mainWindow.openDocument(arguments[1]);
|
||||||
|
}
|
||||||
|
|
||||||
return application.exec();
|
return application.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,8 @@ PDFViewerMainWindow::PDFViewerMainWindow(QWidget* parent) :
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
setAcceptDrops(true);
|
||||||
|
|
||||||
// Initialize toolbar icon size
|
// Initialize toolbar icon size
|
||||||
QSize iconSize = pdf::PDFWidgetUtils::scaleDPI(this, QSize(24, 24));
|
QSize iconSize = pdf::PDFWidgetUtils::scaleDPI(this, QSize(24, 24));
|
||||||
ui->mainToolBar->setIconSize(iconSize);
|
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
|
} // namespace pdfviewer
|
||||||
|
|
|
@ -74,9 +74,17 @@ public:
|
||||||
virtual void closeEvent(QCloseEvent* event) override;
|
virtual void closeEvent(QCloseEvent* event) override;
|
||||||
virtual void showEvent(QShowEvent* event) override;
|
virtual void showEvent(QShowEvent* event) override;
|
||||||
|
|
||||||
|
void openDocument(const QString& fileName);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void queryPasswordRequest(QString* password, bool* ok);
|
void queryPasswordRequest(QString* password, bool* ok);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void dragEnterEvent(QDragEnterEvent* event) override;
|
||||||
|
virtual void dragMoveEvent(QDragMoveEvent* event) override;
|
||||||
|
virtual void dragLeaveEvent(QDragLeaveEvent* event) override;
|
||||||
|
virtual void dropEvent(QDropEvent* event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onQueryPasswordRequest(QString* password, bool* ok);
|
void onQueryPasswordRequest(QString* password, bool* ok);
|
||||||
|
|
||||||
|
@ -137,7 +145,6 @@ private:
|
||||||
void onViewerSettingsChanged();
|
void onViewerSettingsChanged();
|
||||||
void onRenderingOptionTriggered(bool checked);
|
void onRenderingOptionTriggered(bool checked);
|
||||||
|
|
||||||
void openDocument(const QString& fileName);
|
|
||||||
void setDocument(pdf::PDFModifiedDocument document);
|
void setDocument(pdf::PDFModifiedDocument document);
|
||||||
void closeDocument();
|
void closeDocument();
|
||||||
void saveDocument(const QString& fileName);
|
void saveDocument(const QString& fileName);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
==========================================================================
|
==========================================================================
|
||||||
PDFforQt library / PDF viewer
|
PDFforQt library / PDF viewer
|
||||||
(c) Jakub Melka 2018-2019
|
(c) Jakub Melka 2018-2020
|
||||||
==========================================================================
|
==========================================================================
|
||||||
|
|
||||||
This software is consisting of PDF rendering library, and viewer,
|
This software is consisting of PDF rendering library, and viewer,
|
||||||
|
|
Loading…
Reference in New Issue