From caa516d6bdaab3d0faabe7d74006645b111b4fa5 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Sat, 2 Apr 2016 16:07:01 +0300 Subject: [PATCH] Scale actions have been added to Report Preview Window --- demo_r2/mainwindow.cpp | 4 +-- limereport/images/FitPage.png | Bin 0 -> 1102 bytes limereport/images/FitWidth.png | Bin 0 -> 1071 bytes limereport/images/OneToOne.png | Bin 0 -> 1051 bytes limereport/lrpreviewreportwidget.cpp | 1 + limereport/lrpreviewreportwindow.cpp | 46 +++++++++++++++++++++++++++ limereport/lrpreviewreportwindow.h | 9 ++++++ limereport/lrpreviewreportwindow.ui | 32 ++++++++++++++++++- limereport/report.qrc | 3 ++ 9 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 limereport/images/FitPage.png create mode 100644 limereport/images/FitWidth.png create mode 100644 limereport/images/OneToOne.png diff --git a/demo_r2/mainwindow.cpp b/demo_r2/mainwindow.cpp index 06a02fd..45e4b84 100644 --- a/demo_r2/mainwindow.cpp +++ b/demo_r2/mainwindow.cpp @@ -70,7 +70,7 @@ void MainWindow::enableUI(bool value) void MainWindow::slotScalePercentChanged(int percent) { - ui->cbScalePercent->setCurrentText(QString("%1\%").arg(percent)); + ui->cbScalePercent->setCurrentText(QString("%1%").arg(percent)); } void MainWindow::scaleComboboxChanged(QString text) @@ -101,7 +101,7 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, int ) void MainWindow::initPercentCombobox() { for (int i = 10; i<310; i+=10){ - ui->cbScalePercent->addItem(QString("%1\%").arg(i)); + ui->cbScalePercent->addItem(QString("%1%").arg(i)); } ui->cbScalePercent->setCurrentIndex(4); } diff --git a/limereport/images/FitPage.png b/limereport/images/FitPage.png new file mode 100644 index 0000000000000000000000000000000000000000..a630918a32014932138a8d76bd699446e76f113a GIT binary patch literal 1102 zcmaJ=Pe>F|93EYZWmTxaP^o;3Sw`*7%<8P};A-oPTMO=D>yi=$&CWdC$(?!A%+p;x zgc?QvNT?2xU{DYpA_y-*Nn#y}=pb~64$&dJ6hxFzA=w*stwY-|Gw%=I_x*nF_xs-Y zuK0m+Pql}lsPgDRDM7|f&gb4p{xx5hWinLZj$Yi2`fygZAQe_o3WBIE_rnB~)!~yb zU<*aLXf4@`dt;q~f^?tkV0<~>i0Hm5~7@sM2k%pd}{|0Ucr)*n~_1+Gx;HNaOlyolvGA zT2RKwN+OiWSFtONFtXFg1Y&mp)c0tHin8{e6?`lvL=79uh61Bfh$ad?O;ZIa&?K=O zFGZTg2*-8sVcs8ZZjZE!q9n4-O;VmKA!Sg92F`QUKirOjT*nH!Ng_+o(uSZKv5*c{ zjx1<}b7?QAx5iZq=OPy5G9($sY3yH(&TkR-IMa38lEu35p+Vek5nJyl8k{9pVlFC$ zlexF4rRC)|SKa95zWwUe4csnn{9MK2?yC1&PgjC%^XXqTRj)G(XQpKfRG&NajgzPE z43*Y+%3Uu%#zz;6AMESAv|+O7RqM^!8{x(>YR28~I`+lAuzhQ)*mI)c@YCy+^(CDT zmnN8u8M%F7p1+luvE!v5ypenJ?u)G-($d6{yGK6FyFEYJmQTrVJX^%e6_3ZB&pnG= ztBkwMx}CSmM}rlUSGl8S_l~h_nv Dve9EC literal 0 HcmV?d00001 diff --git a/limereport/images/FitWidth.png b/limereport/images/FitWidth.png new file mode 100644 index 0000000000000000000000000000000000000000..af2fed91d0066dab19005800eb7a74295497aea9 GIT binary patch literal 1071 zcmaJ=PfXKL9B!Bxg2Nyh61niG8X;lrTDHL&=49(8ODrK{k;M~T`+x@8SK9|0BpL#0 z(38YJL5=YbHx35mWHgykK}k$Bp3t*i)I<^wUX1e<7c?5xf>ei!G7uzmc>pG%td5;oh3ypO zqP0{Sr=^pEf^IP9{LEvXv zJc^g&Kp?=j`2E2Dgq_x|4?1uM%y?Eck=zGu$>w+A)ACY8nG18xc);8o0<+cewtNT*nH!Ng|8T(ng^gw~!7tjx1=U zbKy(sZE@AoxwMqzvLqSSY3yH(E^ZO`IMZ$0lEt?1p+Vek5nEr+pPDCEVlE+eq;elK zzY2x0>&Qg;%JlFfuyQzFz4+kwVb_~Xt@`2f$kBx_Wp#UROr3r{-TX?tY~Qb)aL+8S zmo-pUxm)zz3Qs;he__|{#k!T3#~Yq`?~U%M?^<5_lwN28!_&19>cCy#cFz_-_tMRu zVTQUoHDCVq#d>7v?a_)6WHFkq|b({uz zP%j?DKuioL6B84Hdf?ze<3%|T!^uC<1mnSj2Th1K<9r?4@ZfCPzCZcC@ArGZ-}i3D z$3~i)jy6#g)f^oa5@c+(zs7y!-?38^$^v_a)g{^(m!;~2O;LRVmM%)u5Q8+FQnVob{n>LGC~}aV@WtFQJq)wT z=$rw^=f;xK+_V&s>4ARGXYoWpg;)fZI-{Aq6{JhLJek|u3=K*UJRPKWlS;+nAdCzM ze6Aj+_wJuYNSF>D|Zur)j$CqX#PyoN=~shOP>1p%6pq3Bpa8n6|`G@8Xhnq<0r1XZuf zYG%1iq+pCC>J000+efMZW3m53RkeyXaRTn;`%hsrnb#qcfF_zXB+|G{ryWY?!v+*F zGLi_*RH_)yB8d@tdKlA)h A=>Px# literal 0 HcmV?d00001 diff --git a/limereport/lrpreviewreportwidget.cpp b/limereport/lrpreviewreportwidget.cpp index 117dc24..47b3fb9 100644 --- a/limereport/lrpreviewreportwidget.cpp +++ b/limereport/lrpreviewreportwidget.cpp @@ -211,6 +211,7 @@ void PreviewReportWidget::saveToFile() void PreviewReportWidget::setScalePercent(int percent) { ui->graphicsView->resetMatrix(); + d_ptr->m_scalePercent = percent; qreal scaleSize = percent/100.0; ui->graphicsView->scale(scaleSize, scaleSize); emit scalePercentChanged(percent); diff --git a/limereport/lrpreviewreportwindow.cpp b/limereport/lrpreviewreportwindow.cpp index cf1296d..c0b33fc 100644 --- a/limereport/lrpreviewreportwindow.cpp +++ b/limereport/lrpreviewreportwindow.cpp @@ -61,6 +61,13 @@ PreviewReportWindow::PreviewReportWindow(ReportEnginePrivate *report,QWidget *pa setCentralWidget(m_previewReportWidget); layout()->setContentsMargins(1,1,1,1); connect(m_previewReportWidget,SIGNAL(pageChanged(int)), this,SLOT(slotPageChanged(int)) ); + + + m_scalePercent = new QComboBox(this); + ui->toolBar->insertWidget(ui->actionZoomOut, m_scalePercent); + initPercentCombobox(); + connect(m_previewReportWidget, SIGNAL(scalePercentChanged(int)), this, SLOT(slotScalePercentChanged(int))); + connect(m_scalePercent, SIGNAL(currentIndexChanged(QString)), this, SLOT(scaleComboboxChanged(QString))); restoreSetting(); } @@ -241,6 +248,14 @@ ItemsReaderIntf *PreviewReportWindow::reader() return m_reader.data(); } +void PreviewReportWindow::initPercentCombobox() +{ + for (int i = 10; i<310; i+=10){ + m_scalePercent->addItem(QString("%1%").arg(i)); + } + m_scalePercent->setCurrentIndex(4); +} + void PreviewReportWindow::on_actionSaveToFile_triggered() { m_previewReportWidget->saveToFile(); @@ -266,4 +281,35 @@ void PreviewReportWindow::slotPageChanged(int pageIndex) m_pagesNavigator->setValue(pageIndex); } +void PreviewReportWindow::on_actionFit_page_width_triggered() +{ + m_previewReportWidget->fitWidth(); +} + +void PreviewReportWindow::on_actionFit_page_triggered() +{ + m_previewReportWidget->fitPage(); +} + +void PreviewReportWindow::on_actionOne_to_one_triggered() +{ + m_previewReportWidget->setScalePercent(100); +} + +void PreviewReportWindow::scaleComboboxChanged(QString text) +{ + m_previewReportWidget->setScalePercent(text.remove(text.count()-1,1).toInt()); +} + +void PreviewReportWindow::slotScalePercentChanged(int percent) +{ + m_scalePercent->setCurrentText(QString("%1%").arg(percent)); +} + }// namespace LimeReport + + + + + + diff --git a/limereport/lrpreviewreportwindow.h b/limereport/lrpreviewreportwindow.h index c23d5dc..6a68f82 100644 --- a/limereport/lrpreviewreportwindow.h +++ b/limereport/lrpreviewreportwindow.h @@ -33,6 +33,7 @@ #include #include #include +#include #include "lrpagedesignintf.h" #include "lrreportrender.h" @@ -78,8 +79,15 @@ public slots: void slotLastPage(); void slotPrintToPDF(); void slotPageChanged(int pageIndex); +private slots: + void on_actionFit_page_width_triggered(); + void on_actionFit_page_triggered(); + void on_actionOne_to_one_triggered(); + void scaleComboboxChanged(QString text); + void slotScalePercentChanged(int percent); private: ItemsReaderIntf* reader(); + void initPercentCombobox(); //bool pageIsVisible(PageItemDesignIntf::Ptr page); //QRectF calcPageShift(PageItemDesignIntf::Ptr page); private: @@ -91,6 +99,7 @@ private: QSettings* m_settings; bool m_ownedSettings; PreviewReportWidget* m_previewReportWidget; + QComboBox* m_scalePercent; }; } //namespace LimeReport #endif // LRPREVIEWREPORTWINDOW_H diff --git a/limereport/lrpreviewreportwindow.ui b/limereport/lrpreviewreportwindow.ui index a7c2170..7618999 100644 --- a/limereport/lrpreviewreportwindow.ui +++ b/limereport/lrpreviewreportwindow.ui @@ -77,6 +77,9 @@ + + + @@ -224,10 +227,37 @@ Print To PDF + + + + :/report/images/FitWidth.png:/report/images/FitWidth.png + + + Fit page width + + + + + + :/report/images/FitPage.png:/report/images/FitPage.png + + + Fit page + + + + + + :/report/images/OneToOne.png:/report/images/OneToOne.png + + + One to one + + - + diff --git a/limereport/report.qrc b/limereport/report.qrc index 75b1d3b..a8e1b17 100644 --- a/limereport/report.qrc +++ b/limereport/report.qrc @@ -161,5 +161,8 @@ images/settings.png images/grid.png images/magnet.png + images/FitPage.png + images/FitWidth.png + images/OneToOne.png