38 if ( ! size.isNull() ) {
45 updateFont( pPref->getLevel3FontFamily(), pPref->getFontSize() );
48 setAlignment( Qt::AlignCenter );
61 text = pPref->getColorTheme()->m_windowTextColor;
63 text = pPref->getColorTheme()->m_widgetTextColor;
66 setStyleSheet( QString(
"QLabel { color: %1; }" ).arg( text.name() ) );
77 QLabel::paintEvent( ev );
86 QPainter painter(
this);
88 QColor colorHighlightActive = pPref->getColorTheme()->m_highlightColor;
94 colorHighlightActive.setAlpha( 150 );
98 pen.setColor( colorHighlightActive );
100 painter.setPen( pen );
101 painter.drawRoundedRect( QRect( 1, 1,
m_size.width() - 2,
m_size.height() - 2 ), 3, 3 );
105#ifdef H2CORE_HAVE_QT6
110 QLabel::enterEvent( ev );
118 QLabel::leaveEvent( ev );
129 if ( !
m_size.isNull() ) {
131 float fScalingFactor = 1.0;
132 switch ( fontSize ) {
134 fScalingFactor = 1.0;
137 fScalingFactor = 0.75;
140 fScalingFactor = 0.5;
145 if (
m_size.height() <= 9 ) {
147 }
else if (
m_size.height() <= 16 ) {
153 nPixelSize =
m_size.height() - std::round( fScalingFactor * nMargin );
156 QFont font( sFontFamily );
158 if ( !
m_size.isNull() ) {
159 font.setPixelSize( nPixelSize );
161 font.setBold(
true );
163 if ( !
m_size.isNull() || width() > height() ) {
166 while ( QFontMetrics( font ).size( Qt::TextSingleLine, text() ).width() >
167 width() && nPixelSize > 1 ) {
169 font.setPixelSize( nPixelSize );
184 updateFont( pPref->getLevel3FontFamily(), pPref->getFontSize() );
190 if ( text() == sNewText ) {
196 QLabel::setText( sNewText );
197 updateFont( pPref->getLevel3FontFamily(), pPref->getFontSize() );
void labelClicked(ClickableLabel *pLabel)
virtual void mousePressEvent(QMouseEvent *e) override
bool m_bIsEditable
If set to true a highlight will be painted when hovered.
virtual void leaveEvent(QEvent *e) override
void onPreferencesChanged(H2Core::Preferences::Changes changes)
void setText(const QString &sNewText)
ClickableLabel(QWidget *pParent, QSize size=QSize(0, 0), QString sText="", Color color=Color::Bright, bool bIsEditable=false)
Color
The individual colors of the text won't be exposed but are up to the palette/application-wide setting...
void updateFont(QString sFontFamily, H2Core::FontTheme::FontSize fontSize)
virtual void enterEvent(QEvent *ev) override
virtual void paintEvent(QPaintEvent *e) override
FontSize
Enables custom scaling of the font size in the GUI.
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
Changes
Bitwise or-able options showing which part of the Preferences were altered using the PreferencesDialo...
@ Font
Either the font size or font family have changed.
@ Colors
At least one of the colors has changed.
static HydrogenApp * get_instance()
Returns the instance of HydrogenApp class.
void preferencesChanged(H2Core::Preferences::Changes changes)
Propagates a change in the Preferences through the GUI.