-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadingbutton.cpp
47 lines (38 loc) · 1.04 KB
/
loadingbutton.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "loadingbutton.h"
#include <QHBoxLayout>
#include <QLabel>
#include "buttonicon.h"
LoadingButton::LoadingButton(QWidget* parent)
: QPushButton(parent)
{
QHBoxLayout* layout = new QHBoxLayout(this);
m_buttonIcon = new ButtonIcon;
m_textLabel = new QLabel();
m_textLabel->setAlignment(Qt::AlignLeft);
m_textLabel->setAlignment(Qt::AlignVCenter);
layout->addWidget(m_buttonIcon);
layout->addWidget(m_textLabel);
layout->setSpacing(20);
layout->setContentsMargins(10, 0, 10, 0);
setLayout(layout);
}
void LoadingButton::showLoading(bool bShow)
{
if (bShow) {
m_buttonIcon->showLoadingAnimation();
} else {
m_buttonIcon->hideLoadingAnimation();
}
}
void LoadingButton::setIcon(const QString &url)
{
m_buttonIcon->setIcon(url);
}
void LoadingButton::setLoadingPng(const QString &url, int pngWidthPx, int pngHeightPx)
{
m_buttonIcon->setLoadingPng(url, pngWidthPx, pngHeightPx);
}
void LoadingButton::setText(const QString &text)
{
m_textLabel->setText(text);
}