mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2024-12-28 17:20:02 +01:00
46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
#include "pdfviewermainwindow.h"
|
|
#include "ui_pdfviewermainwindow.h"
|
|
|
|
#include "pdfdocumentreader.h"
|
|
|
|
#include <QFileDialog>
|
|
#include <QMessageBox>
|
|
|
|
namespace pdfviewer
|
|
{
|
|
|
|
PDFViewerMainWindow::PDFViewerMainWindow(QWidget *parent) :
|
|
QMainWindow(parent),
|
|
ui(new Ui::PDFViewerMainWindow)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
connect(ui->actionOpen, &QAction::triggered, this, &PDFViewerMainWindow::onActionOpenTriggered);
|
|
}
|
|
|
|
PDFViewerMainWindow::~PDFViewerMainWindow()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void PDFViewerMainWindow::onActionOpenTriggered()
|
|
{
|
|
QString fileName = QFileDialog::getOpenFileName(this, tr("Select PDF document"), "K:/Programming/PDF/testpdf", tr("PDF document (*.pdf)"));
|
|
if (!fileName.isEmpty())
|
|
{
|
|
pdf::PDFDocumentReader reader;
|
|
pdf::PDFDocument document = reader.readFromFile(fileName);
|
|
|
|
if (reader.isSuccessfull())
|
|
{
|
|
QMessageBox::information(this, tr("PDF Reader"), tr("Document '%1' was successfully loaded!").arg(fileName));
|
|
}
|
|
else
|
|
{
|
|
QMessageBox::information(this, tr("PDF Reader"), tr("Document read error: %1").arg(fileName));
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace pdfviewer
|