From 64fc4e5b4bc7f8c59f5c3e04638506a6a76e0773 Mon Sep 17 00:00:00 2001 From: Segey Date: Wed, 10 Apr 2019 16:23:50 +0300 Subject: [PATCH] Added hiding (saving, printing, ...) buttons in the Render Report window --- include/lrreportengine.h | 6 +++ limereport/lrpreviewreportwindow.cpp | 20 ++++++++ limereport/lrpreviewreportwindow.h | 4 ++ limereport/lrreportengine.cpp | 73 +++++++++++++++++++++++++++- limereport/lrreportengine.h | 6 +++ limereport/lrreportengine_p.h | 9 ++++ 6 files changed, 117 insertions(+), 1 deletion(-) diff --git a/include/lrreportengine.h b/include/lrreportengine.h index f935b80..b9e6e94 100644 --- a/include/lrreportengine.h +++ b/include/lrreportengine.h @@ -100,6 +100,12 @@ public: void setPreviewWindowIcon(const QIcon& icon); void setResultEditable(bool value); bool resultIsEditable(); + void setSaveToFileVisible(bool value); + bool saveToFileIsVisible(); + void setPrintToPdfVisible(bool value); + bool printToPdfIsVisible(); + void setPrintVisible(bool value); + bool printIsVisible(); bool isBusy(); void setPassPharse(QString& passPharse); Qt::LayoutDirection previewLayoutDirection(); diff --git a/limereport/lrpreviewreportwindow.cpp b/limereport/lrpreviewreportwindow.cpp index d58678e..7fe5f23 100644 --- a/limereport/lrpreviewreportwindow.cpp +++ b/limereport/lrpreviewreportwindow.cpp @@ -176,6 +176,26 @@ void PreviewReportWindow::setHideResultEditButton(bool value) ui->actionEdit_Mode->setVisible(value); } +void PreviewReportWindow::setHidePrintButton(bool value) +{ + ui->actionPrint->setVisible(value); +} + +void PreviewReportWindow::setHideSaveToFileButton(bool value) +{ + ui->actionSaveToFile->setVisible(value); +} + +void PreviewReportWindow::setHidePrintToPdfButton(bool value) +{ + ui->actionPrint_To_PDF->setVisible(value); +} + +void PreviewReportWindow::setEnablePrintMenu(bool value) +{ + ui->menuReport->setEnabled(value); +} + QSettings*PreviewReportWindow::settings() { if (m_settings){ diff --git a/limereport/lrpreviewreportwindow.h b/limereport/lrpreviewreportwindow.h index bc6da16..72ae3b7 100644 --- a/limereport/lrpreviewreportwindow.h +++ b/limereport/lrpreviewreportwindow.h @@ -67,6 +67,10 @@ public: void setStatusBarVisible(bool value); void setMenuVisible(bool value); void setHideResultEditButton(bool value); + void setHidePrintButton(bool value); + void setHideSaveToFileButton(bool value); + void setHidePrintToPdfButton(bool value); + void setEnablePrintMenu(bool value); QSettings* settings(); ScaleType previewScaleType() const; void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0); diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 7a9c52f..b9b7633 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -64,7 +64,8 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) : m_previewWindowIcon(":/report/images/logo32"), m_previewWindowTitle(tr("Preview")), m_reportRendering(false), m_resultIsEditable(true), m_passPhrase("HjccbzHjlbyfCkjy"), m_fileWatcher( new QFileSystemWatcher( this ) ), m_previewLayoutDirection(Qt::LayoutDirectionAuto), - m_previewScaleType(FitWidth), m_previewScalePercent(0) + m_previewScaleType(FitWidth), m_previewScalePercent(0), m_saveToFileVisible(true), m_printToPdfVisible(true), + m_printVisible(true) { #ifdef HAVE_STATIC_BUILD initResources(); @@ -394,6 +395,10 @@ void ReportEnginePrivate::previewReport(PreviewHints hints) } w->setHideResultEditButton(resultIsEditable()); + w->setHidePrintButton(printIsVisible()); + w->setHideSaveToFileButton(saveToFileIsVisible()); + w->setHidePrintToPdfButton(printToPdfIsVisible()); + w->setEnablePrintMenu(printIsVisible() || printToPdfIsVisible()); m_activePreview = w; @@ -786,6 +791,36 @@ void ReportEnginePrivate::setResultEditable(bool value) m_resultIsEditable = value; } +bool ReportEnginePrivate::saveToFileIsVisible() const +{ + return m_saveToFileVisible; +} + +void ReportEnginePrivate::setSaveToFileVisible(bool value) +{ + m_saveToFileVisible = value; +} + +bool ReportEnginePrivate::printToPdfIsVisible() const +{ + return m_printToPdfVisible; +} + +void ReportEnginePrivate::setPrintToPdfVisible(bool value) +{ + m_printToPdfVisible = value; +} + +bool ReportEnginePrivate::printIsVisible() const +{ + return m_printVisible; +} + +void ReportEnginePrivate::setPrintVisible(bool value) +{ + m_printVisible = value; +} + bool ReportEnginePrivate::suppressFieldAndVarError() const { return m_reportSettings.suppressAbsentFieldsAndVarsWarnings(); @@ -948,6 +983,42 @@ bool ReportEngine::resultIsEditable() return d->resultIsEditable(); } +void ReportEngine::setSaveToFileVisible(bool value) +{ + Q_D(ReportEngine); + d->setSaveToFileVisible(value); +} + +bool ReportEngine::saveToFileIsVisible() +{ + Q_D(ReportEngine); + return d->saveToFileIsVisible(); +} + +void ReportEngine::setPrintToPdfVisible(bool value) +{ + Q_D(ReportEngine); + d->setPrintToPdfVisible(value); +} + +bool ReportEngine::printToPdfIsVisible() +{ + Q_D(ReportEngine); + return d->printToPdfIsVisible(); +} + +void ReportEngine::setPrintVisible(bool value) +{ + Q_D(ReportEngine); + d->setPrintVisible(value); +} + +bool ReportEngine::printIsVisible() +{ + Q_D(ReportEngine); + return d->printIsVisible(); +} + bool ReportEngine::isBusy() { Q_D(ReportEngine); diff --git a/limereport/lrreportengine.h b/limereport/lrreportengine.h index f935b80..b9e6e94 100644 --- a/limereport/lrreportengine.h +++ b/limereport/lrreportengine.h @@ -100,6 +100,12 @@ public: void setPreviewWindowIcon(const QIcon& icon); void setResultEditable(bool value); bool resultIsEditable(); + void setSaveToFileVisible(bool value); + bool saveToFileIsVisible(); + void setPrintToPdfVisible(bool value); + bool printToPdfIsVisible(); + void setPrintVisible(bool value); + bool printIsVisible(); bool isBusy(); void setPassPharse(QString& passPharse); Qt::LayoutDirection previewLayoutDirection(); diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index 7784479..e9ea8dd 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -126,6 +126,12 @@ public: bool isBusy(); bool resultIsEditable() const; void setResultEditable(bool value); + bool saveToFileIsVisible() const; + void setSaveToFileVisible(bool value); + bool printToPdfIsVisible() const; + void setPrintToPdfVisible(bool value); + bool printIsVisible() const; + void setPrintVisible(bool value); void setPassPhrase(const QString &passPhrase); void reorderPages(const QList &reorderedPages); @@ -192,6 +198,9 @@ private: Qt::LayoutDirection m_previewLayoutDirection; ScaleType m_previewScaleType; int m_previewScalePercent; + bool m_saveToFileVisible; + bool m_printToPdfVisible; + bool m_printVisible; }; }