Terminal strip layout editor : add preview of terminal strip layout

This commit is contained in:
joshua
2023-09-18 22:28:30 +02:00
committed by Laurent Trinques
parent 8ca1e0487e
commit 12b7c7c47c
5 changed files with 216 additions and 159 deletions

View File

@@ -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