mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 16:44:39 +03:00
Added the ability to change the background color of the preview page
This commit is contained in:
parent
4e91701387
commit
b8900b1e96
@ -29,6 +29,8 @@ public:
|
||||
ScaleType scaleType() const;
|
||||
int scalePercent() const;
|
||||
void setScaleType(const ScaleType &scaleType, int percent = 0);
|
||||
void setPreviewPageBackgroundColor(QColor color);
|
||||
QColor previewPageBackgroundColor();
|
||||
public slots:
|
||||
void refreshPages();
|
||||
void zoomIn();
|
||||
@ -67,7 +69,8 @@ private:
|
||||
PreviewReportWidgetPrivate* d_ptr;
|
||||
ScaleType m_scaleType;
|
||||
int m_scalePercent;
|
||||
QTimer m_resizeTimer;
|
||||
QTimer m_resizeTimer;
|
||||
QColor m_previewPageBackgroundColor;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -107,6 +107,7 @@ public:
|
||||
PreviewReportWidget *createPreviewWidget(QWidget *parent = 0);
|
||||
void setPreviewWindowTitle(const QString& title);
|
||||
void setPreviewWindowIcon(const QIcon& icon);
|
||||
void setPreviewPageBackgroundColor(QColor color);
|
||||
void setResultEditable(bool value);
|
||||
bool resultIsEditable();
|
||||
bool isBusy();
|
||||
|
@ -71,7 +71,7 @@ QList<QString> PreviewReportWidgetPrivate::aviableExporters()
|
||||
PreviewReportWidget::PreviewReportWidget(ReportEngine *report, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::PreviewReportWidget), d_ptr(new PreviewReportWidgetPrivate(this)),
|
||||
m_scaleType(FitWidth), m_scalePercent(0)
|
||||
m_scaleType(FitWidth), m_scalePercent(0), m_previewPageBackgroundColor(Qt::white)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
d_ptr->m_report = report->d_ptr;
|
||||
@ -127,6 +127,7 @@ void PreviewReportWidget::initPreview()
|
||||
ui->graphicsView->setScene(d_ptr->m_previewPage);
|
||||
ui->graphicsView->resetMatrix();
|
||||
ui->graphicsView->centerOn(0, 0);
|
||||
ui->graphicsView->scene()->setBackgroundBrush(QColor(m_previewPageBackgroundColor));
|
||||
setScalePercent(d_ptr->m_scalePercent);
|
||||
}
|
||||
|
||||
@ -322,6 +323,16 @@ void PreviewReportWidget::setScaleType(const ScaleType &scaleType, int percent)
|
||||
m_scalePercent = percent;
|
||||
}
|
||||
|
||||
void PreviewReportWidget::setPreviewPageBackgroundColor(QColor color)
|
||||
{
|
||||
m_previewPageBackgroundColor = color;
|
||||
}
|
||||
|
||||
QColor PreviewReportWidget::previewPageBackgroundColor()
|
||||
{
|
||||
return m_previewPageBackgroundColor;
|
||||
}
|
||||
|
||||
void PreviewReportWidget::refreshPages()
|
||||
{
|
||||
if (d_ptr->m_report){
|
||||
|
@ -29,6 +29,8 @@ public:
|
||||
ScaleType scaleType() const;
|
||||
int scalePercent() const;
|
||||
void setScaleType(const ScaleType &scaleType, int percent = 0);
|
||||
void setPreviewPageBackgroundColor(QColor color);
|
||||
QColor previewPageBackgroundColor();
|
||||
public slots:
|
||||
void refreshPages();
|
||||
void zoomIn();
|
||||
@ -67,7 +69,8 @@ private:
|
||||
PreviewReportWidgetPrivate* d_ptr;
|
||||
ScaleType m_scaleType;
|
||||
int m_scalePercent;
|
||||
QTimer m_resizeTimer;
|
||||
QTimer m_resizeTimer;
|
||||
QColor m_previewPageBackgroundColor;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
PreviewReportWidgetPrivate(PreviewReportWidget* previewReportWidget):
|
||||
m_previewPage(NULL), m_report(NULL), m_zoomer(NULL),
|
||||
m_currentPage(1), m_changingPage(false), m_priorScrolValue(0), m_scalePercent(50),
|
||||
q_ptr(previewReportWidget) {}
|
||||
q_ptr(previewReportWidget), m_previePageColor(Qt::white) {}
|
||||
bool pageIsVisible();
|
||||
QRectF calcPageShift();
|
||||
void setPages( ReportPages pages);
|
||||
@ -31,7 +31,7 @@ public:
|
||||
int m_priorScrolValue;
|
||||
int m_scalePercent;
|
||||
PreviewReportWidget* q_ptr;
|
||||
|
||||
QColor m_previePageColor;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -47,7 +47,8 @@ namespace LimeReport{
|
||||
|
||||
PreviewReportWindow::PreviewReportWindow(ReportEngine *report, QWidget *parent, QSettings *settings, Qt::WindowFlags flags) :
|
||||
QMainWindow(parent,flags),
|
||||
ui(new Ui::PreviewReportWindow), m_settings(settings), m_ownedSettings(false), m_scalePercentChanging(false)
|
||||
ui(new Ui::PreviewReportWindow), m_settings(settings), m_ownedSettings(false),
|
||||
m_scalePercentChanging(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowTitle("Lime Report Preview");
|
||||
@ -362,6 +363,16 @@ void PreviewReportWindow::setPreviewScaleType(const ScaleType &previewScaleType,
|
||||
m_previewReportWidget->setScaleType(previewScaleType, percent);
|
||||
}
|
||||
|
||||
QColor PreviewReportWindow::previewPageBackgroundColor()
|
||||
{
|
||||
return m_previewReportWidget->previewPageBackgroundColor();
|
||||
}
|
||||
|
||||
void PreviewReportWindow::setPreviewPageBackgroundColor(QColor color)
|
||||
{
|
||||
m_previewReportWidget->setPreviewPageBackgroundColor(color);
|
||||
}
|
||||
|
||||
void PreviewReportWindow::on_actionSaveToFile_triggered()
|
||||
{
|
||||
m_previewReportWidget->saveToFile();
|
||||
|
@ -73,7 +73,8 @@ public:
|
||||
QSettings* settings();
|
||||
ScaleType previewScaleType() const;
|
||||
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
||||
|
||||
QColor previewPageBackgroundColor();
|
||||
void setPreviewPageBackgroundColor(QColor color);
|
||||
protected:
|
||||
void writeSetting();
|
||||
void restoreSetting();
|
||||
@ -124,7 +125,6 @@ private:
|
||||
ScaleType m_previewScaleType;
|
||||
int m_previewScalePercent;
|
||||
bool m_scalePercentChanging;
|
||||
|
||||
};
|
||||
} //namespace LimeReport
|
||||
#endif // LRPREVIEWREPORTWINDOW_H
|
||||
|
@ -82,7 +82,8 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
|
||||
m_reportRendering(false), m_resultIsEditable(true), m_passPhrase("HjccbzHjlbyfCkjy"),
|
||||
m_fileWatcher( new QFileSystemWatcher( this ) ), m_reportLanguage(QLocale::AnyLanguage),
|
||||
m_previewLayoutDirection(Qt::LayoutDirectionAuto), m_designerFactory(0),
|
||||
m_previewScaleType(FitWidth), m_previewScalePercent(0), m_startTOCPage(0)
|
||||
m_previewScaleType(FitWidth), m_previewScalePercent(0), m_startTOCPage(0),
|
||||
m_previewPageBackgroundColor(Qt::white)
|
||||
{
|
||||
#ifdef HAVE_STATIC_BUILD
|
||||
initResources();
|
||||
@ -503,6 +504,7 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
|
||||
if (pages.count()>0){
|
||||
Q_Q(ReportEngine);
|
||||
PreviewReportWindow* w = new PreviewReportWindow(q,0,settings());
|
||||
w->setPreviewPageBackgroundColor(m_previewPageBackgroundColor);
|
||||
w->setWindowFlags(Qt::Dialog|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint| Qt::WindowMinMaxButtonsHint);
|
||||
w->setAttribute(Qt::WA_DeleteOnClose,true);
|
||||
w->setWindowModality(Qt::ApplicationModal);
|
||||
@ -1094,6 +1096,16 @@ void ReportEnginePrivate::setPreviewWindowTitle(const QString &previewWindowTitl
|
||||
m_previewWindowTitle = previewWindowTitle;
|
||||
}
|
||||
|
||||
QColor ReportEnginePrivate::previewWindowPageBackground()
|
||||
{
|
||||
return m_previewPageBackgroundColor;
|
||||
}
|
||||
|
||||
void ReportEnginePrivate::setPreviewWindowPageBackground(QColor color)
|
||||
{
|
||||
m_previewPageBackgroundColor = color;
|
||||
}
|
||||
|
||||
QIcon ReportEnginePrivate::previewWindowIcon() const
|
||||
{
|
||||
return m_previewWindowIcon;
|
||||
@ -1338,6 +1350,12 @@ void ReportEngine::setPreviewWindowIcon(const QIcon &icon)
|
||||
d->setPreviewWindowIcon(icon);
|
||||
}
|
||||
|
||||
void ReportEngine::setPreviewPageBackgroundColor(QColor color)
|
||||
{
|
||||
Q_D(ReportEngine);
|
||||
d->setPreviewWindowPageBackground(color);
|
||||
}
|
||||
|
||||
void ReportEngine::setResultEditable(bool value)
|
||||
{
|
||||
Q_D(ReportEngine);
|
||||
|
@ -107,6 +107,7 @@ public:
|
||||
PreviewReportWidget *createPreviewWidget(QWidget *parent = 0);
|
||||
void setPreviewWindowTitle(const QString& title);
|
||||
void setPreviewWindowIcon(const QIcon& icon);
|
||||
void setPreviewPageBackgroundColor(QColor color);
|
||||
void setResultEditable(bool value);
|
||||
bool resultIsEditable();
|
||||
bool isBusy();
|
||||
|
@ -189,6 +189,8 @@ public:
|
||||
void setPreviewWindowIcon(const QIcon &previewWindowIcon);
|
||||
QString previewWindowTitle() const;
|
||||
void setPreviewWindowTitle(const QString &previewWindowTitle);
|
||||
QColor previewWindowPageBackground();
|
||||
void setPreviewWindowPageBackground(QColor color);
|
||||
|
||||
bool suppressFieldAndVarError() const;
|
||||
void setSuppressFieldAndVarError(bool suppressFieldAndVarError);
|
||||
@ -299,6 +301,7 @@ private:
|
||||
ScaleType m_previewScaleType;
|
||||
int m_previewScalePercent;
|
||||
int m_startTOCPage;
|
||||
QColor m_previewPageBackgroundColor;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user