Commit 7fbe18e6 authored by Laurent Montel's avatar Laurent Montel 😁

Add print support

parent 202ba086
......@@ -32,7 +32,7 @@ set(PIMCOMMON_LIB_VERSION "5.2.40")
set(AKONADI_VERSION "5.2.40")
find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED)
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Xml)
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Xml PrintSupport)
find_package(KF5I18n ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5IconThemes ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5PimCommon ${PIMCOMMON_LIB_VERSION} CONFIG REQUIRED)
......
......@@ -219,6 +219,7 @@ target_link_libraries(KF5KSieveUi
KF5::PimTextEdit
KF5::I18n
KF5::SonnetUi
Qt5::PrintSupport
)
set_target_properties(KF5KSieveUi PROPERTIES
......
......@@ -2,7 +2,7 @@ set( libksieveui_sieveeditormenubartest_source sieveeditormenubartest.cpp ../sie
add_executable( sieveeditormenubartest ${libksieveui_sieveeditormenubartest_source})
add_test(sieveeditormenubartest sieveeditormenubartest)
ecm_mark_as_test(sieveeditormenubartest)
target_link_libraries( sieveeditormenubartest Qt5::Test Qt5::Gui Qt5::Widgets KF5::ConfigWidgets KF5::I18n KF5::PimTextEdit)
target_link_libraries( sieveeditormenubartest Qt5::Test Qt5::Gui Qt5::Widgets KF5::ConfigWidgets KF5::I18n KF5::PimTextEdit Qt5::PrintSupport)
......@@ -10,11 +10,11 @@ set( libksieveui_sievetextedittest_source sievetextedittest.cpp )
add_executable( sievetextedittest ${libksieveui_sievetextedittest_source})
add_test(sievetextedittest sievetextedittest)
ecm_mark_as_test(sievetextedittest)
target_link_libraries( sievetextedittest Qt5::Test Qt5::Gui KF5::KSieveUi KF5::PimCommon KF5::PimTextEdit)
target_link_libraries( sievetextedittest Qt5::Test Qt5::Gui KF5::KSieveUi KF5::PimCommon KF5::PimTextEdit Qt5::PrintSupport)
set( libksieveui_sievetexteditwidgettest_source sievetexteditwidgettest.cpp )
add_executable( sievetexteditwidgettest ${libksieveui_sievetexteditwidgettest_source})
add_test(sievetexteditwidgettest sievetexteditwidgettest)
ecm_mark_as_test(sievetexteditwidgettest)
target_link_libraries( sievetexteditwidgettest Qt5::Test Qt5::Gui KF5::KSieveUi KF5::PimCommon KF5::PimTextEdit)
target_link_libraries( sievetexteditwidgettest Qt5::Test Qt5::Gui KF5::KSieveUi KF5::PimCommon KF5::PimTextEdit Qt5::PrintSupport)
......@@ -51,6 +51,9 @@
#include <QPushButton>
#include <QVBoxLayout>
#include <QDebug>
#include <QPrinter>
#include <QPrintDialog>
#include <PimCommon/KPimPrintPreviewDialog>
#include <errno.h>
......@@ -321,12 +324,22 @@ bool SieveEditorTextModeWidget::isWordWrap() const
void SieveEditorTextModeWidget::print()
{
//TODO
QPrinter printer;
QScopedPointer<QPrintDialog> dlg(new QPrintDialog(&printer));
if (dlg && dlg->exec() == QDialog::Accepted) {
mTextEdit->print(&printer);
}
}
void SieveEditorTextModeWidget::printPreview()
{
//TODO
PimCommon::KPimPrintPreviewDialog previewdlg(this);
connect(&previewdlg, &QPrintPreviewDialog::paintRequested, this, [this](QPrinter * printer) {
mTextEdit->print(printer);
});
previewdlg.exec();
}
void SieveEditorTextModeWidget::wordWrap(bool state)
......
......@@ -9,5 +9,6 @@ target_link_libraries(editorsieve_gui
KF5::KSieveUi
KF5::PimCommon
KF5::I18n
Qt5::PrintSupport
)
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