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,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
|
||||
|
||||
Reference in New Issue
Block a user