mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Terminal strip layout editor : add preview of terminal strip layout
This commit is contained in:
@@ -18,12 +18,6 @@
|
||||
#include "terminalstripdrawer.h"
|
||||
#include <QPainter>
|
||||
|
||||
#include "../physicalterminal.h"
|
||||
#include "../realterminal.h"
|
||||
#include "../terminalstrip.h"
|
||||
#include "../terminalstripbridge.h"
|
||||
#include "trueterminalstrip.h"
|
||||
|
||||
namespace TerminalStripDrawer {
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,6 +44,5 @@ void TerminalStripProjectConfigPage::initWidgets()
|
||||
|
||||
auto v_layout = new QVBoxLayout { this };
|
||||
v_layout->addWidget(m_layout_editor);
|
||||
v_layout->addStretch();
|
||||
setLayout(v_layout);
|
||||
}
|
||||
|
||||
@@ -23,15 +23,29 @@ TerminalStripLayoutEditor::TerminalStripLayoutEditor(QSharedPointer<TerminalStri
|
||||
QWidget *parent) :
|
||||
QWidget{ parent },
|
||||
ui{ new Ui::TerminalStripLayoutEditor },
|
||||
m_layout{ layout }
|
||||
m_layout{ layout }
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->m_graphics_view->setScene(new QGraphicsScene{ this });
|
||||
ui->m_graphics_view->scene()->addItem(&m_preview_strip_item);
|
||||
updateUi();
|
||||
}
|
||||
|
||||
TerminalStripLayoutEditor::~TerminalStripLayoutEditor()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TerminalStripLayoutEditor::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
updatePreview();
|
||||
}
|
||||
|
||||
void TerminalStripLayoutEditor::showEvent(QShowEvent *event)
|
||||
{
|
||||
QWidget::showEvent(event);
|
||||
updatePreview();
|
||||
}
|
||||
|
||||
void TerminalStripLayoutEditor::valueEdited()
|
||||
@@ -118,7 +132,8 @@ void TerminalStripLayoutEditor::valueEdited()
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
updateUi();
|
||||
m_preview_strip_item.update();
|
||||
}
|
||||
|
||||
void TerminalStripLayoutEditor::updateUi()
|
||||
@@ -193,7 +208,14 @@ void TerminalStripLayoutEditor::updateUi()
|
||||
ui->m_terminal_text_alignment_cb->setCurrentIndex(1);
|
||||
} else if (terminal_alignment &Qt::AlignRight) {
|
||||
ui->m_terminal_text_alignment_cb->setCurrentIndex(2);
|
||||
}
|
||||
}
|
||||
|
||||
m_ui_updating = false;
|
||||
m_ui_updating = false;
|
||||
updatePreview();
|
||||
}
|
||||
|
||||
void TerminalStripLayoutEditor::updatePreview()
|
||||
{
|
||||
ui->m_graphics_view->fitInView(m_preview_strip_item.boundingRect().adjusted(-5,-5,5,5),
|
||||
Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
@@ -18,14 +18,44 @@
|
||||
#ifndef TERMINALSTRIPLAYOUTEDITOR_H
|
||||
#define TERMINALSTRIPLAYOUTEDITOR_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QWidget>
|
||||
|
||||
#include "../GraphicsItem/demoterminalstrip.h"
|
||||
#include "../GraphicsItem/terminalstripdrawer.h"
|
||||
|
||||
class TerminalStripLayoutPattern;
|
||||
|
||||
namespace Ui {
|
||||
class TerminalStripLayoutEditor;
|
||||
}
|
||||
|
||||
class PreviewStripItem : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
PreviewStripItem (QSharedPointer<TerminalStripLayoutPattern> layout) :
|
||||
m_drawer {QSharedPointer<TerminalStripDrawer::DemoTerminalStrip>{new TerminalStripDrawer::DemoTerminalStrip},
|
||||
layout}
|
||||
{}
|
||||
|
||||
QRectF boundingRect() const override {
|
||||
return m_drawer.boundingRect();
|
||||
}
|
||||
|
||||
protected:
|
||||
void paint(QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) override
|
||||
{
|
||||
Q_UNUSED (option); Q_UNUSED (widget);
|
||||
m_drawer.paint(painter);
|
||||
}
|
||||
|
||||
private:
|
||||
TerminalStripDrawer::TerminalStripDrawer m_drawer;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The TerminalStripLayoutEditor class
|
||||
* Widget used to edit the layout of a terminal strip item
|
||||
@@ -39,16 +69,22 @@ class TerminalStripLayoutEditor : public QWidget
|
||||
QWidget *parent = nullptr);
|
||||
~TerminalStripLayoutEditor();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void valueEdited();
|
||||
|
||||
private:
|
||||
void updateUi();
|
||||
private:
|
||||
void updateUi();
|
||||
void updatePreview();
|
||||
|
||||
private:
|
||||
Ui::TerminalStripLayoutEditor *ui;
|
||||
QSharedPointer<TerminalStripLayoutPattern> m_layout;
|
||||
bool m_ui_updating { false } ;
|
||||
PreviewStripItem m_preview_strip_item {m_layout};
|
||||
};
|
||||
|
||||
#endif // TERMINALSTRIPLAYOUTEDITOR_H
|
||||
|
||||
@@ -7,17 +7,55 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>553</width>
|
||||
<height>311</height>
|
||||
<height>387</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Borne niveau 2 :</string>
|
||||
<string>Espace :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="m_y_header_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QSpinBox" name="m_width_terminal_0_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QSpinBox" name="m_y_terminal_3_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Borne niveau 1 :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QSpinBox" name="m_height_spacer_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -28,8 +66,78 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="m_y_spacer_sb">
|
||||
<item row="6" column="1">
|
||||
<widget class="QSpinBox" name="m_y_terminal_2_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Borne niveau 0 :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Hauteur</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>Point de pont</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="3">
|
||||
<widget class="QSpinBox" name="m_height_terminal_2_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QSpinBox" name="m_height_terminal_0_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="m_y_terminal_0_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="4">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="5">
|
||||
<widget class="Line" name="line_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Largeur</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="3">
|
||||
<widget class="QSpinBox" name="m_height_terminal_3_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
@@ -147,41 +255,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="m_y_terminal_1_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QSpinBox" name="m_height_spacer_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="5">
|
||||
<widget class="Line" name="line_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="QSpinBox" name="m_width_terminal_3_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="4">
|
||||
<widget class="QSpinBox" name="m_bridge_point_3_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
@@ -189,34 +262,27 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="m_y_terminal_0_sb">
|
||||
<item row="5" column="2">
|
||||
<widget class="QSpinBox" name="m_width_terminal_1_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Espace :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Borne niveau 0 :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QSpinBox" name="m_y_terminal_2_sb">
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="m_y_terminal_1_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Borne niveau 2 :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="4">
|
||||
<widget class="QSpinBox" name="m_bridge_point_1_sb">
|
||||
<property name="maximum">
|
||||
@@ -224,8 +290,8 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="3">
|
||||
<widget class="QSpinBox" name="m_height_terminal_1_sb">
|
||||
<item row="1" column="3">
|
||||
<widget class="QSpinBox" name="m_height_header_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
@@ -238,29 +304,15 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Borne niveau 1 :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Hauteur</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QSpinBox" name="m_width_terminal_1_sb">
|
||||
<item row="6" column="2">
|
||||
<widget class="QSpinBox" name="m_width_terminal_2_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="m_width_header_sb">
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="m_y_spacer_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
@@ -273,6 +325,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="m_width_header_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="4">
|
||||
<widget class="QSpinBox" name="m_bridge_point_3_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
@@ -280,43 +346,15 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QSpinBox" name="m_y_terminal_3_sb">
|
||||
<item row="5" column="3">
|
||||
<widget class="QSpinBox" name="m_height_terminal_1_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="4">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Largeur</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QSpinBox" name="m_height_header_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QSpinBox" name="m_width_terminal_2_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="m_y_header_sb">
|
||||
<item row="7" column="2">
|
||||
<widget class="QSpinBox" name="m_width_terminal_3_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
@@ -329,40 +367,8 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="3">
|
||||
<widget class="QSpinBox" name="m_height_terminal_2_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QSpinBox" name="m_width_terminal_0_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>Point de pont</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="3">
|
||||
<widget class="QSpinBox" name="m_height_terminal_3_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QSpinBox" name="m_height_terminal_0_sb">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="10" column="0" colspan="5">
|
||||
<widget class="QGraphicsView" name="m_graphics_view"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user