35 , m_bIsEditable( bIsEditable )
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 );
106 QLabel::enterEvent( ev );
114 QLabel::leaveEvent( ev );
125 if ( !
m_size.isNull() ) {
127 float fScalingFactor = 1.0;
128 switch ( fontSize ) {
130 fScalingFactor = 1.0;
133 fScalingFactor = 0.75;
136 fScalingFactor = 0.5;
141 if (
m_size.height() <= 9 ) {
143 }
else if (
m_size.height() <= 16 ) {
149 nPixelSize =
m_size.height() - std::round( fScalingFactor * nMargin );
152 QFont font( sFontFamily );
154 if ( !
m_size.isNull() ) {
155 font.setPixelSize( nPixelSize );
157 font.setBold(
true );
159 if ( !
m_size.isNull() || width() > height() ) {
162 while ( QFontMetrics( font ).size( Qt::TextSingleLine, text() ).width() >
163 width() && nPixelSize > 1 ) {
165 font.setPixelSize( nPixelSize );
180 updateFont( pPref->getLevel3FontFamily(), pPref->getFontSize() );
186 if ( text() == sNewText ) {
192 QLabel::setText( sNewText );
193 updateFont( pPref->getLevel3FontFamily(), pPref->getFontSize() );
void labelClicked(ClickableLabel *pLabel)
virtual void enterEvent(QEvent *e) override
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 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.