diff options
Diffstat (limited to 'examples/widgets/pdfviewer/mainwindow.cpp')
-rw-r--r-- | examples/widgets/pdfviewer/mainwindow.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/examples/widgets/pdfviewer/mainwindow.cpp b/examples/widgets/pdfviewer/mainwindow.cpp index 1316dede1..e5b29edfd 100644 --- a/examples/widgets/pdfviewer/mainwindow.cpp +++ b/examples/widgets/pdfviewer/mainwindow.cpp @@ -4,6 +4,7 @@ #include <QFileDialog> #include <QMessageBox> #include <QPdfDocument> +#include "sequentialpagewidget.h" Q_LOGGING_CATEGORY(lcExample, "qt.examples.pdfviewer") @@ -11,9 +12,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , m_doc(new QPdfDocument(this)) + , m_pageWidget(new SequentialPageWidget(this)) { ui->setupUi(this); - ui->pageWidget->setDocument(m_doc); + m_pageWidget->setDocument(m_doc); + ui->scrollArea->setWidget(m_pageWidget); + connect(m_pageWidget, SIGNAL(showingPageRange(int,int)), + this, SLOT(showingPageRange(int,int)), Qt::QueuedConnection); } MainWindow::~MainWindow() @@ -29,11 +34,24 @@ void MainWindow::open(const QUrl &docLocation) qCDebug(lcExample) << docLocation << "is not a valid local file"; QMessageBox::critical(this, tr("Failed to open"), tr("%1 is not a valid local file").arg(docLocation.toString())); } + // TODO: connect to signal from document + m_pageWidget->invalidate(); + qCDebug(lcExample) << docLocation; + ui->scrollArea->ensureVisible(0, 0, 0, 0); +} + +void MainWindow::showingPageRange(int start, int end) +{ + ui->statusBar->clearMessage(); + if (start == end) + ui->statusBar->showMessage(tr("showing page %1").arg(start)); + else + ui->statusBar->showMessage(tr("showing pages %1 to %2").arg(start).arg(end)); } void MainWindow::on_actionOpen_triggered() { - QUrl toOpen = QFileDialog::getOpenFileUrl(this); + QUrl toOpen = QFileDialog::getOpenFileUrl(this, tr("Choose a PDF"), QUrl(), "Portable Documents (*.pdf)"); if (toOpen.isValid()) open(toOpen); } |