kwave  18.07.70
Kwave::StatusWidget Class Reference

#include <StatusWidget.h>

Inheritance diagram for Kwave::StatusWidget:
Inheritance graph
Collaboration diagram for Kwave::StatusWidget:
Collaboration graph

Public Member Functions

 StatusWidget (QWidget *parent=Q_NULLPTR)
 
virtual ~StatusWidget () Q_DECL_OVERRIDE
 
void setPixmaps (const QVector< QPixmap > &pixmaps, unsigned int speed=150)
 

Protected Member Functions

virtual void paintEvent (QPaintEvent *) Q_DECL_OVERRIDE
 

Private Slots

void nextPixmap ()
 

Private Attributes

QVector< QPixmap > m_pixmaps
 
unsigned int m_index
 
QTimer m_timer
 

Detailed Description

Widget needed to display a little icon in the status bar

Definition at line 33 of file StatusWidget.h.

Constructor & Destructor Documentation

◆ StatusWidget()

Kwave::StatusWidget::StatusWidget ( QWidget *  parent = Q_NULLPTR)
explicit

Constructor

Definition at line 28 of file StatusWidget.cpp.

References Kwave::connect(), m_timer, and nextPixmap().

29  :QWidget(parent), m_pixmaps(), m_index(0), m_timer()
30 {
31  connect(&m_timer, SIGNAL(timeout()),
32  this, SLOT(nextPixmap()));
33 }
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
QVector< QPixmap > m_pixmaps
Definition: StatusWidget.h:66
unsigned int m_index
Definition: StatusWidget.h:69
Here is the call graph for this function:

◆ ~StatusWidget()

Kwave::StatusWidget::~StatusWidget ( )
virtual

Destructor

Definition at line 36 of file StatusWidget.cpp.

References m_pixmaps, and m_timer.

37 {
38  m_timer.stop();
39  m_pixmaps.clear();
40 }
QVector< QPixmap > m_pixmaps
Definition: StatusWidget.h:66

Member Function Documentation

◆ nextPixmap

void Kwave::StatusWidget::nextPixmap ( )
privateslot

switch to the next pixmap in the pixmaps list

Definition at line 73 of file StatusWidget.cpp.

References m_index, m_pixmaps, and Kwave::toInt().

Referenced by StatusWidget().

74 {
75  m_index++;
76  if (Kwave::toInt(m_index) >= m_pixmaps.count())
77  m_index = 0;
78  repaint();
79 }
QVector< QPixmap > m_pixmaps
Definition: StatusWidget.h:66
int toInt(T x)
Definition: Utils.h:127
unsigned int m_index
Definition: StatusWidget.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ paintEvent()

void Kwave::StatusWidget::paintEvent ( QPaintEvent *  )
protectedvirtual

repaint, see QWidget::paintEvent

Definition at line 43 of file StatusWidget.cpp.

References m_index, and m_pixmaps.

44 {
45  if (!m_pixmaps.count()) return;
46 
47  QPixmap pixmap = m_pixmaps.at(m_index);
48  const int ww = width();
49  const int wh = height();
50  const int pw = pixmap.width();
51  const int ph = pixmap.height();
52 
53  QPainter p(this);
54  p.drawPixmap((ww - pw) >> 1, (wh - ph) >> 1, pixmap);
55 }
QVector< QPixmap > m_pixmaps
Definition: StatusWidget.h:66
unsigned int m_index
Definition: StatusWidget.h:69

◆ setPixmaps()

void Kwave::StatusWidget::setPixmaps ( const QVector< QPixmap > &  pixmaps,
unsigned int  speed = 150 
)

Set a new list of pixmaps

Parameters
pixmapsa list of pixmaps (can also have only one element)
speedif multiple pixmaps are given, the time in milliseconds between the pixmaps, for animation

Definition at line 58 of file StatusWidget.cpp.

References m_index, m_pixmaps, and m_timer.

Referenced by Kwave::RecordDialog::setState().

60 {
61  m_timer.stop();
62  m_pixmaps.clear();
63  m_pixmaps = pixmaps;
64  m_index = 0;
65  repaint();
66 
67  m_timer.setSingleShot(false);
68  m_timer.setInterval(speed);
69  if (m_pixmaps.count() > 1) m_timer.start();
70 }
QVector< QPixmap > m_pixmaps
Definition: StatusWidget.h:66
unsigned int m_index
Definition: StatusWidget.h:69
Here is the caller graph for this function:

Member Data Documentation

◆ m_index

unsigned int Kwave::StatusWidget::m_index
private

index of the current pixmap

Definition at line 69 of file StatusWidget.h.

Referenced by nextPixmap(), paintEvent(), and setPixmaps().

◆ m_pixmaps

QVector<QPixmap> Kwave::StatusWidget::m_pixmaps
private

the pixmap to show

Definition at line 66 of file StatusWidget.h.

Referenced by nextPixmap(), paintEvent(), setPixmaps(), and ~StatusWidget().

◆ m_timer

QTimer Kwave::StatusWidget::m_timer
private

timer for switching to the next pixmap

Definition at line 72 of file StatusWidget.h.

Referenced by setPixmaps(), StatusWidget(), and ~StatusWidget().


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