Commit 6a3cede3 authored by Laurent Montel's avatar Laurent Montel 😁

Continue to implement printpreviewdialog

parent 9a35398b
......@@ -21,6 +21,9 @@ if (WEBENGINEVIEWER_PRINTPREVIEW_SUPPORT)
)
set(poppler_lib Poppler::Qt5)
endif()
if(BUILD_TESTING)
add_subdirectory(print/autotests)
endif()
endif()
set(libwebengineviewer_webengine_SRCS
......@@ -78,6 +81,7 @@ target_link_libraries(KF5WebEngineViewer
KF5::Completion
KF5::I18n
KF5::PimCommon
KF5::WidgetsAddons
${poppler_lib}
)
......
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "printpreviewdialogtest.h"
#include "../printpreviewdialog.h"
#include "../printpreviewpageviewer.h"
#include <QTest>
PrintPreviewDialogTest::PrintPreviewDialogTest(QObject *parent)
: QObject(parent)
{
}
PrintPreviewDialogTest::~PrintPreviewDialogTest()
{
}
void PrintPreviewDialogTest::shouldHaveDefaultValue()
{
WebEngineViewer::PrintPreviewDialog dlg;
WebEngineViewer::PrintPreviewPageViewer *page = dlg.findChild<WebEngineViewer::PrintPreviewPageViewer *>(QStringLiteral("printpreviewpage"));
QVERIFY(page);
}
QTEST_MAIN(PrintPreviewDialogTest)
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PRINTPREVIEWDIALOGTEST_H
#define PRINTPREVIEWDIALOGTEST_H
#include <QObject>
class PrintPreviewDialogTest : public QObject
{
Q_OBJECT
public:
explicit PrintPreviewDialogTest(QObject *parent = Q_NULLPTR);
~PrintPreviewDialogTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // PRINTPREVIEWDIALOGTEST_H
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "printpreviewpageviewertest.h"
#include "../printpreviewpageviewer.h"
#include <QLabel>
#include <QTest>
PrintPreviewPageViewerTest::PrintPreviewPageViewerTest(QObject *parent)
: QObject(parent)
{
}
PrintPreviewPageViewerTest::~PrintPreviewPageViewerTest()
{
}
void PrintPreviewPageViewerTest::shouldHaveDefaultValue()
{
WebEngineViewer::PrintPreviewPageViewer page;
QLabel *label = page.findChild<QLabel *>(QStringLiteral("page"));
QVERIFY(label);
}
QTEST_MAIN(PrintPreviewPageViewerTest)
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PRINTPREVIEWPAGEVIEWERTEST_H
#define PRINTPREVIEWPAGEVIEWERTEST_H
#include <QObject>
class PrintPreviewPageViewerTest : public QObject
{
Q_OBJECT
public:
explicit PrintPreviewPageViewerTest(QObject *parent = Q_NULLPTR);
~PrintPreviewPageViewerTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // PRINTPREVIEWPAGEVIEWERTEST_H
......@@ -17,22 +17,42 @@
#include "printpreviewdialog.h"
#include "printpreviewpageviewer.h"
#include <poppler-qt5.h>
#include <KLocalizedString>
#include <KMessageBox>
#include <QVBoxLayout>
#include <QDialogButtonBox>
using namespace WebEngineViewer;
PrintPreviewDialog::PrintPreviewDialog(QWidget *parent)
: QDialog(parent)
: QDialog(parent),
mDoc(Q_NULLPTR)
{
QVBoxLayout *layout = new QVBoxLayout;
setLayout(layout);
mPrintPreviewPage = new PrintPreviewPageViewer(this);
mPrintPreviewPage->setObjectName(QStringLiteral("printpreviewpage"));
layout->addWidget(mPrintPreviewPage);
}
PrintPreviewDialog::~PrintPreviewDialog()
{
}
void PrintPreviewDialog::loadFile(const QString &path)
{
if (path.isEmpty()) {
return;
}
mDoc = Poppler::Document::load(path);
if (!mDoc) {
KMessageBox::error(this, i18n("Unable to open file \"%1\"", path), i18n("Open file error"));
return;
}
//TODO
}
......@@ -20,6 +20,10 @@
#include <QDialog>
namespace Poppler
{
class Document;
}
namespace WebEngineViewer
{
class PrintPreviewPageViewer;
......@@ -29,8 +33,11 @@ class PrintPreviewDialog : public QDialog
public:
explicit PrintPreviewDialog(QWidget *parent = Q_NULLPTR);
~PrintPreviewDialog();
void loadFile(const QString &path);
private:
PrintPreviewPageViewer *mPrintPreviewPage;
Poppler::Document *mDoc;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment