hydrogen 1.2.3
ClickableLabel Class Reference

Custom QLabel that emits a signal when clicked. More...

#include <ClickableLabel.h>

Inheritance diagram for ClickableLabel:
Object< ClickableLabel > Base

Public Types

enum class  Color { Bright , Dark }
 The individual colors of the text won't be exposed but are up to the palette/application-wide settings. More...
 

Public Slots

void onPreferencesChanged (H2Core::Preferences::Changes changes)
 
void setText (const QString &sNewText)
 

Signals

void labelClicked (ClickableLabel *pLabel)
 

Public Member Functions

 ClickableLabel (QWidget *pParent, QSize size=QSize(0, 0), QString sText="", Color color=Color::Bright, bool bIsEditable=false)
 
- Public Member Functions inherited from Object< ClickableLabel >
 Object ()
 
 Object (const Object< ClickableLabel > &other)
 
- Public Member Functions inherited from Base
 Base ()
 
 Base (const Base &other)
 
virtual const char * class_name () const
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG.
 
virtual QString toQString (const QString &sPrefix="", bool bShort=true) const
 Formatted string version for debugging purposes.
 

Private Member Functions

virtual void enterEvent (QEvent *e) override
 
virtual void leaveEvent (QEvent *e) override
 
virtual void mousePressEvent (QMouseEvent *e) override
 
virtual void paintEvent (QPaintEvent *e) override
 
void updateFont (QString sFontFamily, H2Core::FontTheme::FontSize fontSize)
 
void updateStyleSheet ()
 

Private Attributes

bool m_bEntered
 
bool m_bIsEditable
 If set to true a highlight will be painted when hovered.
 
Color m_color
 
QSize m_size
 

Additional Inherited Members

- Static Public Member Functions inherited from Base
static const char * _class_name ()
 return the class name
 
static QString base_clock (const QString &sMsg)
 Measures the current time and stores it in __last_clock.
 
static QString base_clock_in (const QString &sMsg)
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation !
 
static bool count_active ()
 
static int getAliveObjectCount ()
 
static object_map_t getObjectMap ()
 
static Loggerlogger ()
 return the logger instance
 
static int objects_count ()
 
static void printObjectMapDiff (object_map_t map)
 Creates the difference between a snapshot of the object map and its current state and prints it to std::cout.
 
static void set_count (bool flag)
 enable/disable class instances counting
 
static void write_objects_map_to (std::ostream &out, object_map_t *map=nullptr)
 output the full objects map to a given ostream
 
static void write_objects_map_to_cerr ()
 output objects map to stderr
 
- Static Public Attributes inherited from Base
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes.
 
- Protected Member Functions inherited from Object< ClickableLabel >
 ~Object ()
 
- Protected Member Functions inherited from Base
 ~Base ()
 
- Static Protected Member Functions inherited from Base
static void registerClass (const char *name, const atomic_obj_cpt_t *counters)
 
- Static Protected Attributes inherited from Base
static bool __count = false
 should we count class instances
 
static timeval __last_clock = { 0, 0 }
 
static Logger__logger = nullptr
 

Detailed Description

Custom QLabel that emits a signal when clicked.

The label tries to be smart when choosing the font size. It knows its own size and decreases the font size - if the original would make the text overflow - until the text fits.

Definition at line 41 of file ClickableLabel.h.

Member Enumeration Documentation

◆ Color

enum class Color
strong

The individual colors of the text won't be exposed but are up to the palette/application-wide settings.

Enumerator
Bright 
Dark 

Definition at line 49 of file ClickableLabel.h.

Constructor & Destructor Documentation

◆ ClickableLabel()

ClickableLabel ( QWidget * pParent,
QSize size = QSize( 0, 0 ),
QString sText = "",
Color color = Color::Bright,
bool bIsEditable = false )
explicit

Definition at line 31 of file ClickableLabel.cpp.

Member Function Documentation

◆ enterEvent()

void enterEvent ( QEvent * e)
overrideprivatevirtual

Definition at line 105 of file ClickableLabel.cpp.

◆ labelClicked

void labelClicked ( ClickableLabel * pLabel)
signal

◆ leaveEvent()

void leaveEvent ( QEvent * e)
overrideprivatevirtual

Definition at line 113 of file ClickableLabel.cpp.

◆ mousePressEvent()

void mousePressEvent ( QMouseEvent * e)
overrideprivatevirtual

Definition at line 69 of file ClickableLabel.cpp.

◆ onPreferencesChanged

void onPreferencesChanged ( H2Core::Preferences::Changes changes)
slot

Definition at line 175 of file ClickableLabel.cpp.

◆ paintEvent()

void paintEvent ( QPaintEvent * e)
overrideprivatevirtual

Definition at line 75 of file ClickableLabel.cpp.

◆ setText

void setText ( const QString & sNewText)
slot

Definition at line 185 of file ClickableLabel.cpp.

◆ updateFont()

void updateFont ( QString sFontFamily,
H2Core::FontTheme::FontSize fontSize )
private

Definition at line 121 of file ClickableLabel.cpp.

◆ updateStyleSheet()

void updateStyleSheet ( )
private

Definition at line 55 of file ClickableLabel.cpp.

Field Documentation

◆ m_bEntered

bool m_bEntered
private

Definition at line 80 of file ClickableLabel.h.

◆ m_bIsEditable

bool m_bIsEditable
private

If set to true a highlight will be painted when hovered.

This should be set if a callback is connected and the user is able to change its content.

Definition at line 79 of file ClickableLabel.h.

◆ m_color

Color m_color
private

Definition at line 74 of file ClickableLabel.h.

◆ m_size

QSize m_size
private

Definition at line 73 of file ClickableLabel.h.