mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Mod DynamicTextFieldEditor
the ui file is written in the Dynamic Text Field Editor class Add switch for KF5 (QT6)
This commit is contained in:
@@ -25,28 +25,28 @@
|
|||||||
#include "../../ui/alignmenttextdialog.h"
|
#include "../../ui/alignmenttextdialog.h"
|
||||||
#include "../../ui/compositetexteditdialog.h"
|
#include "../../ui/compositetexteditdialog.h"
|
||||||
#include "../qetelementeditor.h"
|
#include "../qetelementeditor.h"
|
||||||
#include "ui_dynamictextfieldeditor.h"
|
|
||||||
|
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
|
#include <QFrame>
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QLabel>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QSpacerItem>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
DynamicTextFieldEditor::DynamicTextFieldEditor(
|
DynamicTextFieldEditor::DynamicTextFieldEditor(
|
||||||
QETElementEditor *editor, PartDynamicTextField *text_field, QWidget *parent) :
|
QETElementEditor* editor,
|
||||||
ElementItemEditor(editor, parent),
|
PartDynamicTextField* text_field,
|
||||||
ui(new Ui::DynamicTextFieldEditor) {
|
QWidget* parent) :
|
||||||
ui -> setupUi(this);
|
ElementItemEditor(editor, parent)
|
||||||
ui -> m_composite_text_pb -> setDisabled(true);
|
{
|
||||||
ui -> m_elmt_info_cb -> setDisabled(true);
|
setUpWidget(parent);
|
||||||
if(text_field) {
|
if (text_field) { setPart(text_field); }
|
||||||
setPart(text_field);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicTextFieldEditor::~DynamicTextFieldEditor()
|
DynamicTextFieldEditor::~DynamicTextFieldEditor()
|
||||||
{
|
{
|
||||||
delete ui;
|
|
||||||
if(!m_connection_list.isEmpty()) {
|
if(!m_connection_list.isEmpty()) {
|
||||||
for(const QMetaObject::Connection& con : m_connection_list) {
|
for(const QMetaObject::Connection& con : m_connection_list) {
|
||||||
disconnect(con);
|
disconnect(con);
|
||||||
@@ -129,39 +129,278 @@ QList<CustomElementPart*> DynamicTextFieldEditor::currentParts() const
|
|||||||
void DynamicTextFieldEditor::updateForm()
|
void DynamicTextFieldEditor::updateForm()
|
||||||
{
|
{
|
||||||
if(m_text_field) {
|
if(m_text_field) {
|
||||||
ui -> m_x_sb -> setValue(m_text_field.data() -> x());
|
m_x_sb->setValue(m_text_field.data()->x());
|
||||||
ui -> m_y_sb -> setValue(m_text_field.data() ->y ());
|
m_y_sb->setValue(m_text_field.data()->y());
|
||||||
ui -> m_rotation_sb -> setValue(QET::correctAngle(m_text_field.data() -> rotation()));
|
m_rotation_sb->setValue(
|
||||||
ui -> m_frame_cb -> setChecked(m_text_field.data() -> frame());
|
QET::correctAngle(m_text_field.data()->rotation()));
|
||||||
ui -> m_user_text_le -> setText(m_text_field.data() -> text());
|
m_frame_cb->setChecked(m_text_field.data()->frame());
|
||||||
ui -> m_size_sb -> setValue(m_text_field.data() -> font().pointSize());
|
m_user_text_le->setText(m_text_field.data()->text());
|
||||||
|
m_size_sb->setValue(m_text_field.data()->font().pointSize());
|
||||||
#ifdef BUILD_WITHOUT_KF5
|
#ifdef BUILD_WITHOUT_KF5
|
||||||
#else
|
#else
|
||||||
ui -> m_color_kpb -> setColor(m_text_field.data() -> color());
|
m_color_kpb->setColor(m_text_field.data()->color());
|
||||||
#endif
|
#endif
|
||||||
ui -> m_width_sb -> setValue(m_text_field.data() -> textWidth());
|
m_width_sb->setValue(m_text_field.data()->textWidth());
|
||||||
ui -> m_font_pb -> setText(m_text_field -> font().family());
|
m_font_pb->setText(m_text_field->font().family());
|
||||||
|
|
||||||
switch (m_text_field.data() -> textFrom()) {
|
switch (m_text_field.data() -> textFrom()) {
|
||||||
case DynamicElementTextItem::UserText: {
|
case DynamicElementTextItem::UserText: {
|
||||||
ui -> m_text_from_cb -> setCurrentIndex(0);
|
m_text_from_cb->setCurrentIndex(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DynamicElementTextItem::ElementInfo: {
|
case DynamicElementTextItem::ElementInfo: {
|
||||||
ui -> m_text_from_cb -> setCurrentIndex(1);
|
m_text_from_cb->setCurrentIndex(1);
|
||||||
ui -> m_elmt_info_cb -> setCurrentIndex(
|
m_elmt_info_cb->setCurrentIndex(
|
||||||
ui -> m_elmt_info_cb -> findData(m_text_field.data() -> infoName()));
|
m_elmt_info_cb->findData(m_text_field.data()->infoName()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DynamicElementTextItem::CompositeText: {
|
case DynamicElementTextItem::CompositeText: {
|
||||||
ui -> m_text_from_cb -> setCurrentIndex(2);
|
m_text_from_cb->setCurrentIndex(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
on_m_text_from_cb_activated(ui -> m_text_from_cb -> currentIndex()); //For enable the good widget
|
on_m_text_from_cb_activated(
|
||||||
|
m_text_from_cb->currentIndex()); // For enable the good widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DynamicTextFieldEditor::setUpWidget(QWidget* parent)
|
||||||
|
{
|
||||||
|
resize(344, 285);
|
||||||
|
setWindowTitle(tr("Form"));
|
||||||
|
|
||||||
|
QGridLayout* gridLayout = new QGridLayout(parent);
|
||||||
|
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
|
||||||
|
|
||||||
|
m_text_from_cb = new QComboBox(parent);
|
||||||
|
m_text_from_cb->addItem(QString());
|
||||||
|
m_text_from_cb->addItem(QString());
|
||||||
|
m_text_from_cb->addItem(QString());
|
||||||
|
m_text_from_cb->setObjectName(QString::fromUtf8("m_text_from_cb"));
|
||||||
|
m_text_from_cb->setItemText(0, tr("Texte utilisateur"));
|
||||||
|
m_text_from_cb->setItemText(
|
||||||
|
1,
|
||||||
|
tr("Information de l'\303\251l\303\251ment"));
|
||||||
|
m_text_from_cb->setItemText(2, tr("Texte compos\303\251"));
|
||||||
|
|
||||||
|
connect(
|
||||||
|
m_text_from_cb,
|
||||||
|
&QComboBox::currentIndexChanged,
|
||||||
|
this,
|
||||||
|
&DynamicTextFieldEditor::on_m_text_from_cb_activated);
|
||||||
|
|
||||||
|
gridLayout->addWidget(m_text_from_cb, 2, 1, 1, 2);
|
||||||
|
|
||||||
|
QLabel* label_3 = new QLabel(tr("Couleur"), parent);
|
||||||
|
label_3->setObjectName(QString::fromUtf8("label_3"));
|
||||||
|
|
||||||
|
gridLayout->addWidget(label_3, 7, 0, 1, 1);
|
||||||
|
|
||||||
|
QSpacerItem* verticalSpacer =
|
||||||
|
new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||||
|
|
||||||
|
gridLayout->addItem(verticalSpacer, 8, 1, 1, 1);
|
||||||
|
|
||||||
|
m_elmt_info_cb = new QComboBox(parent);
|
||||||
|
m_elmt_info_cb->setObjectName(QString::fromUtf8("m_elmt_info_cb"));
|
||||||
|
m_elmt_info_cb->setDisabled(true);
|
||||||
|
|
||||||
|
connect(
|
||||||
|
m_elmt_info_cb,
|
||||||
|
&QComboBox::currentTextChanged,
|
||||||
|
this,
|
||||||
|
&DynamicTextFieldEditor::on_m_elmt_info_cb_activated);
|
||||||
|
|
||||||
|
gridLayout->addWidget(m_elmt_info_cb, 4, 1, 1, 2);
|
||||||
|
|
||||||
|
m_user_text_le = new QLineEdit(parent);
|
||||||
|
m_user_text_le->setObjectName(QString::fromUtf8("m_user_text_le"));
|
||||||
|
|
||||||
|
connect(
|
||||||
|
m_user_text_le,
|
||||||
|
&QLineEdit::editingFinished,
|
||||||
|
this,
|
||||||
|
&DynamicTextFieldEditor::on_m_user_text_le_editingFinished);
|
||||||
|
|
||||||
|
gridLayout->addWidget(m_user_text_le, 3, 1, 1, 2);
|
||||||
|
|
||||||
|
m_composite_text_pb = new QPushButton(tr("Texte compos\303\251"), parent);
|
||||||
|
m_composite_text_pb->setObjectName(
|
||||||
|
QString::fromUtf8("m_composite_text_pb"));
|
||||||
|
m_composite_text_pb->setDisabled(true);
|
||||||
|
|
||||||
|
connect(
|
||||||
|
m_composite_text_pb,
|
||||||
|
&QPushButton::clicked,
|
||||||
|
this,
|
||||||
|
&DynamicTextFieldEditor::on_m_composite_text_pb_clicked);
|
||||||
|
|
||||||
|
gridLayout->addWidget(m_composite_text_pb, 5, 1, 1, 2);
|
||||||
|
|
||||||
|
QLabel* label = new QLabel(tr("Police"), parent);
|
||||||
|
label->setObjectName(QString::fromUtf8("label"));
|
||||||
|
|
||||||
|
gridLayout->addWidget(label, 6, 0, 1, 1);
|
||||||
|
|
||||||
|
QLabel* label_4 = new QLabel(tr("Source du texte"), parent);
|
||||||
|
label_4->setObjectName(QString::fromUtf8("label_4"));
|
||||||
|
|
||||||
|
gridLayout->addWidget(label_4, 2, 0, 1, 1);
|
||||||
|
|
||||||
|
QSpacerItem* verticalSpacer_2 =
|
||||||
|
new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||||
|
|
||||||
|
gridLayout->addItem(verticalSpacer_2, 1, 0, 1, 1);
|
||||||
|
|
||||||
|
QFrame* frame = new QFrame(parent);
|
||||||
|
frame->setObjectName(QString::fromUtf8("frame"));
|
||||||
|
frame->setFrameShape(QFrame::NoFrame);
|
||||||
|
frame->setFrameShadow(QFrame::Raised);
|
||||||
|
|
||||||
|
QGridLayout* gridLayout_2 = new QGridLayout(frame);
|
||||||
|
gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2"));
|
||||||
|
|
||||||
|
m_x_sb = new QDoubleSpinBox(frame);
|
||||||
|
m_x_sb->setObjectName(QString::fromUtf8("m_x_sb"));
|
||||||
|
m_x_sb->setMinimum(-5000.000000000000000);
|
||||||
|
m_x_sb->setMaximum(5000.000000000000000);
|
||||||
|
|
||||||
|
connect(
|
||||||
|
m_x_sb,
|
||||||
|
&QDoubleSpinBox::editingFinished,
|
||||||
|
this,
|
||||||
|
&DynamicTextFieldEditor::on_m_x_sb_editingFinished);
|
||||||
|
|
||||||
|
gridLayout_2->addWidget(m_x_sb, 0, 1, 1, 1);
|
||||||
|
|
||||||
|
m_frame_cb = new QCheckBox(tr("cadre"), frame);
|
||||||
|
m_frame_cb->setObjectName(QString::fromUtf8("m_frame_cb"));
|
||||||
|
|
||||||
|
connect(
|
||||||
|
m_frame_cb,
|
||||||
|
&QCheckBox::clicked,
|
||||||
|
this,
|
||||||
|
&DynamicTextFieldEditor::on_m_frame_cb_clicked);
|
||||||
|
|
||||||
|
gridLayout_2->addWidget(m_frame_cb, 0, 6, 1, 1);
|
||||||
|
|
||||||
|
m_rotation_sb = new QSpinBox(frame);
|
||||||
|
m_rotation_sb->setObjectName(QString::fromUtf8("m_rotation_sb"));
|
||||||
|
m_rotation_sb->setMaximum(359);
|
||||||
|
|
||||||
|
connect(
|
||||||
|
m_rotation_sb,
|
||||||
|
&QSpinBox::editingFinished,
|
||||||
|
this,
|
||||||
|
&DynamicTextFieldEditor::on_m_rotation_sb_editingFinished);
|
||||||
|
|
||||||
|
gridLayout_2->addWidget(m_rotation_sb, 0, 5, 1, 1);
|
||||||
|
|
||||||
|
QLabel* label_7 = new QLabel(tr("Rotation"), frame);
|
||||||
|
label_7->setObjectName(QString::fromUtf8("label_7"));
|
||||||
|
label_7->setAlignment(
|
||||||
|
Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
||||||
|
|
||||||
|
gridLayout_2->addWidget(label_7, 0, 4, 1, 1);
|
||||||
|
|
||||||
|
QLabel* label_5 = new QLabel(tr("X"), frame);
|
||||||
|
label_5->setObjectName(QString::fromUtf8("label_5"));
|
||||||
|
label_5->setAlignment(
|
||||||
|
Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
||||||
|
|
||||||
|
gridLayout_2->addWidget(label_5, 0, 0, 1, 1);
|
||||||
|
|
||||||
|
m_width_sb = new QSpinBox(frame);
|
||||||
|
m_width_sb->setObjectName(QString::fromUtf8("m_width_sb"));
|
||||||
|
m_width_sb->setMinimum(-1);
|
||||||
|
m_width_sb->setMaximum(500);
|
||||||
|
|
||||||
|
connect(
|
||||||
|
m_width_sb,
|
||||||
|
&QSpinBox::editingFinished,
|
||||||
|
this,
|
||||||
|
&DynamicTextFieldEditor::on_m_width_sb_editingFinished);
|
||||||
|
|
||||||
|
gridLayout_2->addWidget(m_width_sb, 1, 5, 1, 1);
|
||||||
|
|
||||||
|
QLabel* label_2 = new QLabel(tr("Largeur"), frame);
|
||||||
|
label_2->setObjectName(QString::fromUtf8("label_2"));
|
||||||
|
label_2->setAlignment(
|
||||||
|
Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
||||||
|
|
||||||
|
gridLayout_2->addWidget(label_2, 1, 4, 1, 1);
|
||||||
|
|
||||||
|
QLabel* label_6 = new QLabel(tr("Y"), frame);
|
||||||
|
label_6->setObjectName(QString::fromUtf8("label_6"));
|
||||||
|
label_6->setAlignment(
|
||||||
|
Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
||||||
|
|
||||||
|
gridLayout_2->addWidget(label_6, 1, 0, 1, 1);
|
||||||
|
|
||||||
|
m_y_sb = new QDoubleSpinBox(frame);
|
||||||
|
m_y_sb->setObjectName(QString::fromUtf8("m_y_sb"));
|
||||||
|
m_y_sb->setMinimum(-5000.000000000000000);
|
||||||
|
m_y_sb->setMaximum(5000.000000000000000);
|
||||||
|
|
||||||
|
connect(
|
||||||
|
m_y_sb,
|
||||||
|
&QDoubleSpinBox::editingFinished,
|
||||||
|
this,
|
||||||
|
&DynamicTextFieldEditor::on_m_y_sb_editingFinished);
|
||||||
|
|
||||||
|
gridLayout_2->addWidget(m_y_sb, 1, 1, 1, 1);
|
||||||
|
|
||||||
|
QPushButton* m_alignment_pb = new QPushButton(tr("Alignement"), frame);
|
||||||
|
m_alignment_pb->setObjectName(QString::fromUtf8("m_alignment_pb"));
|
||||||
|
|
||||||
|
connect(
|
||||||
|
m_alignment_pb,
|
||||||
|
&QPushButton::clicked,
|
||||||
|
this,
|
||||||
|
&DynamicTextFieldEditor::on_m_alignment_pb_clicked);
|
||||||
|
|
||||||
|
gridLayout_2->addWidget(m_alignment_pb, 1, 6, 1, 1);
|
||||||
|
|
||||||
|
gridLayout->addWidget(frame, 0, 0, 1, 3);
|
||||||
|
|
||||||
|
m_size_sb = new QSpinBox(parent);
|
||||||
|
m_size_sb->setObjectName(QString::fromUtf8("m_size_sb"));
|
||||||
|
|
||||||
|
connect(
|
||||||
|
m_size_sb,
|
||||||
|
&QSpinBox::editingFinished,
|
||||||
|
this,
|
||||||
|
&DynamicTextFieldEditor::on_m_size_sb_editingFinished);
|
||||||
|
|
||||||
|
gridLayout->addWidget(m_size_sb, 6, 1, 1, 1);
|
||||||
|
|
||||||
|
m_font_pb = new QPushButton(QString(), parent);
|
||||||
|
m_font_pb->setObjectName(QString::fromUtf8("m_font_pb"));
|
||||||
|
|
||||||
|
connect(
|
||||||
|
m_font_pb,
|
||||||
|
&QPushButton::clicked,
|
||||||
|
this,
|
||||||
|
&DynamicTextFieldEditor::on_m_font_pb_clicked);
|
||||||
|
|
||||||
|
gridLayout->addWidget(m_font_pb, 6, 2, 1, 1);
|
||||||
|
|
||||||
|
#ifdef BUILD_WITHOUT_KF5
|
||||||
|
#else
|
||||||
|
m_color_kpb = new KColorButton(parent);
|
||||||
|
m_color_kpb->setObjectName(QString::fromUtf8("m_color_kpb"));
|
||||||
|
|
||||||
|
connect(
|
||||||
|
m_color_kpb,
|
||||||
|
&KColorButton::changed,
|
||||||
|
this,
|
||||||
|
&DynamicTextFieldEditor::on_m_color_kpb_changed);
|
||||||
|
|
||||||
|
gridLayout->addWidget(m_color_kpb, 7, 1, 1, 2);
|
||||||
|
#endif
|
||||||
|
setLayout(gridLayout);
|
||||||
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::setUpConnections()
|
void DynamicTextFieldEditor::setUpConnections()
|
||||||
{
|
{
|
||||||
assert(m_connection_list.isEmpty());
|
assert(m_connection_list.isEmpty());
|
||||||
@@ -204,7 +443,7 @@ void DynamicTextFieldEditor::disconnectConnections()
|
|||||||
*/
|
*/
|
||||||
void DynamicTextFieldEditor::fillInfoComboBox()
|
void DynamicTextFieldEditor::fillInfoComboBox()
|
||||||
{
|
{
|
||||||
ui -> m_elmt_info_cb -> clear();
|
m_elmt_info_cb->clear();
|
||||||
|
|
||||||
QStringList strl;
|
QStringList strl;
|
||||||
QString type = elementEditor() -> elementScene() -> elementType();
|
QString type = elementEditor() -> elementScene() -> elementType();
|
||||||
@@ -223,12 +462,12 @@ void DynamicTextFieldEditor::fillInfoComboBox()
|
|||||||
|
|
||||||
|
|
||||||
for (const QString& key : info_map.keys())
|
for (const QString& key : info_map.keys())
|
||||||
ui -> m_elmt_info_cb -> addItem(key, info_map.value(key));
|
m_elmt_info_cb->addItem(key, info_map.value(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_x_sb_editingFinished()
|
void DynamicTextFieldEditor::on_m_x_sb_editingFinished()
|
||||||
{
|
{
|
||||||
double value = ui -> m_x_sb -> value();
|
double value = m_x_sb->value();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "x", m_parts[i] -> x(), value);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "x", m_parts[i] -> x(), value);
|
||||||
undo -> setText(tr("Déplacer un champ texte"));
|
undo -> setText(tr("Déplacer un champ texte"));
|
||||||
@@ -239,7 +478,7 @@ void DynamicTextFieldEditor::on_m_x_sb_editingFinished()
|
|||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_y_sb_editingFinished()
|
void DynamicTextFieldEditor::on_m_y_sb_editingFinished()
|
||||||
{
|
{
|
||||||
double value = ui -> m_y_sb -> value();
|
double value = m_y_sb->value();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "y", m_parts[i] -> y(), value);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "y", m_parts[i] -> y(), value);
|
||||||
undo -> setText(tr("Déplacer un champ texte"));
|
undo -> setText(tr("Déplacer un champ texte"));
|
||||||
@@ -250,7 +489,7 @@ void DynamicTextFieldEditor::on_m_y_sb_editingFinished()
|
|||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_rotation_sb_editingFinished()
|
void DynamicTextFieldEditor::on_m_rotation_sb_editingFinished()
|
||||||
{
|
{
|
||||||
int value = ui -> m_rotation_sb -> value();
|
int value = m_rotation_sb->value();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "rotation", m_parts[i] -> rotation(), value);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "rotation", m_parts[i] -> rotation(), value);
|
||||||
undo -> setText(tr("Pivoter un champ texte"));
|
undo -> setText(tr("Pivoter un champ texte"));
|
||||||
@@ -261,7 +500,7 @@ void DynamicTextFieldEditor::on_m_rotation_sb_editingFinished()
|
|||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_user_text_le_editingFinished()
|
void DynamicTextFieldEditor::on_m_user_text_le_editingFinished()
|
||||||
{
|
{
|
||||||
QString text = ui -> m_user_text_le -> text();
|
QString text = m_user_text_le->text();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "text", m_parts[i] -> text(), text);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "text", m_parts[i] -> text(), text);
|
||||||
undo -> setText(tr("Modifier le texte d'un champ texte"));
|
undo -> setText(tr("Modifier le texte d'un champ texte"));
|
||||||
@@ -272,7 +511,7 @@ void DynamicTextFieldEditor::on_m_user_text_le_editingFinished()
|
|||||||
void DynamicTextFieldEditor::on_m_size_sb_editingFinished()
|
void DynamicTextFieldEditor::on_m_size_sb_editingFinished()
|
||||||
{
|
{
|
||||||
QFont font_ = m_text_field -> font();
|
QFont font_ = m_text_field -> font();
|
||||||
font_.setPointSize(ui -> m_size_sb -> value());
|
font_.setPointSize(m_size_sb->value());
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i] -> font(), font_);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i] -> font(), font_);
|
||||||
undo -> setText(tr("Modifier la police d'un champ texte"));
|
undo -> setText(tr("Modifier la police d'un champ texte"));
|
||||||
@@ -282,7 +521,7 @@ void DynamicTextFieldEditor::on_m_size_sb_editingFinished()
|
|||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_frame_cb_clicked()
|
void DynamicTextFieldEditor::on_m_frame_cb_clicked()
|
||||||
{
|
{
|
||||||
bool frame = ui -> m_frame_cb -> isChecked();
|
bool frame = m_frame_cb->isChecked();
|
||||||
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(frame != m_parts[i] -> frame()) {
|
if(frame != m_parts[i] -> frame()) {
|
||||||
@@ -295,7 +534,7 @@ void DynamicTextFieldEditor::on_m_frame_cb_clicked()
|
|||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_width_sb_editingFinished()
|
void DynamicTextFieldEditor::on_m_width_sb_editingFinished()
|
||||||
{
|
{
|
||||||
qreal width = (qreal)ui -> m_width_sb -> value();
|
qreal width = (qreal) m_width_sb->value();
|
||||||
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(width != m_parts[i] -> textWidth()) {
|
if(width != m_parts[i] -> textWidth()) {
|
||||||
@@ -309,7 +548,7 @@ void DynamicTextFieldEditor::on_m_width_sb_editingFinished()
|
|||||||
void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(const QString &arg1) {
|
void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(const QString &arg1) {
|
||||||
Q_UNUSED(arg1)
|
Q_UNUSED(arg1)
|
||||||
|
|
||||||
QString info = ui -> m_elmt_info_cb -> currentData().toString();
|
QString info = m_elmt_info_cb->currentData().toString();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(info != m_parts[i] -> infoName()) {
|
if(info != m_parts[i] -> infoName()) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "infoName", m_parts[i] -> infoName(), info);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "infoName", m_parts[i] -> infoName(), info);
|
||||||
@@ -322,18 +561,16 @@ void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(const QString &arg1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_text_from_cb_activated(int index) {
|
void DynamicTextFieldEditor::on_m_text_from_cb_activated(int index) {
|
||||||
ui -> m_user_text_le -> setDisabled(true);
|
m_user_text_le->setDisabled(true);
|
||||||
ui -> m_elmt_info_cb -> setDisabled(true);
|
m_elmt_info_cb->setDisabled(true);
|
||||||
ui -> m_composite_text_pb -> setDisabled(true);
|
m_composite_text_pb->setDisabled(true);
|
||||||
|
|
||||||
if(index == 0) {
|
if (index == 0) { m_user_text_le->setEnabled(true); }
|
||||||
ui->m_user_text_le->setEnabled(true);
|
|
||||||
}
|
|
||||||
else if (index == 1) {
|
else if (index == 1) {
|
||||||
ui->m_elmt_info_cb->setEnabled(true);
|
m_elmt_info_cb->setEnabled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui->m_composite_text_pb->setEnabled(true);
|
m_composite_text_pb->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicElementTextItem::TextFrom tf;
|
DynamicElementTextItem::TextFrom tf;
|
||||||
@@ -392,8 +629,8 @@ void DynamicTextFieldEditor::on_m_font_pb_clicked()
|
|||||||
bool ok;
|
bool ok;
|
||||||
QFont font_ = QFontDialog::getFont(&ok, m_text_field -> font(), this);
|
QFont font_ = QFontDialog::getFont(&ok, m_text_field -> font(), this);
|
||||||
if (ok && font_ != this -> font()) {
|
if (ok && font_ != this -> font()) {
|
||||||
ui -> m_font_pb -> setText(font_.family());
|
m_font_pb->setText(font_.family());
|
||||||
ui -> m_size_sb -> setValue(font_.pointSize());
|
m_size_sb->setValue(font_.pointSize());
|
||||||
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i] -> font(), font_);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i] -> font(), font_);
|
||||||
@@ -403,16 +640,24 @@ void DynamicTextFieldEditor::on_m_font_pb_clicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_color_kpb_changed(const QColor &newColor) {
|
#ifdef BUILD_WITHOUT_KF5
|
||||||
if (!newColor.isValid()) {
|
#else
|
||||||
return;
|
void DynamicTextFieldEditor::on_m_color_kpb_changed(const QColor& newColor)
|
||||||
}
|
{
|
||||||
|
if (! newColor.isValid()) { return; }
|
||||||
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++)
|
||||||
if(newColor != m_parts[i] -> color()) {
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "color", m_parts[i] -> color(), newColor);
|
if (newColor != m_parts[i]->color())
|
||||||
undo -> setText(tr("Modifier la couleur d'un champ texte"));
|
{
|
||||||
|
QPropertyUndoCommand* undo = new QPropertyUndoCommand(
|
||||||
|
m_parts[i],
|
||||||
|
"color",
|
||||||
|
m_parts[i]->color(),
|
||||||
|
newColor);
|
||||||
|
undo->setText(tr("Modifier la couleur d'un champ texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -21,9 +21,16 @@
|
|||||||
#include "../elementitemeditor.h"
|
#include "../elementitemeditor.h"
|
||||||
#include "../graphicspart/partdynamictextfield.h"
|
#include "../graphicspart/partdynamictextfield.h"
|
||||||
|
|
||||||
namespace Ui {
|
#include <QCheckBox>
|
||||||
class DynamicTextFieldEditor;
|
#include <QComboBox>
|
||||||
}
|
#include <QDoubleSpinBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#ifdef BUILD_WITHOUT_KF5
|
||||||
|
#else
|
||||||
|
# include <KColorButton>
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The DynamicTextFieldEditor class
|
@brief The DynamicTextFieldEditor class
|
||||||
@@ -32,42 +39,61 @@ namespace Ui {
|
|||||||
class DynamicTextFieldEditor : public ElementItemEditor {
|
class DynamicTextFieldEditor : public ElementItemEditor {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DynamicTextFieldEditor(QETElementEditor *editor, PartDynamicTextField *text_field = nullptr, QWidget *parent = nullptr);
|
explicit DynamicTextFieldEditor(
|
||||||
~DynamicTextFieldEditor() override;
|
QETElementEditor* editor,
|
||||||
|
PartDynamicTextField* text_field = nullptr,
|
||||||
|
QWidget* parent = nullptr);
|
||||||
|
~DynamicTextFieldEditor() override;
|
||||||
|
|
||||||
bool setPart(CustomElementPart *part) override;
|
bool setPart(CustomElementPart* part) override;
|
||||||
bool setParts(QList <CustomElementPart *>) override;
|
bool setParts(QList<CustomElementPart*>) override;
|
||||||
CustomElementPart *currentPart() const override;
|
CustomElementPart* currentPart() const override;
|
||||||
QList<CustomElementPart*> currentParts() const override;
|
QList<CustomElementPart*> currentParts() const override;
|
||||||
void updateForm() override;
|
void updateForm() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fillInfoComboBox();
|
void setUpWidget(QWidget* parent = nullptr);
|
||||||
void setUpConnections();
|
void fillInfoComboBox();
|
||||||
void disconnectConnections();
|
void setUpConnections();
|
||||||
|
void disconnectConnections();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_x_sb_editingFinished();
|
void on_m_x_sb_editingFinished();
|
||||||
void on_m_y_sb_editingFinished();
|
void on_m_y_sb_editingFinished();
|
||||||
void on_m_rotation_sb_editingFinished();
|
void on_m_rotation_sb_editingFinished();
|
||||||
void on_m_user_text_le_editingFinished();
|
void on_m_user_text_le_editingFinished();
|
||||||
void on_m_size_sb_editingFinished();
|
void on_m_size_sb_editingFinished();
|
||||||
void on_m_frame_cb_clicked();
|
void on_m_frame_cb_clicked();
|
||||||
void on_m_width_sb_editingFinished();
|
void on_m_width_sb_editingFinished();
|
||||||
void on_m_elmt_info_cb_activated(const QString &arg1);
|
void on_m_elmt_info_cb_activated(const QString& arg1);
|
||||||
void on_m_text_from_cb_activated(int index);
|
void on_m_text_from_cb_activated(int index);
|
||||||
void on_m_composite_text_pb_clicked();
|
void on_m_composite_text_pb_clicked();
|
||||||
void on_m_alignment_pb_clicked();
|
void on_m_alignment_pb_clicked();
|
||||||
void on_m_font_pb_clicked();
|
void on_m_font_pb_clicked();
|
||||||
|
#ifdef BUILD_WITHOUT_KF5
|
||||||
void on_m_color_kpb_changed(const QColor &newColor);
|
#else
|
||||||
|
void on_m_color_kpb_changed(const QColor& newColor);
|
||||||
private:
|
#endif
|
||||||
Ui::DynamicTextFieldEditor *ui;
|
private:
|
||||||
QPointer<PartDynamicTextField> m_text_field;
|
QPointer<PartDynamicTextField> m_text_field;
|
||||||
QList<PartDynamicTextField*> m_parts;
|
QList<PartDynamicTextField*> m_parts;
|
||||||
QList<QMetaObject::Connection> m_connection_list;
|
QList<QMetaObject::Connection> m_connection_list;
|
||||||
|
QComboBox* m_text_from_cb;
|
||||||
|
QComboBox* m_elmt_info_cb;
|
||||||
|
QDoubleSpinBox* m_x_sb;
|
||||||
|
QDoubleSpinBox* m_y_sb;
|
||||||
|
QSpinBox* m_rotation_sb;
|
||||||
|
QLineEdit* m_user_text_le;
|
||||||
|
QSpinBox* m_size_sb;
|
||||||
|
QCheckBox* m_frame_cb;
|
||||||
|
QSpinBox* m_width_sb;
|
||||||
|
QPushButton* m_composite_text_pb;
|
||||||
|
QPushButton* m_font_pb;
|
||||||
|
#ifdef BUILD_WITHOUT_KF5
|
||||||
|
#else
|
||||||
|
KColorButton* m_color_kpb;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DYNAMICTEXTFIELDEDITOR_H
|
#endif // DYNAMICTEXTFIELDEDITOR_H
|
||||||
|
|||||||
@@ -1,223 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>DynamicTextFieldEditor</class>
|
|
||||||
<widget class="QWidget" name="DynamicTextFieldEditor">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>344</width>
|
|
||||||
<height>285</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Form</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="2" column="1" colspan="2">
|
|
||||||
<widget class="QComboBox" name="m_text_from_cb">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Texte utilisateur</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Information de l'élément</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Texte composé</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="0">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Couleur</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="8" column="1">
|
|
||||||
<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 row="4" column="1" colspan="2">
|
|
||||||
<widget class="QComboBox" name="m_elmt_info_cb"/>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1" colspan="2">
|
|
||||||
<widget class="QLineEdit" name="m_user_text_le"/>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="1" colspan="2">
|
|
||||||
<widget class="QPushButton" name="m_composite_text_pb">
|
|
||||||
<property name="text">
|
|
||||||
<string>Texte composé</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Police</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="text">
|
|
||||||
<string>Source du texte</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<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>
|
|
||||||
<item row="0" column="0" colspan="3">
|
|
||||||
<widget class="QFrame" name="frame">
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::NoFrame</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QDoubleSpinBox" name="m_x_sb">
|
|
||||||
<property name="minimum">
|
|
||||||
<double>-5000.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<double>5000.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="6">
|
|
||||||
<widget class="QCheckBox" name="m_frame_cb">
|
|
||||||
<property name="text">
|
|
||||||
<string>cadre</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="5">
|
|
||||||
<widget class="QSpinBox" name="m_rotation_sb">
|
|
||||||
<property name="maximum">
|
|
||||||
<number>359</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="4">
|
|
||||||
<widget class="QLabel" name="label_7">
|
|
||||||
<property name="text">
|
|
||||||
<string>Rotation</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label_5">
|
|
||||||
<property name="text">
|
|
||||||
<string>X</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="5">
|
|
||||||
<widget class="QSpinBox" name="m_width_sb">
|
|
||||||
<property name="minimum">
|
|
||||||
<number>-1</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>500</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="4">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Largeur</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_6">
|
|
||||||
<property name="text">
|
|
||||||
<string>Y</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QDoubleSpinBox" name="m_y_sb">
|
|
||||||
<property name="minimum">
|
|
||||||
<double>-5000.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<double>5000.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="6">
|
|
||||||
<widget class="QPushButton" name="m_alignment_pb">
|
|
||||||
<property name="text">
|
|
||||||
<string>Alignement</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="1">
|
|
||||||
<widget class="QSpinBox" name="m_size_sb"/>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="2">
|
|
||||||
<widget class="QPushButton" name="m_font_pb">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="1" colspan="2">
|
|
||||||
<widget class="KColorButton" name="m_color_kpb"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>KColorButton</class>
|
|
||||||
<extends>QPushButton</extends>
|
|
||||||
<header>kcolorbutton.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
Reference in New Issue
Block a user