diff --git a/cmake/qet_compilation_vars.cmake b/cmake/qet_compilation_vars.cmake index 85de75176..6a1c68a85 100644 --- a/cmake/qet_compilation_vars.cmake +++ b/cmake/qet_compilation_vars.cmake @@ -51,7 +51,6 @@ set(QET_RES_FILES ${QET_DIR}/sources/editor/ui/lineeditor.ui ${QET_DIR}/sources/editor/ui/polygoneditor.ui ${QET_DIR}/sources/editor/ui/rectangleeditor.ui - ${QET_DIR}/sources/editor/ui/texteditor.ui ${QET_DIR}/sources/ElementsCollection/ui/renamedialog.ui ${QET_DIR}/sources/factory/ui/addtabledialog.ui ${QET_DIR}/sources/NameList/ui/namelistdialog.ui diff --git a/sources/editor/ui/texteditor.cpp b/sources/editor/ui/texteditor.cpp index 201e18e01..1f3c0ff5e 100644 --- a/sources/editor/ui/texteditor.cpp +++ b/sources/editor/ui/texteditor.cpp @@ -19,7 +19,6 @@ #include "../../QPropertyUndoCommand/qpropertyundocommand.h" #include "../graphicspart/parttext.h" -#include "ui_texteditor.h" #include @@ -31,9 +30,8 @@ @param parent : the parent widget */ TextEditor::TextEditor(QETElementEditor *editor, PartText *text, QWidget *parent) : - ElementItemEditor(editor, parent), - ui(new Ui::TextEditor) { - ui -> setupUi(this); + ElementItemEditor(editor, parent){ + setUpWidget(parent); setUpEditConnection(); if (text) { setPart(text); @@ -44,10 +42,7 @@ TextEditor::TextEditor(QETElementEditor *editor, PartText *text, QWidget *paren /** @brief TextEditor::~TextEditor */ -TextEditor::~TextEditor() -{ - delete ui; -} +TextEditor::~TextEditor() {} /** @brief TextEditor::updateForm @@ -61,13 +56,16 @@ void TextEditor::updateForm() disconnectEditConnection(); - ui -> m_line_edit -> setText(m_text -> toPlainText()); - ui -> m_x_sb -> setValue(m_text -> pos().x()); - ui -> m_y_sb -> setValue(m_text -> pos().y()); - ui -> m_rotation_sb -> setValue(m_text -> rotation()); - ui -> m_size_sb -> setValue(m_text -> font().pointSize()); - ui -> m_font_pb -> setText(m_text -> font().family()); - ui -> m_color_pb -> setColor(m_text -> defaultTextColor()); + m_line_edit -> setText(m_text -> toPlainText()); + m_x_sb -> setValue(m_text -> pos().x()); + m_y_sb -> setValue(m_text -> pos().y()); + m_rotation_sb -> setValue(m_text -> rotation()); + m_size_sb -> setValue(m_text -> font().pointSize()); + m_font_pb -> setText(m_text -> font().family()); +#ifdef BUILD_WITHOUT_KF5 +#else + m_color_pb -> setColor(m_text -> defaultTextColor()); +#endif setUpEditConnection(); } @@ -111,7 +109,7 @@ bool TextEditor::setPart(CustomElementPart *part) { disconnectChangeConnection(); return true; } - + if (PartText *part_text = static_cast(part)) { if (part_text == m_text) { return true; @@ -178,8 +176,8 @@ void TextEditor::setUpEditConnection() { disconnectEditConnection(); - m_edit_connection << connect(ui -> m_line_edit, &QLineEdit::editingFinished, [this]() { - QString text_ = ui -> m_line_edit -> text(); + m_edit_connection << connect(m_line_edit, &QLineEdit::editingFinished, [this]() { + QString text_ = m_line_edit -> text(); for (int i=0; i < m_parts.length(); i++) { PartText* partText = m_parts[i]; if (text_ != partText -> toPlainText()) { @@ -189,8 +187,8 @@ void TextEditor::setUpEditConnection() } } }); - m_edit_connection << connect(ui->m_x_sb, QOverload::of(&QSpinBox::valueChanged), [this]() { - QPointF pos(ui -> m_x_sb -> value(), 0); + m_edit_connection << connect(m_x_sb, QOverload::of(&QSpinBox::valueChanged), [this]() { + QPointF pos(m_x_sb -> value(), 0); for (int i=0; i < m_parts.length(); i++) { PartText* partText = m_parts[i]; pos.setY(partText -> pos().y()); @@ -202,8 +200,8 @@ void TextEditor::setUpEditConnection() } } }); - m_edit_connection << connect(ui -> m_y_sb, QOverload::of(&QSpinBox::valueChanged), [this]() { - QPointF pos(0, ui -> m_y_sb -> value()); + m_edit_connection << connect(m_y_sb, QOverload::of(&QSpinBox::valueChanged), [this]() { + QPointF pos(0, m_y_sb -> value()); for (int i=0; i < m_parts.length(); i++) { PartText* partText = m_parts[i]; pos.setX(partText -> pos().x()); @@ -215,24 +213,24 @@ void TextEditor::setUpEditConnection() } } }); - m_edit_connection << connect(ui -> m_rotation_sb, QOverload::of(&QSpinBox::valueChanged), [this]() { + m_edit_connection << connect(m_rotation_sb, QOverload::of(&QSpinBox::valueChanged), [this]() { for (int i=0; i < m_parts.length(); i++) { PartText* partText = m_parts[i]; - if (ui -> m_rotation_sb -> value() != partText -> rotation()) { + if (m_rotation_sb -> value() != partText -> rotation()) { QPropertyUndoCommand *undo = new QPropertyUndoCommand( - partText, "rotation", partText -> rotation(), ui -> m_rotation_sb -> value()); + partText, "rotation", partText -> rotation(), m_rotation_sb -> value()); undo -> setText(tr("Pivoter un champ texte")); undo -> setAnimated(true, false); undoStack().push(undo); } } }); - m_edit_connection << connect(ui->m_size_sb, QOverload::of(&QSpinBox::valueChanged), [this]() { + m_edit_connection << connect(m_size_sb, QOverload::of(&QSpinBox::valueChanged), [this]() { for (int i=0; i < m_parts.length(); i++) { PartText* partText = m_parts[i]; - if (partText -> font().pointSize() != ui -> m_size_sb -> value()) { + if (partText -> font().pointSize() !=m_size_sb -> value()) { QFont font_ = partText -> font(); - font_.setPointSize(ui -> m_size_sb -> value()); + font_.setPointSize(m_size_sb -> value()); QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText -> font(), font_); undo -> setText(tr("Modifier la police d'un texte")); undoStack().push(undo); @@ -250,11 +248,11 @@ void TextEditor::on_m_font_pb_clicked() QFont font_ = QFontDialog::getFont(&ok, m_text -> font(), this); if (ok && font_ != m_text -> font()) { - ui -> m_size_sb -> blockSignals(true); - ui -> m_size_sb -> setValue(font_.pointSize()); - ui -> m_size_sb -> blockSignals(false); + m_size_sb -> blockSignals(true); + m_size_sb -> setValue(font_.pointSize()); + m_size_sb -> blockSignals(false); - ui -> m_font_pb -> setText(font_.family()); + m_font_pb -> setText(font_.family()); } for (int i=0; i < m_parts.length(); i++) { @@ -280,5 +278,91 @@ void TextEditor::on_m_color_pb_changed(const QColor &newColor) { undo -> setText(tr("Modifier la couleur d'un texte")); undoStack().push(undo); } - } + } +} + +void TextEditor::setUpWidget(QWidget *parent) +{ + setWindowTitle(tr("Form")); + resize(378, 133); + QGridLayout *gridLayout = new QGridLayout(parent); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + m_y_sb = new QSpinBox(parent); + m_y_sb->setObjectName(QString::fromUtf8("m_y_sb")); + m_y_sb->setMinimum(-10000); + m_y_sb->setMaximum(10000); + + gridLayout->addWidget(m_y_sb, 1, 3, 1, 1); + + QLabel*label_2 = new QLabel(tr("Y :"),parent); + + gridLayout->addWidget(label_2, 1, 2, 1, 1); + + QLabel*label_4 = new QLabel(tr("Police :"),parent); + + gridLayout->addWidget(label_4, 2, 0, 1, 1); + + m_rotation_sb = new QSpinBox(parent); + m_rotation_sb->setSuffix(tr("\302\260")); + m_rotation_sb->setWrapping(true); + m_rotation_sb->setMaximum(360); + + gridLayout->addWidget(m_rotation_sb, 1, 5, 1, 1); + + QLabel *label_3 = new QLabel(tr("Rotation :"),parent); + + gridLayout->addWidget(label_3, 1, 4, 1, 1); + + m_x_sb = new QSpinBox(parent); + m_x_sb->setObjectName(QString::fromUtf8("m_x_sb")); + m_x_sb->setMinimum(-10000); + m_x_sb->setMaximum(10000); + + gridLayout->addWidget(m_x_sb, 1, 1, 1, 1); + + QLabel *label = new QLabel(tr("X :"),parent); + + gridLayout->addWidget(label, 1, 0, 1, 1); + + m_size_sb = new QSpinBox(parent); + m_size_sb->setObjectName(QString::fromUtf8("m_size_sb")); + + gridLayout->addWidget(m_size_sb, 2, 1, 1, 1); + + m_line_edit = new QLineEdit(parent); + m_line_edit->setObjectName(QString::fromUtf8("m_line_edit")); + m_line_edit->setClearButtonEnabled(true); + m_line_edit->setPlaceholderText(tr("Entrer votre texte ici")); + + gridLayout->addWidget(m_line_edit, 0, 0, 1, 6); +#ifdef BUILD_WITHOUT_KF5 +#else + m_color_pb = new KColorButton(parent); + m_color_pb->setObjectName(QString::fromUtf8("m_color_pb")); + + connect( + m_color_pb, + &KColorButton::changed, + this, + &TextEditor::on_m_color_pb_changed); + + gridLayout->addWidget(m_color_pb, 2, 5, 1, 1); + #endif + QLabel *label_5 = new QLabel(parent); + label_5->setObjectName(QString::fromUtf8("label_5")); + + gridLayout->addWidget(label_5, 2, 4, 1, 1); + + m_font_pb = new QPushButton(tr("Couleur :"),parent); + connect(m_font_pb, + &QPushButton::pressed, + this, + &TextEditor::on_m_font_pb_clicked); + + gridLayout->addWidget(m_font_pb, 2, 2, 1, 2); + + QSpacerItem *verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout->addItem(verticalSpacer, 3, 2, 1, 1); + setLayout(gridLayout); } diff --git a/sources/editor/ui/texteditor.h b/sources/editor/ui/texteditor.h index c7fe4647d..f0a99b11f 100644 --- a/sources/editor/ui/texteditor.h +++ b/sources/editor/ui/texteditor.h @@ -22,13 +22,15 @@ #include #include - +#include +#include +#include +#ifdef BUILD_WITHOUT_KF5 +#else +#include +#endif class PartText; -namespace Ui { -class TextEditor; -} - class TextEditor : public ElementItemEditor { Q_OBJECT @@ -46,18 +48,27 @@ class TextEditor : public ElementItemEditor { void on_m_font_pb_clicked(); void on_m_color_pb_changed(const QColor &newColor); private: + void setUpWidget(QWidget* parent = nullptr); void setUpEditConnection(); void setUpChangeConnection(QPointer part); void disconnectChangeConnection(); void disconnectEditConnection(); private: - Ui::TextEditor *ui; - QPointer m_text; QList m_parts; QList m_edit_connection; QList m_change_connection; + QSpinBox *m_y_sb; + QSpinBox *m_rotation_sb; + QSpinBox *m_x_sb; + QSpinBox *m_size_sb; + QLineEdit *m_line_edit; + QPushButton *m_font_pb; +#ifdef BUILD_WITHOUT_KF5 +#else + KColorButton *m_color_pb; +#endif }; #endif // TEXTEDITOR_H diff --git a/sources/editor/ui/texteditor.ui b/sources/editor/ui/texteditor.ui deleted file mode 100644 index 1fcd957bf..000000000 --- a/sources/editor/ui/texteditor.ui +++ /dev/null @@ -1,132 +0,0 @@ - - - TextEditor - - - - 0 - 0 - 378 - 133 - - - - Form - - - - - - -10000 - - - 10000 - - - - - - - Y : - - - - - - - Police : - - - - - - - true - - - ° - - - 360 - - - - - - - Rotation : - - - - - - - -10000 - - - 10000 - - - - - - - X : - - - - - - - - - - Entrer votre texte ici - - - true - - - - - - - - - - Couleur : - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - KColorButton - QPushButton -
kcolorbutton.h
-
-
- - -