0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-25 00:54:39 +03:00
LimeReport/limereport/items/lrbordereditor.cpp

157 lines
5.6 KiB
C++
Raw Normal View History

2022-06-13 21:18:57 +03:00
#include "lrbordereditor.h"
#include "ui_lrbordereditor.h"
#include <QColorDialog>
#include "lrbasedesignintf.h"
2022-10-31 21:20:24 +03:00
namespace LimeReport{
BorderEditor::BorderEditor(QWidget *parent) :
2022-06-13 21:18:57 +03:00
QDialog(parent),
2022-10-31 21:20:24 +03:00
ui(new Ui::BorderEditor),
m_borderStyle(1),
m_borderWidth(1)
2022-06-13 21:18:57 +03:00
{
ui->setupUi(this);
2022-10-31 21:20:24 +03:00
connect(
ui->borderFrame, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)),
this, SLOT(checkToolButtons(LimeReport::BaseDesignIntf::BorderSide, bool))
);
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
void BorderEditor::loadItem(LimeReport::BaseDesignIntf *item)
2022-06-13 21:18:57 +03:00
{
2022-10-31 21:20:24 +03:00
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);
2022-06-13 21:18:57 +03:00
QPen pen;
pen.setWidthF(item->borderLineSize());
pen.setColor(item->borderColor());
pen.setStyle((Qt::PenStyle)item->borderStyle());
ui->borderFrame->setPen(pen);
2022-10-31 21:20:24 +03:00
m_borderColor = item->borderColor().name();
2022-06-13 21:18:57 +03:00
ui->listWidget->setCurrentRow((Qt::PenStyle)item->borderStyle());
ui->comboBox->setCurrentText(QString::number(item->borderLineSize()));
2022-10-31 21:20:24 +03:00
m_borderWidth = ui->comboBox->currentText().toDouble();
m_borderStyle =ui->listWidget->currentRow();
ui->colorIndicator->setStyleSheet(QString("background-color:%1;").arg(m_borderColor));
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
LimeReport::BaseDesignIntf::BorderLines BorderEditor::borderSides()
2022-06-13 21:18:57 +03:00
{
int borders = 0;
2022-10-31 21:20:24 +03:00
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;
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
LimeReport::BaseDesignIntf::BorderStyle BorderEditor::borderStyle()
2022-06-13 21:18:57 +03:00
{
2022-10-31 21:20:24 +03:00
return (LimeReport::BaseDesignIntf::BorderStyle) m_borderStyle;
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
QString BorderEditor::borderColor()
2022-06-13 21:18:57 +03:00
{
2022-10-31 21:20:24 +03:00
return m_borderColor;
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
double BorderEditor::borderWidth()
2022-06-13 21:18:57 +03:00
{
2022-10-31 21:20:24 +03:00
return m_borderWidth;
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
BorderEditor::~BorderEditor()
2022-06-13 21:18:57 +03:00
{
delete ui;
}
2022-10-31 21:20:24 +03:00
void BorderEditor::on_listWidget_currentRowChanged(int currentRow)
2022-06-13 21:18:57 +03:00
{
QPen pen = ui->borderFrame->pen();
pen.setStyle((Qt::PenStyle)currentRow);
2022-10-31 21:20:24 +03:00
m_borderStyle = currentRow;
2022-06-13 21:18:57 +03:00
ui->borderFrame->setPen(pen);
}
2022-10-31 21:20:24 +03:00
void BorderEditor::on_comboBox_currentTextChanged(const QString &arg1)
2022-06-13 21:18:57 +03:00
{
QPen pen = ui->borderFrame->pen();
pen.setWidthF(arg1.toDouble());
ui->borderFrame->setPen(pen);
2022-10-31 21:20:24 +03:00
m_borderWidth = arg1.toDouble();
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
void BorderEditor::checkToolButtons(LimeReport::BaseDesignIntf::BorderSide side, bool check)
2022-06-13 21:18:57 +03:00
{
2022-10-31 21:20:24 +03:00
switch(side)
{
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;
}
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
void BorderEditor::on_topLine_clicked(bool checked){
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, checked);
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
void BorderEditor::on_bottomLine_clicked(bool checked){
emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::BottomLine, checked);
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
void BorderEditor::on_leftLine_clicked(bool checked){
emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::LeftLine, checked);
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
void BorderEditor::on_rightLine_clicked(bool checked){
emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::RightLine, checked);
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
void BorderEditor::on_allLines_clicked()
2022-06-13 21:18:57 +03:00
{
2022-10-31 21:20:24 +03:00
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);
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
void BorderEditor::on_noLines_clicked()
2022-06-13 21:18:57 +03:00
{
2022-10-31 21:20:24 +03:00
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);
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
void BorderEditor::on_selectColor_clicked()
2022-06-13 21:18:57 +03:00
{
2022-10-31 21:20:24 +03:00
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);
2022-06-13 21:18:57 +03:00
}
2022-10-31 21:20:24 +03:00
} // namespace LimeReport