QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
QETUtils Namespace Reference

Classes

class  FontRestorationScope

Functions

QString marginsToString (const QMargins &margins)
 QETUtils::marginsToString.
QMargins marginsFromString (const QString &string)
 QETUtils::marginsFromString.
qreal graphicsHandlerSize (QGraphicsItem *item)
 QETUtils::graphicsHandlerSize.
void pixelSizedFont (QFont &font)
 QETUtils::pixelSizedFont Set the font size to pixelSize instead of pointSize (if needed). The font used to draw diagram must be pixel sized instead of point sized (default by Qt) then no matter the screen dpi used, the text in diagram keep the same size. For more information see https://qelectrotech.org/forum/viewtopic.php?pid=6267#p6267.
QString fontToString (const QFont &font)
 QETUtils::fontToString Serialize a font to the 10/11 field description format written by Qt 5, to be used instead of QFont::toString() everywhere a font description is stored in a project, element or settings file. The format of QFont::toString() is not stable across Qt versions : Qt 6.11 switched to a 19 field format carrying OpenType weights, which QFont::fromString() of Qt 5.x and Qt <= 6.10 rejects, leaving a broken font. The 10/11 field form is parsed correctly by every Qt version (they convert the legacy weight scale as needed), so composing it ourselves keeps files readable by every QET build in circulation. See https://github.com/qelectrotech/qelectrotech-source-mirror/issues/553.
bool fontFromString (QFont &font, const QString &description)
 QETUtils::fontFromString Restore a font from a description string, tolerating descriptions written by any Qt version. QFont::fromString() of Qt 5.x and Qt <= 6.10 rejects the >= 19 field format QFont::toString() emits since Qt 6.11 (16 base fields plus style name, font-feature count and variable-axis count), leaving a broken font behind. When the native parser fails, salvage such a description by re-composing the 10/11 field form (OpenType weight mapped back to the legacy scale) and parsing that instead, so no font information stored in existing files is lost. See https://github.com/qelectrotech/qelectrotech-source-mirror/issues/553.
bool sortBeginIntString (const QString &str_a, const QString &str_b)
 QETUtils::sortBeginIntString Sort the string str_a and str_b and take in count if string begin with an int to sort it as int and not as string in this case. For example if we have to sort the string : "3str", 10str", "100str", "2str", "20str". The default behavior when sorting QString with the comparison operator will be: "10str" "100str" "2str", "20str", "3str" When sorting with this function, the result will be : "10str", "2str", "3str", "20str", "100str".
template<typename T>
QVector< QWeakPointer< T > > sharedVectorToWeak (const QVector< QSharedPointer< T > > &vector)
template<typename T>
QVector< QSharedPointer< T > > weakVectorToShared (const QVector< QWeakPointer< T > > &vector)

Detailed Description

Provide some small utils function

Function Documentation

◆ fontFromString()

bool QETUtils::fontFromString ( QFont & font,
const QString & description )

QETUtils::fontFromString Restore a font from a description string, tolerating descriptions written by any Qt version. QFont::fromString() of Qt 5.x and Qt <= 6.10 rejects the >= 19 field format QFont::toString() emits since Qt 6.11 (16 base fields plus style name, font-feature count and variable-axis count), leaving a broken font behind. When the native parser fails, salvage such a description by re-composing the 10/11 field form (OpenType weight mapped back to the legacy scale) and parsing that instead, so no font information stored in existing files is lost. See https://github.com/qelectrotech/qelectrotech-source-mirror/issues/553.

Parameters
font: font to restore into; left untouched on failure, so the caller's default keeps applying.
description: font description string
Returns
true if the description could be parsed
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fontToString()

QString QETUtils::fontToString ( const QFont & font)

QETUtils::fontToString Serialize a font to the 10/11 field description format written by Qt 5, to be used instead of QFont::toString() everywhere a font description is stored in a project, element or settings file. The format of QFont::toString() is not stable across Qt versions : Qt 6.11 switched to a 19 field format carrying OpenType weights, which QFont::fromString() of Qt 5.x and Qt <= 6.10 rejects, leaving a broken font. The 10/11 field form is parsed correctly by every Qt version (they convert the legacy weight scale as needed), so composing it ourselves keeps files readable by every QET build in circulation. See https://github.com/qelectrotech/qelectrotech-source-mirror/issues/553.

Parameters
font
Returns
the font description string
Here is the call graph for this function:
Here is the caller graph for this function:

◆ graphicsHandlerSize()

qreal QETUtils::graphicsHandlerSize ( QGraphicsItem * item)

QETUtils::graphicsHandlerSize.

Parameters
item
Returns
Return the handler size to use in the QGraphicsScene of item. If size can't be found, return 10 by default.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marginsFromString()

QMargins QETUtils::marginsFromString ( const QString & string)

QETUtils::marginsFromString.

Parameters
string
Returns
QMargins margins
Here is the caller graph for this function:

◆ marginsToString()

QString QETUtils::marginsToString ( const QMargins & margins)

QETUtils::marginsToString.

Parameters
margins
Returns
QString str "left;top;right;bottom"
Here is the caller graph for this function:

◆ pixelSizedFont()

void QETUtils::pixelSizedFont ( QFont & font)

QETUtils::pixelSizedFont Set the font size to pixelSize instead of pointSize (if needed). The font used to draw diagram must be pixel sized instead of point sized (default by Qt) then no matter the screen dpi used, the text in diagram keep the same size. For more information see https://qelectrotech.org/forum/viewtopic.php?pid=6267#p6267.

Parameters
font
Here is the caller graph for this function:

◆ sharedVectorToWeak()

template<typename T>
QVector< QWeakPointer< T > > QETUtils::sharedVectorToWeak ( const QVector< QSharedPointer< T > > & vector)

◆ sortBeginIntString()

bool QETUtils::sortBeginIntString ( const QString & str_a,
const QString & str_b )

QETUtils::sortBeginIntString Sort the string str_a and str_b and take in count if string begin with an int to sort it as int and not as string in this case. For example if we have to sort the string : "3str", 10str", "100str", "2str", "20str". The default behavior when sorting QString with the comparison operator will be: "10str" "100str" "2str", "20str", "3str" When sorting with this function, the result will be : "10str", "2str", "3str", "20str", "100str".

Parameters
str_a
str_b
Returns

◆ weakVectorToShared()

template<typename T>
QVector< QSharedPointer< T > > QETUtils::weakVectorToShared ( const QVector< QWeakPointer< T > > & vector)