LibrePCB Developers Documentation
Loading...
Searching...
No Matches
ShortcutsReferenceGenerator Class Referencefinal

Helper to generate a keyboard shortcuts reference PDF. More...

#include <shortcutsreferencegenerator.h>

+ Collaboration diagram for ShortcutsReferenceGenerator:

Public Types

enum class  Flag
 

Public Member Functions

 ShortcutsReferenceGenerator ()=delete
 
 ShortcutsReferenceGenerator (const ShortcutsReferenceGenerator &other)=delete
 
 ShortcutsReferenceGenerator (EditorCommandSet &commands) noexcept
 
 ~ShortcutsReferenceGenerator () noexcept
 
bool generatePdf (const FilePath &fp)
 Generate the PDF.
 
ShortcutsReferenceGeneratoroperator= (const ShortcutsReferenceGenerator &rhs)=delete
 

Private Member Functions

void drawSectionTitle (QPdfWriter &writer, QPainter &painter, qreal x1, qreal x2, qreal y, const QString &text) const noexcept
 
void drawCommandCategory (QPdfWriter &writer, QPainter &painter, qreal x, qreal y, EditorCommandCategory &cat) const noexcept
 
void drawRow (QPdfWriter &writer, QPainter &painter, qreal x, qreal y, qreal totalWidth, qreal shortcutsWidth, const QString &text, const QString &shortcuts, bool gray) const noexcept
 
int drawText (QPdfWriter &writer, QPainter &painter, qreal x, qreal y, qreal size, qreal maxLength, const QString &text, Flags flags=Flags()) const noexcept
 
int mmToPx (QPdfWriter &writer, qreal mm) const noexcept
 

Private Attributes

EditorCommandSetmCommands
 

Static Private Attributes

static constexpr qreal sPageWidth = 270
 
static constexpr qreal sPageHeight = 190
 
static constexpr qreal sCategoryTextSize = 3
 
static constexpr qreal sRowTextSize = 2.5
 
static constexpr qreal sRowHeight = 3
 
static constexpr qreal sCategorySpacing = 5
 
static constexpr qreal sColumnSpacing = 3.5
 
static constexpr qreal sColumnWidth = (sPageWidth - 3 * sColumnSpacing) / 4
 
static constexpr qreal sShortcutsWidth = 28
 

Detailed Description

Helper to generate a keyboard shortcuts reference PDF.

Dynamically creates a PDF using the configured keyboard shortcuts (via workspace settings) from librepcb::editor::EditorCommandSet.

Attention
The exported PDF shall be locale-independent, i.e. always in english to avoid unexpected formatting in other languages!

Member Enumeration Documentation

◆ Flag

enum class Flag
strong
Enumerator
Bold 
Italic 
AlignCenter 
AlignRight 

Constructor & Destructor Documentation

◆ ShortcutsReferenceGenerator() [1/3]

◆ ShortcutsReferenceGenerator() [2/3]

◆ ShortcutsReferenceGenerator() [3/3]

ShortcutsReferenceGenerator ( EditorCommandSet commands)
explicitnoexcept

◆ ~ShortcutsReferenceGenerator()

Member Function Documentation

◆ generatePdf()

bool generatePdf ( const FilePath fp)

Generate the PDF.

Parameters
fpDestination PDF file path.
Return values
trueon success.
falseIf the PDF was generated, but the layout has overflown.
Exceptions
Exceptionin case of a fatal error.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

ShortcutsReferenceGenerator & operator= ( const ShortcutsReferenceGenerator rhs)
delete

◆ drawSectionTitle()

void drawSectionTitle ( QPdfWriter &  writer,
QPainter &  painter,
qreal  x1,
qreal  x2,
qreal  y,
const QString &  text 
) const
privatenoexcept
+ Here is the caller graph for this function:

◆ drawCommandCategory()

void drawCommandCategory ( QPdfWriter &  writer,
QPainter &  painter,
qreal  x,
qreal  y,
EditorCommandCategory cat 
) const
privatenoexcept
+ Here is the caller graph for this function:

◆ drawRow()

void drawRow ( QPdfWriter &  writer,
QPainter &  painter,
qreal  x,
qreal  y,
qreal  totalWidth,
qreal  shortcutsWidth,
const QString &  text,
const QString &  shortcuts,
bool  gray 
) const
privatenoexcept
+ Here is the caller graph for this function:

◆ drawText()

int drawText ( QPdfWriter &  writer,
QPainter &  painter,
qreal  x,
qreal  y,
qreal  size,
qreal  maxLength,
const QString &  text,
Flags  flags = Flags() 
) const
privatenoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mmToPx()

int mmToPx ( QPdfWriter &  writer,
qreal  mm 
) const
privatenoexcept
+ Here is the caller graph for this function:

Member Data Documentation

◆ mCommands

EditorCommandSet& mCommands
private

◆ sPageWidth

constexpr qreal sPageWidth = 270
staticconstexprprivate

◆ sPageHeight

constexpr qreal sPageHeight = 190
staticconstexprprivate

◆ sCategoryTextSize

constexpr qreal sCategoryTextSize = 3
staticconstexprprivate

◆ sRowTextSize

constexpr qreal sRowTextSize = 2.5
staticconstexprprivate

◆ sRowHeight

constexpr qreal sRowHeight = 3
staticconstexprprivate

◆ sCategorySpacing

constexpr qreal sCategorySpacing = 5
staticconstexprprivate

◆ sColumnSpacing

constexpr qreal sColumnSpacing = 3.5
staticconstexprprivate

◆ sColumnWidth

constexpr qreal sColumnWidth = (sPageWidth - 3 * sColumnSpacing) / 4
staticconstexprprivate

◆ sShortcutsWidth

constexpr qreal sShortcutsWidth = 28
staticconstexprprivate

The documentation for this class was generated from the following files: