BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FancyLabel Class Reference

The FancyLabel class is a QLabel-like class with trivial animation when text slowly appears on the screen from left to right, pretending to be typed. More...

Inheritance diagram for FancyLabel:
[legend]
Collaboration diagram for FancyLabel:
[legend]

Public Member Functions

 FancyLabel (const QString &text, QWidget *parent=nullptr)
 
 FancyLabel (QWidget *parent=nullptr)
 
void setTextAnimated (const QString &animated_text)
 

Private Slots

void onTimeout ()
 

Private Member Functions

void init_fancy_label ()
 

Private Attributes

int m_current_index {0}
 
QString m_text
 
QTimer * m_timer {nullptr}
 
int m_total_effect_duration {0}
 

Detailed Description

The FancyLabel class is a QLabel-like class with trivial animation when text slowly appears on the screen from left to right, pretending to be typed.

Definition at line 23 of file FancyLabel.h.

Constructor & Destructor Documentation

◆ FancyLabel() [1/2]

FancyLabel::FancyLabel ( const QString &  text,
QWidget *  parent = nullptr 
)

Definition at line 18 of file FancyLabel.cpp.

18  : QLabel(text, parent)
19 {
21 }
void init_fancy_label()
Definition: FancyLabel.cpp:59

References init_fancy_label().

Here is the call graph for this function:

◆ FancyLabel() [2/2]

FancyLabel::FancyLabel ( QWidget *  parent = nullptr)

Definition at line 23 of file FancyLabel.cpp.

23  : QLabel(parent)
24 {
26 }

References init_fancy_label().

Here is the call graph for this function:

Member Function Documentation

◆ init_fancy_label()

void FancyLabel::init_fancy_label ( )
private

Definition at line 59 of file FancyLabel.cpp.

60 {
61  m_total_effect_duration = 200; // in msec
62  m_current_index = 0;
63  m_timer = new QTimer(this);
64  connect(m_timer, &QTimer::timeout, this, &FancyLabel::onTimeout);
65 }
int m_current_index
Definition: FancyLabel.h:41
void onTimeout()
Definition: FancyLabel.cpp:49
QTimer * m_timer
Definition: FancyLabel.h:39
int m_total_effect_duration
Definition: FancyLabel.h:40

References m_current_index, m_timer, m_total_effect_duration, and onTimeout().

Referenced by FancyLabel().

Here is the call graph for this function:

◆ onTimeout

void FancyLabel::onTimeout ( )
privateslot

Definition at line 49 of file FancyLabel.cpp.

50 {
51  if (m_current_index <= m_text.size()) {
52  setText(m_text.left(m_current_index));
54  return;
55  }
56  m_timer->stop();
57 }
QString m_text
Definition: FancyLabel.h:38

References m_current_index, m_text, and m_timer.

Referenced by init_fancy_label().

◆ setTextAnimated()

void FancyLabel::setTextAnimated ( const QString &  animated_text)

Definition at line 28 of file FancyLabel.cpp.

29 {
30  if (m_timer->isActive())
31  m_timer->stop();
32 
33  if (animated_text == text())
34  return;
35 
36  if (animated_text.isEmpty()) {
37  setText(animated_text);
38  return;
39  }
40 
41  m_text = animated_text;
42  m_current_index = 0;
43 
44  m_timer->setInterval(m_total_effect_duration / m_text.size());
45 
46  m_timer->start();
47 }

References m_current_index, m_text, m_timer, and m_total_effect_duration.

Referenced by WelcomeView::setCurrentProjectName().

Member Data Documentation

◆ m_current_index

int FancyLabel::m_current_index {0}
private

Definition at line 41 of file FancyLabel.h.

Referenced by init_fancy_label(), onTimeout(), and setTextAnimated().

◆ m_text

QString FancyLabel::m_text
private

Definition at line 38 of file FancyLabel.h.

Referenced by onTimeout(), and setTextAnimated().

◆ m_timer

QTimer* FancyLabel::m_timer {nullptr}
private

Definition at line 39 of file FancyLabel.h.

Referenced by init_fancy_label(), onTimeout(), and setTextAnimated().

◆ m_total_effect_duration

int FancyLabel::m_total_effect_duration {0}
private

Definition at line 40 of file FancyLabel.h.

Referenced by init_fancy_label(), and setTextAnimated().


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