Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:rhabacker:branches:windows:mingw
kmymoney4
add-print-preview-for-charts.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File add-print-preview-for-charts.patch of Package kmymoney4
From 0dd809ab050c558a158a537ee568e4b8c689fcb8 Mon Sep 17 00:00:00 2001 From: Ralf Habacker <ralf.habacker@freenet.de> Date: Sun, 6 Oct 2019 11:33:48 +0200 Subject: Add print preview for charts BUG:406338 FIXED-IN:4.8.5 --- kmymoney/kmymoney.cpp | 7 +++++++ kmymoney/kmymoney.h | 5 +++++ kmymoney/kmymoneyui.rc | 1 + kmymoney/views/khomeview.cpp | 29 +++++++++++++++++++++++++++-- kmymoney/views/khomeview.h | 10 ++++++++++ kmymoney/views/kmymoneyview.cpp | 8 ++++++++ kmymoney/views/kmymoneyview.h | 5 +++++ kmymoney/views/kreportsview.cpp | 15 +++++++++++++++ kmymoney/views/kreportsview.h | 2 ++ 9 files changed, 80 insertions(+), 2 deletions(-) diff --git a/kmymoney/kmymoney.cpp b/kmymoney/kmymoney.cpp index 93f95b6..1a7543c 100644 --- a/kmymoney/kmymoney.cpp +++ b/kmymoney/kmymoney.cpp @@ -581,6 +581,7 @@ void KMyMoneyApp::initActions() actionCollection()->addAction(KStandardAction::Close, this, SLOT(slotFileClose())); actionCollection()->addAction(KStandardAction::Quit, this, SLOT(slotFileQuit())); actionCollection()->addAction(KStandardAction::Print, this, SLOT(slotPrintView())); + actionCollection()->addAction(KStandardAction::PrintPreview, this, SLOT(slotPrintPreviewView())); KAction *open_database = actionCollection()->addAction("open_database"); open_database->setText(i18n("Open database...")); @@ -6364,6 +6365,11 @@ void KMyMoneyApp::slotPrintView() d->m_myMoneyView->slotPrintView(); } +void KMyMoneyApp::slotPrintPreviewView() +{ + d->m_myMoneyView->slotPrintPreviewView(); +} + void KMyMoneyApp::updateCaption(bool skipActions) { QString caption; @@ -6412,6 +6418,7 @@ void KMyMoneyApp::slotUpdateActions() action("view_personal_data")->setEnabled(fileOpen); action("file_backup")->setEnabled(fileOpen && !d->m_myMoneyView->isDatabase()); action("file_print")->setEnabled(fileOpen && d->m_myMoneyView->canPrint()); + action("file_print_preview")->setEnabled(fileOpen && d->m_myMoneyView->canPrint()); #ifdef KMM_DEBUG action("view_file_info")->setEnabled(fileOpen); action("file_dump")->setEnabled(fileOpen); diff --git a/kmymoney/kmymoney.h b/kmymoney/kmymoney.h index b723c3a..d1dc3cc 100644 --- a/kmymoney/kmymoney.h +++ b/kmymoney/kmymoney.h @@ -277,6 +277,11 @@ protected slots: void slotPrintView(); /** + * Calls the print preview logic for the current view + */ + void slotPrintPreviewView(); + + /** * Create a new investment */ void slotInvestmentNew(); diff --git a/kmymoney/kmymoneyui.rc b/kmymoney/kmymoneyui.rc index 4573089..963e444 100644 --- a/kmymoney/kmymoneyui.rc +++ b/kmymoney/kmymoneyui.rc @@ -269,6 +269,7 @@ <Action name="file_open" /> <Action name="file_save" /> <Action name="file_print" /> + <Action name="file_print_preview" /> <Separator lineSeparator="true"/> <Action name="institution_new" /> <Action name="account_new" /> diff --git a/kmymoney/views/khomeview.cpp b/kmymoney/views/khomeview.cpp index 399150c..a93c3be 100644 --- a/kmymoney/views/khomeview.cpp +++ b/kmymoney/views/khomeview.cpp @@ -35,6 +35,9 @@ #include <QFile> #include <QTimer> #include <QBuffer> +#include <QPrinter> +#include <QPrintDialog> +#include <QPrintPreviewDialog> // ---------------------------------------------------------------------------- // KDE Includes @@ -188,8 +191,30 @@ void KHomeView::showEvent(QShowEvent* event) void KHomeView::slotPrintView() { - if (d->m_part && d->m_part->view()) - d->m_part->view()->print(); + QPrintDialog dlg(kmymoney->printer(), this); + if (!dlg.exec()) + return; + slotPaintRequested(kmymoney->printer()); +} + +void KHomeView::slotPaintRequested(QPrinter *printer) +{ + if (!d->m_part || !d->m_part->view()) + return; +#if KDE_IS_VERSION(4, 14, 65) + d->m_part->view()->print(printer, true); +#else + d->m_part->view()->print(); +#endif +} + +void KHomeView::slotPrintPreviewView() +{ + if (!d->m_part && !d->m_part->view()) + return; + QPrintPreviewDialog dlg(kmymoney->printer(), this); + connect(&dlg, SIGNAL(paintRequested(QPrinter*)), this, SLOT(slotPaintRequested(QPrinter*))); + dlg.exec(); } void KHomeView::slotZoomView(int delta) diff --git a/kmymoney/views/khomeview.h b/kmymoney/views/khomeview.h index 6bde5ed..235b2d6 100644 --- a/kmymoney/views/khomeview.h +++ b/kmymoney/views/khomeview.h @@ -97,6 +97,16 @@ public slots: */ void slotPrintView(); + /** + * Opens the print preview for the current view + */ + void slotPrintPreviewView(); + + /** + * Generates a print for a given printer + */ + void slotPaintRequested(QPrinter *printer); + void slotZoomView(int); signals: diff --git a/kmymoney/views/kmymoneyview.cpp b/kmymoney/views/kmymoneyview.cpp index 4c0ec97..93033c0 100644 --- a/kmymoney/views/kmymoneyview.cpp +++ b/kmymoney/views/kmymoneyview.cpp @@ -2295,6 +2295,14 @@ void KMyMoneyView::slotPrintView() m_homeView->slotPrintView(); } +void KMyMoneyView::slotPrintPreviewView() +{ + if (m_reportsViewFrame == currentPage()) + m_reportsView->slotPrintPreviewView(); + else if (m_homeViewFrame == currentPage()) + m_homeView->slotPrintPreviewView(); +} + KMyMoneyViewBase* KMyMoneyView::addBasePage(const QString& title, const QString& icon) { KMyMoneyViewBase* viewBase = new KMyMoneyViewBase(this, title, title); diff --git a/kmymoney/views/kmymoneyview.h b/kmymoney/views/kmymoneyview.h index c4a769c..fa4f695 100644 --- a/kmymoney/views/kmymoneyview.h +++ b/kmymoney/views/kmymoneyview.h @@ -539,6 +539,11 @@ public slots: void slotPrintView(); /** + * This slot opens the print preview for the current view. + */ + void slotPrintPreviewView(); + + /** * This slot switches the view to present the home page */ void slotShowHomePage() { diff --git a/kmymoney/views/kreportsview.cpp b/kmymoney/views/kreportsview.cpp index 3b1bf65..c1ba6dc 100644 --- a/kmymoney/views/kreportsview.cpp +++ b/kmymoney/views/kreportsview.cpp @@ -34,6 +34,7 @@ #include <QVariant> #include <QCheckBox> #include <QPainter> +#include <QPrintPreviewDialog> #include <QPrintDialog> #include <QPrinter> @@ -161,6 +162,13 @@ void KReportsView::KReportTab::print() d->slotPaintRequested(kmymoney->printer()); } +void KReportsView::KReportTab::printPreview() +{ + QPrintPreviewDialog dlg(kmymoney->printer(), this); + connect(&dlg, SIGNAL(paintRequested(QPrinter*)), d, SLOT(slotPaintRequested(QPrinter*))); + dlg.exec(); +} + void KReportsView::KReportTab::copyToClipboard() { QMimeData* pMimeData = new QMimeData(); @@ -710,6 +718,13 @@ void KReportsView::slotPrintView() tab->print(); } +void KReportsView::slotPrintPreviewView() +{ + KReportTab* tab = dynamic_cast<KReportTab*>(m_reportTabWidget->currentWidget()); + if (tab) + tab->printPreview(); +} + void KReportsView::slotCopyView() { KReportTab* tab = dynamic_cast<KReportTab*>(m_reportTabWidget->currentWidget()); diff --git a/kmymoney/views/kreportsview.h b/kmymoney/views/kreportsview.h index b440be4..c0d9dd2 100644 --- a/kmymoney/views/kreportsview.h +++ b/kmymoney/views/kreportsview.h @@ -109,6 +109,7 @@ public: return m_report; } void print(); + void printPreview(); void toggleChart(); void copyToClipboard(); void saveAs(const QString& filename, bool includeCSS = false); @@ -216,6 +217,7 @@ public slots: void slotLoadView(); void slotPrintView(); + void slotPrintPreviewView(); void slotCopyView(); void slotSaveView(); void slotConfigure(); -- cgit v1.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor