Terminal strip item font is editable

The font used in the terminal strip item can be edited
trough the terminal strip layout editor widget
This commit is contained in:
joshua
2025-03-12 19:22:30 +01:00
parent ae5e188866
commit 7747223dfa
6 changed files with 345 additions and 232 deletions

View File

@@ -16,10 +16,12 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "terminalstriplayoutpattern.h"
#include "../../../utils/qetutils.h"
#include <QDebug>
TerminalStripLayoutPattern::TerminalStripLayoutPattern()
{
m_font.setPixelSize(15);
updateHeaderTextOption();
updateTerminalsTextOption();
}
@@ -39,6 +41,15 @@ QTextOption TerminalStripLayoutPattern::headerTextOption() const {
return m_header_text_option;
}
QFont TerminalStripLayoutPattern::font() const {
return m_font;
}
void TerminalStripLayoutPattern::setFont(const QFont &font) {
m_font = font;
QETUtils::pixelSizedFont(m_font);
}
void TerminalStripLayoutPattern::setTerminalsTextAlignment(const QVector<Qt::Alignment> &alignment)
{
m_terminals_text_alignment = alignment;

View File

@@ -18,6 +18,7 @@
#ifndef TERMINALSTRIPLAYOUTPATTERN_H
#define TERMINALSTRIPLAYOUTPATTERN_H
#include <QFont>
#include <QRect>
#include <QSize>
#include <QTextOption>
@@ -52,6 +53,10 @@ class TerminalStripLayoutPattern
//Spacer between the header and the terminals
QRect m_spacer_rect{0, 50, 10, 90};
//Font
QFont font() const;
void setFont (const QFont &font);
//Terminals
QVector<QRect> m_terminal_rect
{
@@ -90,7 +95,8 @@ class TerminalStripLayoutPattern
void updateHeaderTextOption();
void updateTerminalsTextOption();
private:
private:
QFont m_font;
Qt::Alignment m_header_text_alignment{Qt::AlignCenter};
QTextOption m_header_text_option;

View File

@@ -56,6 +56,8 @@ void TerminalStripDrawer::paint(QPainter *painter)
auto brush_ = painter->brush();
brush_.setColor(Qt::white);
painter->setFont(m_pattern->font());
painter->setPen(pen_);
painter->setBrush(brush_);