Borders editor dialog added

This commit is contained in:
yanis60
2022-06-13 19:18:57 +01:00
parent 83da159284
commit 8a2d824c5d
25 changed files with 3036 additions and 78 deletions

View File

@@ -0,0 +1,287 @@
#include "borderframeeditor.h"
#include "ui_borderframeeditor.h"
#include <QPainter>
#include <QGraphicsLineItem>
#include <QDebug>
#include <QMouseEvent>
#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);
}
}

View File

@@ -0,0 +1,42 @@
#ifndef WIDGET
#define WIDGET
#include <QWidget>
#include <QGraphicsScene>
#include <QGraphicsLineItem>
#include "lrbasedesignintf.h"
QT_BEGIN_NAMESPACE
namespace Ui { class BorderFrameEditor; }
QT_END_NAMESPACE
class BorderFrameEditor : public QWidget
{
Q_OBJECT
public:
BorderFrameEditor(QWidget *parent = nullptr);
~BorderFrameEditor();
void setPen(QPen pen);
QPen pen();
void setAllLines();
void unSetAllLines();
protected:
void mousePressEvent(QMouseEvent *event);
signals:
void borderSideClicked(int side,bool show);
private slots:
void SlotBorderSideClicked(int side, bool show);
private:
Ui::BorderFrameEditor *ui;
QGraphicsScene *scene;
QGraphicsLineItem *topLine = NULL
,*bottomLine = NULL
,*leftLine = NULL
,*rightLine = NULL;
QPen m_pen;
void updateBorders();
};
#endif // WIDGET

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BorderFrameEditor</class>
<widget class="QWidget" name="BorderFrameEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>150</width>
<height>100</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>BorderFrameEditor</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGraphicsView" name="graphicsView">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>100</height>
</size>
</property>
<property name="baseSize">
<size>
<width>150</width>
<height>100</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="resizeAnchor">
<enum>QGraphicsView::AnchorViewCenter</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -29,7 +29,7 @@
****************************************************************************/
#include "lritemsborderseditorwidget.h"
#include <QAction>
#include "lrbordereditor.h"
namespace LimeReport{
void ItemsBordersEditorWidget::setItemEvent(BaseDesignIntf* item)
@@ -44,6 +44,7 @@ void ItemsBordersEditorWidget::setItemEvent(BaseDesignIntf* item)
updateValues((BaseDesignIntf::BorderLines)borders.toInt());
setEnabled(true);
}
itm = item;
}
void ItemsBordersEditorWidget::properyChangedEvent(const QString& property, const QVariant& oldValue, const QVariant& newValue)
@@ -76,6 +77,18 @@ void ItemsBordersEditorWidget::buttonClicked(bool)
}
void ItemsBordersEditorWidget::editBorderClicked()
{
lrbordereditor be;
be.loadItem(itm);
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());
}
void ItemsBordersEditorWidget::initEditor()
{
@@ -114,6 +127,11 @@ void ItemsBordersEditorWidget::initEditor()
m_allLines->setIcon(QIcon(":/report/images/allLines"));
connect(m_allLines,SIGNAL(triggered()),this,SLOT(allBordesClicked()));
addAction(m_allLines);
addSeparator();
m_BorderEditor = new QAction(tr("Edit border"),this);
m_BorderEditor->setIcon(QIcon(":/report/images/allLines"));
connect(m_BorderEditor,SIGNAL(triggered()),this,SLOT(editBorderClicked()));
addAction(m_BorderEditor);
setEnabled(false);

View File

@@ -49,6 +49,7 @@ protected slots:
virtual void noBordesClicked();
virtual void allBordesClicked();
virtual void buttonClicked(bool);
void editBorderClicked();
protected:
void setItemEvent(BaseDesignIntf *item);
void properyChangedEvent(const QString &property, const QVariant &oldValue, const QVariant &newValue);
@@ -62,8 +63,10 @@ private:
QAction* m_topLine;
QAction* m_bottomLine;
QAction* m_allLines;
QAction* m_BorderEditor;
bool m_changing;
int m_borders;
BaseDesignIntf *itm;
};
#ifdef HAVE_REPORT_DESIGNER
@@ -78,6 +81,7 @@ protected slots:
void allBordesClicked();
private:
ReportDesignWidget* m_reportEditor;
};
#endif

View File

@@ -0,0 +1,182 @@
#include "lrbordereditor.h"
#include "ui_lrbordereditor.h"
#include <QColorDialog>
#include "lrbasedesignintf.h"
lrbordereditor::lrbordereditor(QWidget *parent) :
QDialog(parent),
ui(new Ui::lrbordereditor)
{
ui->setupUi(this);
connect(ui->borderFrame,SIGNAL(borderSideClicked(int, bool)), this, SLOT(checkToolButtons(int, bool)));
}
void lrbordereditor::loadItem(LimeReport::BaseDesignIntf *i)
{
item = i;
if(item->borderLines() & LimeReport::BaseDesignIntf::TopLine)
{
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine,true);
}
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();
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));
}
LimeReport::BaseDesignIntf::BorderLines lrbordereditor::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;
}
LimeReport::BaseDesignIntf::BorderStyle lrbordereditor::border_style()
{
return (LimeReport::BaseDesignIntf::BorderStyle)borderStyle;
}
QString lrbordereditor::borderColor()
{
return border_color;
}
double lrbordereditor::border_width()
{
return borderWidth;
}
lrbordereditor::~lrbordereditor()
{
delete ui;
}
void lrbordereditor::on_listWidget_currentRowChanged(int currentRow)
{
QPen pen = ui->borderFrame->pen();
pen.setStyle((Qt::PenStyle)currentRow);
borderStyle = currentRow;
ui->borderFrame->setPen(pen);
}
void lrbordereditor::on_comboBox_currentTextChanged(const QString &arg1)
{
QPen pen = ui->borderFrame->pen();
pen.setWidthF(arg1.toDouble());
ui->borderFrame->setPen(pen);
borderWidth = arg1.toDouble();
}
void lrbordereditor::on_pushButton_clicked()
{
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;
}
}
void lrbordereditor::on_bottomLine_clicked()
{
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,ui->bottomLine->isChecked());
}
void lrbordereditor::on_leftLine_clicked()
{
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,ui->leftLine->isChecked());
}
void lrbordereditor::on_toolButton_3_clicked()
{
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,ui->rightLine->isChecked());
}

View File

@@ -0,0 +1,56 @@
#ifndef LRBORDEREDITOR_H
#define LRBORDEREDITOR_H
#include <QDialog>
#include "lrbasedesignintf.h"
namespace Ui {
class lrbordereditor;
}
class lrbordereditor : public QDialog
{
Q_OBJECT
public:
explicit lrbordereditor(QWidget *parent = nullptr);
void loadItem(LimeReport::BaseDesignIntf *i);
LimeReport::BaseDesignIntf::BorderLines borderSides();
LimeReport::BaseDesignIntf::BorderStyle border_style();
QString borderColor();
double border_width();
~lrbordereditor();
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();
private:
Ui::lrbordereditor *ui;
LimeReport::BaseDesignIntf *item;
QString border_color;
int borderStyle = 1;
double borderWidth = 1;
};
#endif // LRBORDEREDITOR_H

View File

@@ -0,0 +1,389 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>lrbordereditor</class>
<widget class="QDialog" name="lrbordereditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>381</width>
<height>311</height>
</rect>
</property>
<property name="windowTitle">
<string>Edit border</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Presets</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QToolButton" name="noLines">
<property name="text">
<string>No lines</string>
</property>
<property name="icon">
<iconset resource="../report.qrc">
<normaloff>:/report/images/noLines</normaloff>:/report/images/noLines</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_4">
<property name="text">
<string>Outline</string>
</property>
<property name="icon">
<iconset resource="../report.qrc">
<normaloff>:/report/images/allLines</normaloff>:/report/images/allLines</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Border</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="topLine">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../report.qrc">
<normaloff>:/report/images/topLine</normaloff>:/report/images/topLine</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="bottomLine">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../report.qrc">
<normaloff>:/report/images/bottomLine</normaloff>:/report/images/bottomLine</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="BorderFrameEditor" name="borderFrame" native="true"/>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="leftLine">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../report.qrc">
<normaloff>:/report/images/leftLine</normaloff>:/report/images/leftLine</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="rightLine">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../report.qrc">
<normaloff>:/report/images/rightLine</normaloff>:/report/images/rightLine</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="title">
<string>Style</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QListWidget" name="listWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>125</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<property name="currentRow">
<number>1</number>
</property>
<item>
<property name="text">
<string>No style</string>
</property>
</item>
<item>
<property name="text">
<string>Solid</string>
</property>
</item>
<item>
<property name="text">
<string>Dash</string>
</property>
</item>
<item>
<property name="text">
<string>Dot</string>
</property>
</item>
<item>
<property name="text">
<string>Dash dot</string>
</property>
</item>
<item>
<property name="text">
<string>Dash dot dot</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox">
<property name="editable">
<bool>true</bool>
</property>
<property name="currentText">
<string>1</string>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>0.25</string>
</property>
</item>
<item>
<property name="text">
<string>0.5</string>
</property>
</item>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>1.5</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>3</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>5</string>
</property>
</item>
<item>
<property name="text">
<string>6</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Color:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="styleSheet">
<string notr="true">#pushButton{background-color: black;}</string>
</property>
<property name="text">
<string>Select...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BorderFrameEditor</class>
<extends>QWidget</extends>
<header>borderframeeditor.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../report.qrc"/>
<include location="../report.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>lrbordereditor</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>253</x>
<y>255</y>
</hint>
<hint type="destinationlabel">
<x>219</x>
<y>275</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>lrbordereditor</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>258</y>
</hint>
<hint type="destinationlabel">
<x>345</x>
<y>277</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,104 @@
#include "lrpageeditor.h"
#include "ui_lrpageeditor.h"
#include "lrpagedesignintf.h"
#include <QPushButton>
#include <QPageSize>
lrpageeditor::lrpageeditor(QWidget *parent, LimeReport::PageItemDesignIntf *page) :
QDialog(parent),
ui(new Ui::lrpageeditor)
{
ui->setupUi(this);
m_page = page;
//Paper
QMetaEnum pageSizes = page->metaObject()->property(page->metaObject()->indexOfProperty("pageSize")).enumerator();
for (int i=0;i<pageSizes.keyCount();i++){
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->portrait->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Portrait);
ui->landscape->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Landscape);
//Margins
ui->marginTop->setValue(m_page->topMargin());
ui->marginRight->setValue(m_page->rightMargin());
ui->marginLeft->setValue(m_page->leftMargin());
ui->marginBottom->setValue(m_page->bottomMargin());
ui->dropPrinterMargins->setChecked(m_page->dropPrinterMargins());
//Other
ui->endlessHeight->setChecked(m_page->endlessHeight());
ui->extendedHeight->setValue(m_page->extendedHeight());
ui->fullPage->setChecked(m_page->fullPage());
}
lrpageeditor::~lrpageeditor()
{
delete ui;
}
void lrpageeditor::applyChanges()
{
m_page->setPageSize(static_cast<LimeReport::PageItemDesignIntf::PageSize>(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->setTopMargin(ui->marginTop->value());
m_page->setBottomMargin(ui->marginBottom->value());
m_page->setRightMargin(ui->marginRight->value());
m_page->setLeftMargin(ui->marginLeft->value());
m_page->setDropPrinterMargins(ui->dropPrinterMargins->isChecked());
ui->endlessHeight->setChecked(ui->endlessHeight->isChecked());
m_page->setExtendedHeight(ui->extendedHeight->value());
}
void lrpageeditor::on_buttonBox_accepted()
{
applyChanges();
accept();
}
QSizeF lrpageeditor::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.setPaperSize((QPrinter::PageSize)size);
return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * 10,
printer.paperSize(QPrinter::Millimeter).height() * 10);
#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);
#endif
}
else {
return QSizeF(width(),height());
}
}
void lrpageeditor::on_format_currentIndexChanged(int index)
{
QPageSize ps = *new QPageSize();
if(ui->format->currentText() != "Custom")
{
QSizeF pageSize = getRectByPageSize(static_cast<LimeReport::PageItemDesignIntf::PageSize>(index));
ui->width->setValue(pageSize.width()/10);
ui->height->setValue(pageSize.height()/10);
}
}

View File

@@ -0,0 +1,31 @@
#ifndef LRPAGEEDITOR_H
#define LRPAGEEDITOR_H
#include <QDialog>
#include "lrpageitemdesignintf.h"
#include <QPushButton>
namespace Ui {
class lrpageeditor;
}
class lrpageeditor : public QDialog
{
Q_OBJECT
public:
explicit lrpageeditor(QWidget *parent = nullptr,LimeReport::PageItemDesignIntf *page = nullptr);
~lrpageeditor();
private slots:
void on_buttonBox_accepted();
void on_format_currentIndexChanged(int index);
private:
Ui::lrpageeditor *ui;
LimeReport::PageItemDesignIntf* m_page;
void applyChanges();
QSizeF getRectByPageSize(const LimeReport::PageItemDesignIntf::PageSize& size);
};
#endif // LRPAGEEDITOR_H

View File

@@ -0,0 +1,341 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>lrpageeditor</class>
<widget class="QDialog" name="lrpageeditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>306</width>
<height>322</height>
</rect>
</property>
<property name="windowTitle">
<string>Page setup</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Paper</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Format</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="format"/>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Dimension</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="width">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="showGroupSeparator" stdset="0">
<bool>true</bool>
</property>
<property name="suffix">
<string> mm</string>
</property>
<property name="maximum">
<double>99999999999999991611392.000000000000000</double>
</property>
<property name="singleStep">
<double>10.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Height:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="height">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="showGroupSeparator" stdset="0">
<bool>true</bool>
</property>
<property name="suffix">
<string> mm</string>
</property>
<property name="maximum">
<double>99999999999999991611392.000000000000000</double>
</property>
<property name="singleStep">
<double>10.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Orientation</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QRadioButton" name="portrait">
<property name="text">
<string>Portrait</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="landscape">
<property name="text">
<string>Landscape</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Margins</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Bottom:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Top:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Right:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="marginTop">
<property name="suffix">
<string> mm</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="marginLeft">
<property name="suffix">
<string> mm</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QDoubleSpinBox" name="marginRight">
<property name="suffix">
<string> mm</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Left:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QDoubleSpinBox" name="marginBottom">
<property name="suffix">
<string> mm</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="4">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="QCheckBox" name="dropPrinterMargins">
<property name="text">
<string>Drop printer margins</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="4">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Other</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Height options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QCheckBox" name="endlessHeight">
<property name="text">
<string>Endless Height</string>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="horizontalFrame">
<property name="enabled">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Extended Height:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="extendedHeight">
<property name="maximum">
<double>99999999.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fullPage">
<property name="text">
<string>Full page</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>lrpageeditor</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>325</x>
<y>312</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>endlessHeight</sender>
<signal>clicked(bool)</signal>
<receiver>horizontalFrame</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>60</x>
<y>50</y>
</hint>
<hint type="destinationlabel">
<x>130</x>
<y>85</y>
</hint>
</hints>
</connection>
</connections>
</ui>