From 7bf0ce51e6ddf1450fcedf264b916103213043a4 Mon Sep 17 00:00:00 2001 From: Alexander Arin Date: Mon, 31 Oct 2022 21:20:24 +0300 Subject: [PATCH] Border editor refactoring --- limereport/images/border_settings.png | Bin 0 -> 5843 bytes limereport/items/borderframeeditor.cpp | 287 ------------------ .../editors/lritemsborderseditorwidget.cpp | 54 ++-- .../editors/lritemsborderseditorwidget.h | 6 +- limereport/items/images/border_settings.png | Bin 0 -> 5788 bytes limereport/items/lrbordereditor.cpp | 206 ++++++------- limereport/items/lrbordereditor.h | 53 ++-- limereport/items/lrbordereditor.ui | 68 +++-- limereport/items/lrborderframeeditor.cpp | 181 +++++++++++ ...derframeeditor.h => lrborderframeeditor.h} | 20 +- ...rframeeditor.ui => lrborderframeeditor.ui} | 4 +- limereport/items/lrpageeditor.cpp | 77 ++--- limereport/items/lrpageeditor.h | 9 +- limereport/items/lrpageeditor.ui | 16 +- limereport/limereport.pri | 6 +- limereport/lrbasedesignintf.cpp | 22 +- limereport/lrbasedesignintf.h | 2 +- limereport/lrpagedesignintf.cpp | 14 + limereport/lrpagedesignintf.h | 5 + limereport/lrpageitemdesignintf.cpp | 34 +-- limereport/lrreportdesignwidget.cpp | 10 + limereport/lrreportdesignwidget.h | 2 + limereport/report.qrc | 1 + 23 files changed, 487 insertions(+), 590 deletions(-) create mode 100644 limereport/images/border_settings.png delete mode 100644 limereport/items/borderframeeditor.cpp create mode 100644 limereport/items/images/border_settings.png create mode 100644 limereport/items/lrborderframeeditor.cpp rename limereport/items/{borderframeeditor.h => lrborderframeeditor.h} (61%) rename limereport/items/{borderframeeditor.ui => lrborderframeeditor.ui} (94%) diff --git a/limereport/images/border_settings.png b/limereport/images/border_settings.png new file mode 100644 index 0000000000000000000000000000000000000000..3bae2c8c8626033ef5c59aed46123ad2a09cae81 GIT binary patch literal 5843 zcmeHLX;f3!7QP9fGK!#}pb{d344DHNOb`tzLNjSwATdC+p(jJe*pilF74CoGxFD;!uNJ20?~j z_f5$veKywNZ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7;2Y$*RD75nj-x?j z?D&YU`XE4$i_g^Q)NB$dFE5XnM(?8&T;{CpMvor7#3fU1Vsos>HAcBiG z#b+ZbsT^UORT@pgK#|Z;f`m>ECD2*0lmLg2sRWh`rqWRfgA&4o`#}kmS{ttX8I0JGeqRP{L91_bFXo3zl@kt2{4P{X%Oa_g`pfl+qADxm= zjTY=h6DoyFq*2WyriEdHasaikX{Q1JvmI2!=4nt^r_zX3s%$RaloZZ1^TV(Z94G|V z!4a?y1)yXql}#bDsZ24M$|lpGgDLI6} zAjnWEoj{k$5CS;uFhK&Y8I%meG=|hd>j!kLN~X($HRyy4z$4%aY)~^-xUqdp74T^` zd6}qb9ROtn3YqYcG8&%LS1ieNW4y1HL;5d1IA(`_R}7eEv4N`#+=QeLS79GtAlHBL z)3*-)WC$GYOOVgv_X}NL==v-MKFj&b?)pO4XEE?u&R=%d|BWuYk1tcG68s002VRv5 zJ7Vj>EAdlNw3u&x;erCZAXS1D%?~r$9ZHMDQhXtH5G3MYQ}~$TG#e}y8W)TaactCL z8zLTKV-3ZyFo*z~6$445pl~7-)pRi|#w0y+?FixP-M zmp4j*sG8-#A6U@KX%+#_7E55hpY(F73fHvh~62JsT&;=4%6Aq98Y=05dOyr&AOguBr)SepGrqO)`)+AOutmk^vQg(m+bU#}vBS6tuUu_sw(GQn2b6 zU3^Re6mGl*e*J|olF5+~&_bJ0QJ`b1j+&~4AbVHS7Xy92emF1=)Cq+Afkrz|cWdv* zj<3ssX_6pff_Qjq(TZwE2sg-T)XwQYm%kz5_{(N5>c;!q$UC?A`&@Z2EPY6H$?}j? z%)FA>_$s&iiM5LlTCaF~(fjGBY3;@pgaJ)C^K4z?#tx?(Xx#@;Apt)oV*kYSlK%jW C$=tdC literal 0 HcmV?d00001 diff --git a/limereport/items/borderframeeditor.cpp b/limereport/items/borderframeeditor.cpp deleted file mode 100644 index a864550..0000000 --- a/limereport/items/borderframeeditor.cpp +++ /dev/null @@ -1,287 +0,0 @@ -#include "borderframeeditor.h" -#include "ui_borderframeeditor.h" -#include -#include -#include -#include -#include "lrbasedesignintf.h" -#include "lrbordereditor.h" -using namespace LimeReport; -BorderFrameEditor::BorderFrameEditor(QWidget *parent) - : QWidget(parent) - , ui(new Ui::BorderFrameEditor) -{ - ui->setupUi(this); - scene = new QGraphicsScene(ui->graphicsView); - - QRect vRect = rect(); - - //Draw corder lines - //topLeft - scene->addLine(10,5, 10,10,QPen(Qt::gray)); - scene->addLine(5,10, 10,10,QPen(Qt::gray)); - //bottomLeft - scene->addLine(10,vRect.bottom() -5, 10,vRect.bottom()-10,QPen(Qt::gray)); - scene->addLine(5,vRect.bottom()-10,10,vRect.bottom()-10,QPen(Qt::gray)); - //bottomRight - scene->addLine(vRect.right()-10,vRect.bottom() -5,vRect.right()- 10,vRect.bottom()-10,QPen(Qt::gray)); - scene->addLine(vRect.right()-5,vRect.bottom()-10,vRect.right()-10,vRect.bottom()-10,QPen(Qt::gray)); - //topRight - scene->addLine(vRect.width()-10,5,vRect.width()- 10,10,QPen(Qt::gray)); - scene->addLine(vRect.width()-5,10, vRect.width()-10,10,QPen(Qt::gray)); - scene->setSceneRect(vRect); - ui->graphicsView->setScene(scene); - QGraphicsSimpleTextItem * io = new QGraphicsSimpleTextItem(); - io->setAcceptedMouseButtons(Qt::LeftButton); - io->setPos(scene->sceneRect().center()); - io->setText(tr("Text")); - scene->addItem(io); - - QRectF bR = io->sceneBoundingRect(); - io->setPos( scene->sceneRect().center().x() - bR.width()/2, scene->sceneRect().center().y() - bR.height()/2 ); - connect(this,SIGNAL(borderSideClicked(int, bool)),this,SLOT(SlotBorderSideClicked(int,bool))); - -} - -BorderFrameEditor::~BorderFrameEditor() -{ - delete ui; -} - -void BorderFrameEditor::setPen(QPen pen) -{ - m_pen = pen; - updateBorders(); - -} - -QPen BorderFrameEditor::pen() -{ - return m_pen; -} - -void BorderFrameEditor::setAllLines() -{ - - topLine = scene->addLine(QLineF(10,10,rect().width() - 10,10),m_pen); - - - leftLine = scene->addLine(QLineF(10,10,10,rect().height() - 10),m_pen); - - bottomLine = scene->addLine(QLineF(10,rect().bottom() -10,rect().width() - 10 - ,rect().bottom() - 10),m_pen); - - - - rightLine = scene->addLine(QLineF(rect().width() - 10,10 - ,rect().width() - 10,rect().height() - 10),m_pen); - - -} - -void BorderFrameEditor::unSetAllLines() -{ - if(topLine) - { - scene->removeItem(topLine); - - } - if(leftLine) - { - scene->removeItem(leftLine); - - } - if(bottomLine) - { - scene->removeItem(bottomLine); - - - - } - if(rightLine) - { - scene->removeItem(rightLine); - - } - -} - -void BorderFrameEditor::mousePressEvent(QMouseEvent *event) -{ - - if(event->x() >= 10 && event->y() <30)//Draw top border - { - - if(!topLine) - { - - emit borderSideClicked(1,true); - - } - else - { - - emit borderSideClicked(1,false); - } - } - - if((event->x() >= 10 && event->x() < 30) && (event->y() > 10)) //Draw border left - { - if(!leftLine) - { - - emit borderSideClicked(4,true); - - } - else - { - - emit borderSideClicked(4,false); - - } - } - - if(event->x() >= 10 && (event->y() >80 && event->y() < rect().bottom())) //Draw bottom border - { - if(!bottomLine) - { - - emit borderSideClicked(2,true); - } - - else - { - - emit borderSideClicked(2,false); - - } - } - - if((event->x() >= 130 && event->x() < rect().width()) && event->y() > 10) //Draw border right - { - if(!rightLine) - { - - emit borderSideClicked(8,true); - - } - else - { - - emit borderSideClicked(8,false); - - } - - } - - -} - -void BorderFrameEditor::SlotBorderSideClicked(int side, bool show) -{ - - switch(side) - { - case BaseDesignIntf::BorderSide::TopLine: - { - if(show) - { - topLine = scene->addLine(QLineF(10,10,rect().width() - 10,10),m_pen); - - - } - else - { - scene->removeItem(topLine); - topLine = NULL; - - } - }break; - case BaseDesignIntf::LeftLine: - { - if(show) - { - leftLine = scene->addLine(QLineF(10,10,10,rect().height() - 10),m_pen); - - - } - else - { - scene->removeItem(leftLine); - leftLine = NULL; - - - } - }break; - case BaseDesignIntf::BottomLine: - { - if(show) - { - bottomLine = scene->addLine(QLineF(10,rect().bottom() -10,rect().width() - 10 - ,rect().bottom() - 10),m_pen); - - } - - else - { - scene->removeItem(bottomLine); - bottomLine = NULL; - - - } - }break; - case BaseDesignIntf::RightLine: - { - if(show) - { - rightLine = scene->addLine(QLineF(rect().width() - 10,10 - ,rect().width() - 10,rect().height() - 10),m_pen); - - } - else - { - scene->removeItem(rightLine); - rightLine = NULL; - - } - - } - - } - updateBorders(); -} - -void BorderFrameEditor::updateBorders() -{ - //if a line is set we redraw it - if(topLine) - { - scene->removeItem(topLine); - topLine = scene->addLine(QLineF(10,10,rect().width() - 10,10),m_pen); - - } - if(leftLine) - { - scene->removeItem(leftLine); - leftLine = scene->addLine(QLineF(10,10,10,rect().height() - 10),m_pen); - - } - if(bottomLine) - { - scene->removeItem(bottomLine); - - bottomLine = scene->addLine(QLineF(10,rect().bottom() -10,rect().width() - 10 - ,rect().bottom() - 10),m_pen); - - } - if(rightLine) - { - scene->removeItem(rightLine); - - rightLine = scene->addLine(QLineF(rect().width() - 10,10 - ,rect().width() - 10,rect().height() - 10),m_pen); - - } - -} - diff --git a/limereport/items/editors/lritemsborderseditorwidget.cpp b/limereport/items/editors/lritemsborderseditorwidget.cpp index 7b4853a..a49aef2 100644 --- a/limereport/items/editors/lritemsborderseditorwidget.cpp +++ b/limereport/items/editors/lritemsborderseditorwidget.cpp @@ -44,7 +44,7 @@ void ItemsBordersEditorWidget::setItemEvent(BaseDesignIntf* item) updateValues((BaseDesignIntf::BorderLines)borders.toInt()); setEnabled(true); } - itm = item; + m_item = item; } void ItemsBordersEditorWidget::properyChangedEvent(const QString& property, const QVariant& oldValue, const QVariant& newValue) @@ -72,21 +72,18 @@ void ItemsBordersEditorWidget::allBordesClicked() updateValues((BaseDesignIntf::BorderLines)borders); } -void ItemsBordersEditorWidget::buttonClicked(bool) -{ - -} +void ItemsBordersEditorWidget::buttonClicked(bool){} void ItemsBordersEditorWidget::editBorderClicked() { - lrbordereditor be; - be.loadItem(itm); - if(be.exec() == QDialog::Rejected)return; + BorderEditor be; + be.loadItem(m_item); + if ( be.exec() == QDialog::Rejected ) return; updateValues(be.borderSides()); - itm->setBorderLinesFlags(be.borderSides()); - itm->setBorderLineSize(be.border_width()); - itm->setBorderStyle((LimeReport::BaseDesignIntf::BorderStyle)be.border_style()); - itm->setBorderColor(be.borderColor()); + m_item->setBorderLinesFlags(be.borderSides()); + m_item->setBorderLineSize(be.borderWidth()); + m_item->setBorderStyle((LimeReport::BaseDesignIntf::BorderStyle)be.borderStyle()); + m_item->setBorderColor(be.borderColor()); } void ItemsBordersEditorWidget::initEditor() @@ -129,7 +126,7 @@ void ItemsBordersEditorWidget::initEditor() addAction(m_allLines); addSeparator(); m_BorderEditor = new QAction(tr("Edit border"),this); - m_BorderEditor->setIcon(QIcon(":/report/images/allLines")); + m_BorderEditor->setIcon(QIcon(":/report/images/borderEditor")); connect(m_BorderEditor,SIGNAL(triggered()),this,SLOT(editBorderClicked())); addAction(m_BorderEditor); @@ -140,20 +137,20 @@ void ItemsBordersEditorWidget::initEditor() void ItemsBordersEditorWidget::updateValues(BaseDesignIntf::BorderLines borders) { m_changing = true; - m_topLine->setChecked(borders&BaseDesignIntf::TopLine); - m_bottomLine->setChecked(borders&BaseDesignIntf::BottomLine); - m_leftLine->setChecked(borders&BaseDesignIntf::LeftLine); - m_rightLine->setChecked(borders&BaseDesignIntf::RightLine); + m_topLine->setChecked(borders & BaseDesignIntf::TopLine); + m_bottomLine->setChecked(borders & BaseDesignIntf::BottomLine); + m_leftLine->setChecked(borders & BaseDesignIntf::LeftLine); + m_rightLine->setChecked(borders & BaseDesignIntf::RightLine); m_changing = false; } BaseDesignIntf::BorderLines ItemsBordersEditorWidget::createBorders() { int borders = 0; - borders += (m_topLine->isChecked())?BaseDesignIntf::TopLine:0; - borders += (m_bottomLine->isChecked())?BaseDesignIntf::BottomLine:0; - borders += (m_leftLine->isChecked())?BaseDesignIntf::LeftLine:0; - borders += (m_rightLine->isChecked())?BaseDesignIntf::RightLine:0; + borders += (m_topLine->isChecked()) ? BaseDesignIntf::TopLine:0; + borders += (m_bottomLine->isChecked()) ? BaseDesignIntf::BottomLine:0; + borders += (m_leftLine->isChecked()) ? BaseDesignIntf::LeftLine:0; + borders += (m_rightLine->isChecked()) ? BaseDesignIntf::RightLine:0; return (BaseDesignIntf::BorderLines)borders; } @@ -180,6 +177,21 @@ void ItemsBordersEditorWidgetForDesigner::allBordesClicked() ItemsBordersEditorWidget::allBordesClicked(); m_reportEditor->setBorders(createBorders()); } + +void ItemsBordersEditorWidgetForDesigner::editBorderClicked() +{ + BorderEditor be; + be.loadItem(m_item); + if ( be.exec() == QDialog::Rejected ) return; + + m_reportEditor->setBordersExt( + be.borderSides(), + be.borderWidth(), + (LimeReport::BaseDesignIntf::BorderStyle)be.borderStyle(), + be.borderColor() + ); +} + #endif } //namespace LimeReport diff --git a/limereport/items/editors/lritemsborderseditorwidget.h b/limereport/items/editors/lritemsborderseditorwidget.h index 2538258..ef83dbc 100644 --- a/limereport/items/editors/lritemsborderseditorwidget.h +++ b/limereport/items/editors/lritemsborderseditorwidget.h @@ -49,11 +49,12 @@ protected slots: virtual void noBordesClicked(); virtual void allBordesClicked(); virtual void buttonClicked(bool); - void editBorderClicked(); + virtual void editBorderClicked(); protected: void setItemEvent(BaseDesignIntf *item); void properyChangedEvent(const QString &property, const QVariant &oldValue, const QVariant &newValue); BaseDesignIntf::BorderLines createBorders(); + BaseDesignIntf *m_item; private: void initEditor(); void updateValues(BaseDesignIntf::BorderLines borders); @@ -66,7 +67,7 @@ private: QAction* m_BorderEditor; bool m_changing; int m_borders; - BaseDesignIntf *itm; + }; #ifdef HAVE_REPORT_DESIGNER @@ -79,6 +80,7 @@ protected slots: void buttonClicked(bool); void noBordesClicked(); void allBordesClicked(); + void editBorderClicked(); private: ReportDesignWidget* m_reportEditor; diff --git a/limereport/items/images/border_settings.png b/limereport/items/images/border_settings.png new file mode 100644 index 0000000000000000000000000000000000000000..a74087414c9377b8499b89525b322e1246f61ed2 GIT binary patch literal 5788 zcmeHLcT`hZ6Mq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H$h41AOE_wM>m*EccnO~&85>;FcV$(NTYSO)$B$^x%S3qsc(0I$S< zb7pWEP|sZO#^q)Y$s-LsT@ZHTp(G}f;0#gSAr1{0&p<3lGD0FDUk?O_W~AU6VbKU9 zLnw@b5VDYIVUQpgqGKUA+{GZ*#?ScIz{_HYL1ze zl@%I|X4Bo`L)?gKJTw=SUUU&vl7C z6&`(RW?&sH?o=ebisGE=031c<=719N3d zMgs#x0oVA`(Et-D!4wQ;Jslte*r9_}KP~ViZQ2Q6?e&=NfS{WK1pNqU2n2%u3Jkyi zvVN*Jm|E!#a0c!50?+`xq)i0U284jBK{B8sP#Q=H*l0u7X@mCn_g@nniUUiIP)CGC zLiDby;Fnwo!4G8yK?O#Wg27~jA~;S3L8ha%Uj($d#2P4#)hsr{xXWbXIFb|dji3Uk zn5>`xuJr}MoLXpvE98`m4qcl&omL4Ij<)z?_}CY7a?72!I(V%QFu+3V&5Rbld1I;0 tn-M=N7isf?zPNst>+sWybIeCV(5o89+M?-aw*yFs#Rv=9KW)y!{{YaLv+4i< literal 0 HcmV?d00001 diff --git a/limereport/items/lrbordereditor.cpp b/limereport/items/lrbordereditor.cpp index e8e2af3..63d8b88 100644 --- a/limereport/items/lrbordereditor.cpp +++ b/limereport/items/lrbordereditor.cpp @@ -2,181 +2,155 @@ #include "ui_lrbordereditor.h" #include #include "lrbasedesignintf.h" -lrbordereditor::lrbordereditor(QWidget *parent) : + +namespace LimeReport{ + +BorderEditor::BorderEditor(QWidget *parent) : QDialog(parent), - ui(new Ui::lrbordereditor) + ui(new Ui::BorderEditor), + m_borderStyle(1), + m_borderWidth(1) { ui->setupUi(this); - - connect(ui->borderFrame,SIGNAL(borderSideClicked(int, bool)), this, SLOT(checkToolButtons(int, bool))); + connect( + ui->borderFrame, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)), + this, SLOT(checkToolButtons(LimeReport::BaseDesignIntf::BorderSide, bool)) + ); } -void lrbordereditor::loadItem(LimeReport::BaseDesignIntf *i) +void BorderEditor::loadItem(LimeReport::BaseDesignIntf *item) { - item = i; - if(item->borderLines() & LimeReport::BaseDesignIntf::TopLine) - { - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine,true); + m_item = item; + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, + item->borderLines() & LimeReport::BaseDesignIntf::TopLine); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine, + item->borderLines() & LimeReport::BaseDesignIntf::LeftLine); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine, + item->borderLines() & LimeReport::BaseDesignIntf::RightLine); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine, + item->borderLines() & LimeReport::BaseDesignIntf::BottomLine); - } - if(item->borderLines() & LimeReport::BaseDesignIntf::LeftLine) - { - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,true); - - } - if(item->borderLines() & LimeReport::BaseDesignIntf::RightLine) - { - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,true); - - } - if(item->borderLines() & LimeReport::BaseDesignIntf::BottomLine) - { - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,true); - } QPen pen; pen.setWidthF(item->borderLineSize()); pen.setColor(item->borderColor()); pen.setStyle((Qt::PenStyle)item->borderStyle()); ui->borderFrame->setPen(pen); - border_color = item->borderColor().name(); + m_borderColor = item->borderColor().name(); ui->listWidget->setCurrentRow((Qt::PenStyle)item->borderStyle()); ui->comboBox->setCurrentText(QString::number(item->borderLineSize())); - borderWidth = ui->comboBox->currentText().toDouble(); - borderStyle =ui->listWidget->currentRow(); - ui->pushButton->setStyleSheet(QString("#pushButton{background-color:%1;}").arg(border_color)); + m_borderWidth = ui->comboBox->currentText().toDouble(); + m_borderStyle =ui->listWidget->currentRow(); + ui->colorIndicator->setStyleSheet(QString("background-color:%1;").arg(m_borderColor)); } -LimeReport::BaseDesignIntf::BorderLines lrbordereditor::borderSides() +LimeReport::BaseDesignIntf::BorderLines BorderEditor::borderSides() { int borders = 0; - borders += (ui->topLine->isChecked())?LimeReport::BaseDesignIntf::TopLine:0; - borders += (ui->bottomLine->isChecked())?LimeReport::BaseDesignIntf::BottomLine:0; - borders += (ui->leftLine->isChecked())?LimeReport::BaseDesignIntf::LeftLine:0; - borders += (ui->rightLine->isChecked())?LimeReport::BaseDesignIntf::RightLine:0; - return (LimeReport::BaseDesignIntf::BorderLines)borders; + borders += (ui->topLine->isChecked()) ? LimeReport::BaseDesignIntf::TopLine : 0; + borders += (ui->bottomLine->isChecked()) ? LimeReport::BaseDesignIntf::BottomLine : 0; + borders += (ui->leftLine->isChecked()) ? LimeReport::BaseDesignIntf::LeftLine : 0; + borders += (ui->rightLine->isChecked()) ? LimeReport::BaseDesignIntf::RightLine : 0; + return (LimeReport::BaseDesignIntf::BorderLines) borders; } -LimeReport::BaseDesignIntf::BorderStyle lrbordereditor::border_style() +LimeReport::BaseDesignIntf::BorderStyle BorderEditor::borderStyle() { - return (LimeReport::BaseDesignIntf::BorderStyle)borderStyle; + return (LimeReport::BaseDesignIntf::BorderStyle) m_borderStyle; } -QString lrbordereditor::borderColor() +QString BorderEditor::borderColor() { - return border_color; + return m_borderColor; } -double lrbordereditor::border_width() +double BorderEditor::borderWidth() { - return borderWidth; + return m_borderWidth; } -lrbordereditor::~lrbordereditor() +BorderEditor::~BorderEditor() { delete ui; } -void lrbordereditor::on_listWidget_currentRowChanged(int currentRow) +void BorderEditor::on_listWidget_currentRowChanged(int currentRow) { QPen pen = ui->borderFrame->pen(); pen.setStyle((Qt::PenStyle)currentRow); - borderStyle = currentRow; + m_borderStyle = currentRow; ui->borderFrame->setPen(pen); - - } - -void lrbordereditor::on_comboBox_currentTextChanged(const QString &arg1) +void BorderEditor::on_comboBox_currentTextChanged(const QString &arg1) { QPen pen = ui->borderFrame->pen(); pen.setWidthF(arg1.toDouble()); ui->borderFrame->setPen(pen); - borderWidth = arg1.toDouble(); + m_borderWidth = arg1.toDouble(); } - -void lrbordereditor::on_pushButton_clicked() +void BorderEditor::checkToolButtons(LimeReport::BaseDesignIntf::BorderSide side, bool check) { - QColorDialog cd(this); - if(cd.exec() == QDialog::Rejected)return; - QPen pen = ui->borderFrame->pen(); - pen.setColor(cd.selectedColor().name()); - border_color = pen.color().name(); - - ui->pushButton->setStyleSheet(QString("#pushButton{background-color:%1;}").arg(border_color)); - ui->borderFrame->setPen(pen); -} - - -void lrbordereditor::on_toolButton_4_clicked() -{ - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine,true); - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,true); - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,true); - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,true); - QPen pen = ui->borderFrame->pen(); - - ui->borderFrame->setPen(pen); -} - - -void lrbordereditor::on_noLines_clicked() -{ - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine,false); - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,false); - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,false); - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,false); - -} - - -void lrbordereditor::on_topLine_clicked() -{ - - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine,ui->topLine->isChecked()); - -} - -void lrbordereditor::checkToolButtons(int side, bool check) -{ - switch(side) { - case LimeReport::BaseDesignIntf::BorderSide::TopLine: - { - ui->topLine->setChecked(check); - }break; - case LimeReport::BaseDesignIntf::BorderSide::BottomLine: - { - ui->bottomLine->setChecked(check); - }break; - case LimeReport::BaseDesignIntf::BorderSide::LeftLine: - { - ui->leftLine->setChecked(check); - }break; - case LimeReport::BaseDesignIntf::BorderSide::RightLine: - { - ui->rightLine->setChecked(check); - }break; + case BaseDesignIntf::BorderSide::TopLine: + ui->topLine->setChecked(check); + break; + case BaseDesignIntf::BorderSide::BottomLine: + ui->bottomLine->setChecked(check); + break; + case BaseDesignIntf::BorderSide::LeftLine: + ui->leftLine->setChecked(check); + break; + case BaseDesignIntf::BorderSide::RightLine: + ui->rightLine->setChecked(check); + break; } } +void BorderEditor::on_topLine_clicked(bool checked){ + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, checked); +} -void lrbordereditor::on_bottomLine_clicked() -{ - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,ui->bottomLine->isChecked()); +void BorderEditor::on_bottomLine_clicked(bool checked){ + emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::BottomLine, checked); +} + +void BorderEditor::on_leftLine_clicked(bool checked){ + emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::LeftLine, checked); +} + +void BorderEditor::on_rightLine_clicked(bool checked){ + emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::RightLine, checked); } -void lrbordereditor::on_leftLine_clicked() +void BorderEditor::on_allLines_clicked() { - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,ui->leftLine->isChecked()); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, true); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine, true); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine, true); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine, true); +} + +void BorderEditor::on_noLines_clicked() +{ + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, false); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine, false); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine, false); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine, false); } -void lrbordereditor::on_toolButton_3_clicked() +void BorderEditor::on_selectColor_clicked() { - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,ui->rightLine->isChecked()); + QColorDialog cd(this); + if(cd.exec() == QDialog::Rejected) return; + QPen pen = ui->borderFrame->pen(); + pen.setColor(cd.selectedColor().name()); + m_borderColor = pen.color().name(); + ui->colorIndicator->setStyleSheet(QString("background-color:%1;").arg(m_borderColor)); + ui->borderFrame->setPen(pen); } +} // namespace LimeReport diff --git a/limereport/items/lrbordereditor.h b/limereport/items/lrbordereditor.h index 5c2c9ba..443cb63 100644 --- a/limereport/items/lrbordereditor.h +++ b/limereport/items/lrbordereditor.h @@ -3,54 +3,45 @@ #include #include "lrbasedesignintf.h" +namespace LimeReport{ + namespace Ui { -class lrbordereditor; +class BorderEditor; } -class lrbordereditor : public QDialog +class BorderEditor : public QDialog { Q_OBJECT public: - explicit lrbordereditor(QWidget *parent = nullptr); - void loadItem(LimeReport::BaseDesignIntf *i); + explicit BorderEditor(QWidget *parent = nullptr); + void loadItem(LimeReport::BaseDesignIntf *item); LimeReport::BaseDesignIntf::BorderLines borderSides(); - LimeReport::BaseDesignIntf::BorderStyle border_style(); + LimeReport::BaseDesignIntf::BorderStyle borderStyle(); QString borderColor(); - double border_width(); - - - ~lrbordereditor(); + double borderWidth(); + ~BorderEditor(); private slots: void on_listWidget_currentRowChanged(int currentRow); - void on_comboBox_currentTextChanged(const QString &arg1); - - void on_pushButton_clicked(); - - void on_toolButton_4_clicked(); - void on_noLines_clicked(); - - void on_topLine_clicked(); - void checkToolButtons(int side, bool check); - - void on_bottomLine_clicked(); - - void on_leftLine_clicked(); - - void on_toolButton_3_clicked(); + void on_topLine_clicked(bool checked); + void on_bottomLine_clicked(bool checked); + void on_leftLine_clicked(bool checked); + void on_rightLine_clicked(bool checked); + void on_allLines_clicked(); + void checkToolButtons(LimeReport::BaseDesignIntf::BorderSide side, bool check); + void on_selectColor_clicked(); private: - Ui::lrbordereditor *ui; - LimeReport::BaseDesignIntf *item; - QString border_color; - int borderStyle = 1; - double borderWidth = 1; - - + Ui::BorderEditor *ui; + LimeReport::BaseDesignIntf *m_item; + QString m_borderColor; + int m_borderStyle; + double m_borderWidth; }; +} // namespace LimeReport #endif // LRBORDEREDITOR_H diff --git a/limereport/items/lrbordereditor.ui b/limereport/items/lrbordereditor.ui index 7cd7a39..00c4108 100644 --- a/limereport/items/lrbordereditor.ui +++ b/limereport/items/lrbordereditor.ui @@ -1,13 +1,13 @@ - lrbordereditor - + LimeReport::BorderEditor + 0 0 381 - 311 + 352 @@ -46,7 +46,7 @@ - + Outline @@ -119,7 +119,7 @@ - + @@ -319,14 +319,34 @@ - - - #pushButton{background-color: black;} - - - Select... - - + + + + + + 20 + 20 + + + + + 10 + 10 + + + + background-color: rgb(0, 0, 0); + + + + + + + Select + + + + @@ -342,7 +362,7 @@ - BorderFrameEditor + LimeReport::BorderFrameEditor QWidget
borderframeeditor.h
1 @@ -356,32 +376,32 @@ buttonBox accepted() - lrbordereditor + LimeReport::BorderEditor accept() - 253 - 255 + 119 + 322 - 219 - 275 + 377 + 309 buttonBox rejected() - lrbordereditor + LimeReport::BorderEditor reject() - 316 - 258 + 48 + 334 - 345 - 277 + 66 + 348 diff --git a/limereport/items/lrborderframeeditor.cpp b/limereport/items/lrborderframeeditor.cpp new file mode 100644 index 0000000..46fd9b9 --- /dev/null +++ b/limereport/items/lrborderframeeditor.cpp @@ -0,0 +1,181 @@ +#include "lrborderframeeditor.h" +#include "ui_lrborderframeeditor.h" +#include +#include +#include +#include +#include "lrbasedesignintf.h" +#include "lrbordereditor.h" + +namespace LimeReport{ + +BorderFrameEditor::BorderFrameEditor(QWidget *parent) + : QWidget(parent) + , ui(new Ui::BorderFrameEditor) +{ + ui->setupUi(this); + scene = new QGraphicsScene(ui->graphicsView); + + QRect vRect = rect(); + + //Draw corder lines + //topLeft + scene->addLine(10, 5, 10, 10, QPen(Qt::gray)); + scene->addLine(5, 10, 10, 10, QPen(Qt::gray)); + //bottomLeft + scene->addLine(10,vRect.bottom() -5, 10, vRect.bottom()-10, QPen(Qt::gray)); + scene->addLine(5,vRect.bottom()-10, 10, vRect.bottom()-10, QPen(Qt::gray)); + //bottomRight + scene->addLine(vRect.right() - 10, vRect.bottom() - 5, vRect.right()- 10, vRect.bottom() - 10, QPen(Qt::gray)); + scene->addLine(vRect.right() - 5, vRect.bottom() - 10, vRect.right() - 10, vRect.bottom() - 10, QPen(Qt::gray)); + //topRight + scene->addLine(vRect.width() - 10, 5, vRect.width() - 10, 10, QPen(Qt::gray)); + scene->addLine(vRect.width() - 5, 10, vRect.width() - 10, 10, QPen(Qt::gray)); + scene->setSceneRect(vRect); + ui->graphicsView->setScene(scene); + QGraphicsSimpleTextItem * io = new QGraphicsSimpleTextItem(); + io->setAcceptedMouseButtons(Qt::LeftButton); + io->setPos(scene->sceneRect().center()); + io->setText(tr("Text")); + scene->addItem(io); + + QRectF bR = io->sceneBoundingRect(); + io->setPos( scene->sceneRect().center().x() - bR.width()/2, scene->sceneRect().center().y() - bR.height()/2 ); + connect( + this, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)), + this, SLOT(slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)) + ); + +} + +BorderFrameEditor::~BorderFrameEditor() +{ + delete ui; +} + +void BorderFrameEditor::setPen(QPen pen) +{ + m_pen = pen; + updateBorders(); +} + +QPen BorderFrameEditor::pen() +{ + return m_pen; +} + +void BorderFrameEditor::setAllLines() +{ + if (!topLine) + topLine = createSideLine(LimeReport::BaseDesignIntf::BorderSide::TopLine); + if (!leftLine) + leftLine = createSideLine(LimeReport::BaseDesignIntf::BorderSide::LeftLine); + if (!bottomLine) + bottomLine = createSideLine(LimeReport::BaseDesignIntf::BorderSide::BottomLine); + if (!rightLine) + rightLine = createSideLine(LimeReport::BaseDesignIntf::BorderSide::RightLine); +} + +void BorderFrameEditor::unSetAllLines() +{ + if (topLine){ + scene->removeItem(topLine); + topLine = NULL; + } + if (leftLine){ + scene->removeItem(leftLine); + leftLine = NULL; + } + if (bottomLine){ + scene->removeItem(bottomLine); + bottomLine = NULL; + } + if (rightLine){ + scene->removeItem(rightLine); + rightLine = NULL; + } + +} + +void BorderFrameEditor::mousePressEvent(QMouseEvent *event) +{ + if (event->x() >= 10 && event->y() <30) + emit borderSideClicked(BaseDesignIntf::BorderSide::TopLine, !topLine); + + if ((event->x() >= 10 && event->x() < 30) && (event->y() > 10)) + emit borderSideClicked(BaseDesignIntf::BorderSide::LeftLine, !leftLine); + + if (event->x() >= 10 && (event->y() >80 && event->y() < rect().bottom())) + emit borderSideClicked(BaseDesignIntf::BorderSide::BottomLine, !bottomLine); + + if ((event->x() >= 130 && event->x() < rect().width()) && event->y() > 10) + emit borderSideClicked(BaseDesignIntf::BorderSide::RightLine, !rightLine); +} + +void BorderFrameEditor::slotBorderSideClicked(BaseDesignIntf::BorderSide side, bool show) +{ + + switch(side){ + + case BaseDesignIntf::BorderSide::TopLine: + if (show){ + if (!topLine) topLine = createSideLine(side); + } else { + if (topLine) scene->removeItem(topLine); + topLine = NULL; + } + break; + + case BaseDesignIntf::LeftLine: + if (show){ + if (!leftLine) leftLine = createSideLine(side); + } else { + if (leftLine) scene->removeItem(leftLine); + leftLine = NULL; + } + break; + + case BaseDesignIntf::BottomLine: + if (show){ + if (!bottomLine) bottomLine = createSideLine(side); + } else { + if (bottomLine) scene->removeItem(bottomLine); + bottomLine = NULL; + } + break; + + case BaseDesignIntf::RightLine: + if (show){ + if (!rightLine) rightLine = createSideLine(side); + } else { + if(rightLine) scene->removeItem(rightLine); + rightLine = NULL; + } + + } + updateBorders(); +} + +QGraphicsLineItem *BorderFrameEditor::createSideLine(LimeReport::BaseDesignIntf::BorderSide side) +{ + switch(side){ + case BaseDesignIntf::BorderSide::TopLine: + return scene->addLine(QLineF(10, 10, rect().width() - 10, 10), m_pen); + case BaseDesignIntf::BorderSide::LeftLine: + return scene->addLine(QLineF(10, 10, 10, rect().height() - 10), m_pen); + case BaseDesignIntf::BorderSide::RightLine: + return scene->addLine(QLineF(rect().width() - 10, 10 ,rect().width() - 10, rect().height() - 10), m_pen); + case BaseDesignIntf::BorderSide::BottomLine: + return scene->addLine(QLineF(10, rect().bottom() - 10, rect().width() - 10, rect().bottom() - 10), m_pen); + } +} + +void BorderFrameEditor::updateBorders() +{ + if (topLine) topLine->setPen(m_pen); + if (leftLine) leftLine->setPen(m_pen); + if (bottomLine) bottomLine->setPen(m_pen); + if (rightLine) rightLine->setPen(m_pen); +} + +} //namespace LimeReport diff --git a/limereport/items/borderframeeditor.h b/limereport/items/lrborderframeeditor.h similarity index 61% rename from limereport/items/borderframeeditor.h rename to limereport/items/lrborderframeeditor.h index f0beae8..9333677 100644 --- a/limereport/items/borderframeeditor.h +++ b/limereport/items/lrborderframeeditor.h @@ -5,9 +5,9 @@ #include #include #include "lrbasedesignintf.h" -QT_BEGIN_NAMESPACE +namespace LimeReport{ + namespace Ui { class BorderFrameEditor; } -QT_END_NAMESPACE class BorderFrameEditor : public QWidget { @@ -23,20 +23,24 @@ public: protected: void mousePressEvent(QMouseEvent *event); signals: - void borderSideClicked(int side,bool show); + void borderSideClicked(LimeReport::BaseDesignIntf::BorderSide side, bool show); private slots: - void SlotBorderSideClicked(int side, bool show); + void slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide side, bool show); +private: + QGraphicsLineItem *createSideLine(LimeReport::BaseDesignIntf::BorderSide side); + void updateBorders(); private: Ui::BorderFrameEditor *ui; - QGraphicsScene *scene; - QGraphicsLineItem *topLine = NULL + QGraphicsScene *scene; + QGraphicsLineItem *topLine = NULL ,*bottomLine = NULL ,*leftLine = NULL ,*rightLine = NULL; - QPen m_pen; - void updateBorders(); + QPen m_pen; + }; +} // namespace LimeReport #endif // WIDGET diff --git a/limereport/items/borderframeeditor.ui b/limereport/items/lrborderframeeditor.ui similarity index 94% rename from limereport/items/borderframeeditor.ui rename to limereport/items/lrborderframeeditor.ui index 3324d90..3f70f12 100644 --- a/limereport/items/borderframeeditor.ui +++ b/limereport/items/lrborderframeeditor.ui @@ -1,7 +1,7 @@ - BorderFrameEditor - + LimeReport::BorderFrameEditor + 0 diff --git a/limereport/items/lrpageeditor.cpp b/limereport/items/lrpageeditor.cpp index d0c2f46..6f4c4e3 100644 --- a/limereport/items/lrpageeditor.cpp +++ b/limereport/items/lrpageeditor.cpp @@ -1,9 +1,11 @@ #include "lrpageeditor.h" #include "ui_lrpageeditor.h" #include "lrpagedesignintf.h" +#include "lrpageitemdesignintf.h" #include #include -lrpageeditor::lrpageeditor(QWidget *parent, LimeReport::PageItemDesignIntf *page) : + +PageEditor::PageEditor(QWidget *parent, LimeReport::PageItemDesignIntf *page) : QDialog(parent), ui(new Ui::lrpageeditor) { @@ -16,8 +18,8 @@ lrpageeditor::lrpageeditor(QWidget *parent, LimeReport::PageItemDesignIntf *page ui->format->addItem(pageSizes.key(i)); } ui->format->setCurrentIndex(m_page->pageSize()); - ui->width->setValue(m_page->width() / LimeReport::Const::mmFACTOR); - ui->height->setValue(m_page->height() / LimeReport::Const::mmFACTOR); + ui->width->setValue(m_page->width() / m_page->unitFactor()); + ui->height->setValue(m_page->height() / m_page->unitFactor()); ui->portrait->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Portrait); ui->landscape->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Landscape); //Margins @@ -33,18 +35,17 @@ lrpageeditor::lrpageeditor(QWidget *parent, LimeReport::PageItemDesignIntf *page ui->fullPage->setChecked(m_page->fullPage()); } -lrpageeditor::~lrpageeditor() +PageEditor::~PageEditor() { delete ui; } -void lrpageeditor::applyChanges() +void PageEditor::applyChanges() { m_page->setPageSize(static_cast(ui->format->currentIndex())); - m_page->setWidth(ui->width->value()* LimeReport::Const::mmFACTOR); - m_page->setHeight(ui->height->value()* LimeReport::Const::mmFACTOR); - m_page->setPageOrientation(ui->portrait->isChecked()?LimeReport::PageItemDesignIntf::Portrait : LimeReport::PageItemDesignIntf::Landscape); - + m_page->setWidth(ui->width->value() * LimeReport::Const::mmFACTOR); + m_page->setHeight(ui->height->value() * LimeReport::Const::mmFACTOR); + m_page->setPageOrientation(ui->portrait->isChecked()? LimeReport::PageItemDesignIntf::Portrait : LimeReport::PageItemDesignIntf::Landscape); m_page->setTopMargin(ui->marginTop->value()); m_page->setBottomMargin(ui->marginBottom->value()); m_page->setRightMargin(ui->marginRight->value()); @@ -52,53 +53,55 @@ void lrpageeditor::applyChanges() m_page->setDropPrinterMargins(ui->dropPrinterMargins->isChecked()); ui->endlessHeight->setChecked(ui->endlessHeight->isChecked()); m_page->setExtendedHeight(ui->extendedHeight->value()); + ui->width->setValue(m_page->getItemWidth()); + ui->height->setValue(m_page->getItemHeight()); } -void lrpageeditor::on_buttonBox_accepted() -{ - applyChanges(); - accept(); - -} - -QSizeF lrpageeditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageSize& size) +QSizeF PageEditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageSize& size) { if (size != LimeReport::PageItemDesignIntf::Custom) { QPrinter printer; printer.setOutputFormat(QPrinter::PdfFormat); #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) - printer.setOrientation(ui->portrait->isChecked()?QPrinter::Portrait : QPrinter::Landscape); + printer.setOrientation(ui->portrait->isChecked() ? QPrinter::Portrait : QPrinter::Landscape); printer.setPaperSize((QPrinter::PageSize)size); - return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * 10, - printer.paperSize(QPrinter::Millimeter).height() * 10); + return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * m_page->unitFactor(), + printer.paperSize(QPrinter::Millimeter).height() * m_page->unitFactor()); #else - QPageSize pageSize = QPageSize((QPageSize::PageSizeId)size); - qreal width = pageSize.size(QPageSize::Millimeter).width() * 10; - qreal height = pageSize.size(QPageSize::Millimeter).height() * 10; - return QSizeF(pageOrientation() == Portrait ? width : height, - pageOrientation() == Portrait ? height : width); - -// printer.setPageOrientation((QPageLayout::Orientation)pageOrientation()); -// printer.setPageSize(QPageSize((QPageSize::PageSizeId)size)); -// return QSizeF(printer.pageLayout().pageSize().size(QPageSize::Millimeter).width() * 10, -// printer.pageLayout().pageSize().size(QPageSize::Millimeter).height() * 10); + printer.setPageOrientation((QPageLayout::Orientation)m_page->pageOrientation()); + printer.setPageSize(QPageSize((QPageSize::PageSizeId)size)); + return QSizeF(printer.pageLayout().pageSize().size(QPageSize::Millimeter).width() * m_page->unitFactor(), + printer.pageLayout().pageSize().size(QPageSize::Millimeter).height() * m_page->unitFactor()); #endif - } - - else { - return QSizeF(width(),height()); + } else { + return QSizeF(m_page->getItemWidth(), m_page->getItemHeight()); } } -void lrpageeditor::on_format_currentIndexChanged(int index) +void PageEditor::on_format_currentIndexChanged(int index) { QPageSize ps = *new QPageSize(); if(ui->format->currentText() != "Custom") { QSizeF pageSize = getRectByPageSize(static_cast(index)); - ui->width->setValue(pageSize.width()/10); - ui->height->setValue(pageSize.height()/10); + ui->width->setValue(pageSize.width() / m_page->unitFactor()); + ui->height->setValue(pageSize.height() / m_page->unitFactor()); } } + +void PageEditor::on_buttonBox_clicked(QAbstractButton *button) +{ + switch(ui->buttonBox->buttonRole(button)){ + case QDialogButtonBox::ApplyRole: + applyChanges(); + break; + case QDialogButtonBox::AcceptRole: + applyChanges(); + accept(); + } + + +} + diff --git a/limereport/items/lrpageeditor.h b/limereport/items/lrpageeditor.h index 545ca3e..1adf97b 100644 --- a/limereport/items/lrpageeditor.h +++ b/limereport/items/lrpageeditor.h @@ -8,17 +8,18 @@ namespace Ui { class lrpageeditor; } -class lrpageeditor : public QDialog +class PageEditor : public QDialog { Q_OBJECT public: - explicit lrpageeditor(QWidget *parent = nullptr,LimeReport::PageItemDesignIntf *page = nullptr); - ~lrpageeditor(); + explicit PageEditor(QWidget *parent = nullptr,LimeReport::PageItemDesignIntf *page = nullptr); + ~PageEditor(); private slots: - void on_buttonBox_accepted(); +// void on_buttonBox_accepted(); void on_format_currentIndexChanged(int index); + void on_buttonBox_clicked(QAbstractButton *button); private: Ui::lrpageeditor *ui; diff --git a/limereport/items/lrpageeditor.ui b/limereport/items/lrpageeditor.ui index 70ca440..af2f735 100644 --- a/limereport/items/lrpageeditor.ui +++ b/limereport/items/lrpageeditor.ui @@ -7,7 +7,7 @@ 0 0 306 - 322 + 350 @@ -297,7 +297,7 @@ Qt::Horizontal - QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Ok @@ -312,8 +312,8 @@ reject() - 325 - 312 + 296 + 340 286 @@ -328,12 +328,12 @@ setEnabled(bool) - 60 - 50 + 72 + 81 - 130 - 85 + 131 + 134 diff --git a/limereport/limereport.pri b/limereport/limereport.pri index 524d3d8..c86b575 100644 --- a/limereport/limereport.pri +++ b/limereport/limereport.pri @@ -80,7 +80,7 @@ SOURCES += \ $$REPORT_PATH/lraxisdata.cpp \ $$REPORT_PATH/lrpreparedpages.cpp \ $$REPORT_PATH/items/lrpageeditor.cpp \ - $$REPORT_PATH/items/borderframeeditor.cpp \ + $$REPORT_PATH/items/lrborderframeeditor.cpp \ $$REPORT_PATH/items/lrbordereditor.cpp CONFIG(staticlib) { @@ -181,7 +181,7 @@ HEADERS += \ $$REPORT_PATH/lraxisdata.h \ $$REPORT_PATH/lrpreparedpagesintf.h \ $$REPORT_PATH/items/lrpageeditor.h \ - $$REPORT_PATH/items/borderframeeditor.h \ + $$REPORT_PATH/items/lrborderframeeditor.h \ $$REPORT_PATH/items/lrbordereditor.h CONFIG(staticlib) { @@ -207,7 +207,7 @@ FORMS += \ $$REPORT_PATH/items/lrimageitemeditor.ui \ $$REPORT_PATH/scripteditor/lrscripteditor.ui \ $$REPORT_PATH/items/lrpageeditor.ui \ - $$REPORT_PATH/items/borderframeeditor.ui \ + $$REPORT_PATH/items/lrborderframeeditor.ui \ $$REPORT_PATH/items/lrbordereditor.ui RESOURCES += \ diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index d31165f..d66efeb 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -431,7 +431,7 @@ void BaseDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o setupPainter(ppainter); drawBorder(ppainter, rect()); if(m_shadow) - drawShadow(ppainter, rect()); + drawShadow(ppainter, rect(), 6); // if (m_joinMarkerOn) { drawMarker(ppainter, Const::JOIN_COLOR);} // if (isSelected() && !m_joinMarkerOn) {drawMarker(ppainter, Const::SELECTION_COLOR);} drawResizeZone(ppainter); @@ -1145,10 +1145,9 @@ void BaseDesignIntf::drawBorder(QPainter *painter, QRectF rect) const painter->restore(); } -void BaseDesignIntf::drawShadow(QPainter *painter, QRectF rect) const +void BaseDesignIntf::drawShadow(QPainter *painter, QRectF rect, qreal shadowSize) const { - - qreal shWidth = rect.width()/100; + qreal shWidth = shadowSize; QRectF rshadow(rect.topRight() + QPointF(0, shWidth), rect.bottomRight() + QPointF(shWidth, 0)); QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight()); @@ -1167,8 +1166,6 @@ void BaseDesignIntf::drawShadow(QPainter *painter, QRectF rect) const cgrad.setColorAt(0.0, QColor(0,0,0,255)); cgrad.setColorAt(1.0, QColor(0,0,0,0)); painter->fillRect(cshadow, QBrush(cgrad)); - - } void BaseDesignIntf::setGeometry(QRectF rect) @@ -1486,7 +1483,7 @@ void BaseDesignIntf::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) menu.addSeparator(); QAction* noBordersAction = menu.addAction(QIcon(":/report/images/noLines"), tr("No borders")); QAction* allBordersAction = menu.addAction(QIcon(":/report/images/allLines"), tr("All borders")); - QAction* editBorderAction = menu.addAction(QIcon(":/report/images/allLines"), tr("Edit borders...")); + QAction* editBorderAction = menu.addAction(QIcon(":/report/images/borderEditor"), tr("Edit borders...")); preparePopUpMenu(menu); QAction* a = menu.exec(event->screenPos()); if (a){ @@ -1507,15 +1504,12 @@ void BaseDesignIntf::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) page->setBorders(BaseDesignIntf::NoLine); if (a == allBordersAction) page->setBorders(BaseDesignIntf::AllLines); - if(a == editBorderAction) + if (a == editBorderAction) { - lrbordereditor be; + BorderEditor be; be.loadItem(this); - if(be.exec() == QDialog::Rejected)return; - setBorderLinesFlags(be.borderSides()); - setBorderLineSize(be.border_width()); - setBorderStyle((LimeReport::BaseDesignIntf::BorderStyle)be.border_style()); - setBorderColor(be.borderColor()); + if (be.exec() == QDialog::Rejected) return; + page->setBordersExt(be.borderSides(), be.borderWidth(), (LimeReport::BaseDesignIntf::BorderStyle)be.borderStyle(), be.borderColor()); } if (a == createHLayout) page->addHLayout(); diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index adf7d21..89f68d2 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -389,7 +389,7 @@ protected: void drawBorder(QPainter* painter, QRectF rect) const; - void drawShadow(QPainter* painter, QRectF rect) const; + void drawShadow(QPainter* painter, QRectF rect, qreal shadowSize) const; void drawDesignModeBorder(QPainter* painter, QRectF rect) const; void drawRenderModeBorder(QPainter *painter, QRectF rect) const; void drawResizeZone(QPainter*); diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 55907b4..bd0e583 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -1826,6 +1826,20 @@ void PageDesignIntf::setBorders(const BaseDesignIntf::BorderLines& border) changeSelectedGroupProperty("borders", (int)border); } +void PageDesignIntf::setBordersExt( + const BaseDesignIntf::BorderLines& border, + const double borderWidth, + const LimeReport::BaseDesignIntf::BorderStyle style, + const QString color + +) +{ + changeSelectedGroupProperty("borders", (int)border); + changeSelectedGroupProperty("borderLineSize", borderWidth); + changeSelectedGroupProperty("borderStyle", style); + changeSelectedGroupProperty("borderColor", color); +} + void PageDesignIntf::lockSelectedItems() { foreach(QGraphicsItem* graphicItem, selectedItems()){ diff --git a/limereport/lrpagedesignintf.h b/limereport/lrpagedesignintf.h index 0a49b4d..c64b501 100644 --- a/limereport/lrpagedesignintf.h +++ b/limereport/lrpagedesignintf.h @@ -254,6 +254,11 @@ namespace LimeReport { void setFont(const QFont &font); void setTextAlign(const Qt::Alignment& alignment); void setBorders(const BaseDesignIntf::BorderLines& border); + void setBordersExt(const BaseDesignIntf::BorderLines &border, + const double borderWidth, + const BaseDesignIntf::BorderStyle style, + const QString color + ); void lockSelectedItems(); void unlockSelectedItems(); void selectOneLevelItems(); diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index 0311707..57f05ae 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -98,38 +98,10 @@ void PageItemDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsIte paintGrid(ppainter, rect); ppainter->setPen(gridColor()); ppainter->drawRect(boundingRect()); - //Draw shadow - qreal shWidth = boundingRect().width()/100; - QRectF rshadow(boundingRect().topRight() + QPointF(0, shWidth), - boundingRect().bottomRight() + QPointF(shWidth, 0)); - QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight()); - rgrad.setColorAt(0.0, QColor(0,0,0,255)); - rgrad.setColorAt(1.0, QColor(0,0,0,0)); - ppainter->fillRect(rshadow, QBrush(rgrad)); - QRectF bshadow(boundingRect().bottomLeft() + QPointF(shWidth, 0), - boundingRect().bottomRight() + QPointF(0, shWidth)); - QLinearGradient bgrad(bshadow.topLeft(), bshadow.bottomLeft()); - bgrad.setColorAt(0.0, QColor(0,0,0,255)); - bgrad.setColorAt(1.0, QColor(0,0,0,0)); - ppainter->fillRect(bshadow, QBrush(bgrad)); - QRectF cshadow(boundingRect().bottomRight(), - boundingRect().bottomRight() + QPointF(shWidth, shWidth)); - QRadialGradient cgrad(cshadow.topLeft(), shWidth, cshadow.topLeft()); - cgrad.setColorAt(0.0, QColor(0,0,0,255)); - cgrad.setColorAt(1.0, QColor(0,0,0,0)); - ppainter->fillRect(cshadow, QBrush(cgrad)); - if (m_isExtendedInDesignMode){ - QPen pen; - pen.setColor(Qt::red); - pen.setStyle(Qt::DashLine); - pen.setWidth(2); - ppainter->setPen(pen); - ppainter->drawLine(pageRect().bottomLeft(),pageRect().bottomRight()); - } + drawShadow(ppainter, boundingRect(), 10); ppainter->restore(); } - if (itemMode() & PreviewMode) { ppainter->save(); ppainter->fillRect(rect(), Qt::white); @@ -145,8 +117,6 @@ void PageItemDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsIte BaseDesignIntf::paint(ppainter,option,widget); } - - } BaseDesignIntf *PageItemDesignIntf::createSameTypeItem(QObject *owner, QGraphicsItem *parent) @@ -828,7 +798,7 @@ void PageItemDesignIntf::processPopUpAction(QAction *action) } if(action->text() == tr("Edit")) { - lrpageeditor pageEdit(NULL,this); + PageEditor pageEdit(NULL,this); pageEdit.exec(); } diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index 19c3a3e..58570bc 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -704,6 +704,16 @@ void ReportDesignWidget::setBorders(const BaseDesignIntf::BorderLines& borders) activePage()->setBorders(borders); } +void ReportDesignWidget::setBordersExt( + const BaseDesignIntf::BorderLines& border, + const double borderWidth, + const LimeReport::BaseDesignIntf::BorderStyle style, + const QString color +){ + if (activePage()) + activePage()->setBordersExt(border, borderWidth, style, color); +} + void ReportDesignWidget::prepareReport() { m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h index 8057f13..9a5a68a 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -194,6 +194,8 @@ public slots: void setFont(const QFont &font); void setTextAlign(const bool &horizontalAlign, const Qt::AlignmentFlag &alignment); void setBorders(const BaseDesignIntf::BorderLines& borders); + void setBordersExt(const BaseDesignIntf::BorderLines &border, const double borderWidth, + const LimeReport::BaseDesignIntf::BorderStyle style, const QString color); void editSetting(); void setUseGrid(bool value); void previewReport(); diff --git a/limereport/report.qrc b/limereport/report.qrc index 89999d9..dc59710 100644 --- a/limereport/report.qrc +++ b/limereport/report.qrc @@ -186,5 +186,6 @@ images/designer.png images/lock.png images/unlock.png + images/border_settings.png