spark-store/src/progressload.cpp
zty199 9a3d32ee11 Improve Features
Support save current theme setting when exit;
Use QScreen::primaryScreen() instead of QDesktopWidget to get desktop size;
Ensure only one instance will be running at the same time.
2021-04-20 18:49:17 +08:00

45 lines
996 B
C++

#include "progressload.h"
#include <DApplicationHelper>
ProgressLoad::ProgressLoad(QWidget *parent) :
QWidget(parent),
m_progess(new QWidget(this)),
timer(new QTimer),
value(0)
{
m_progess->move(0,0);
m_progess->show();
timer->setInterval(10);
timer->start();
connect(timer, &QTimer::timeout, [=]()
{
m_progess->setFixedWidth(width() / 100 * value);
m_progess->setFixedHeight(height());
});
}
void ProgressLoad::setValue(int v)
{
value = v;
m_progess->setFixedWidth(width() / 100 * value);
}
void ProgressLoad::setTheme(bool dark, QColor color)
{
if(dark)
{
plt.setColor(QPalette::Background, QColor(40, 40, 40));
setAutoFillBackground(true);
setPalette(plt);
}
else
{
plt.setColor(QPalette::Background, QColor(255, 255, 255));
setAutoFillBackground(true);
setPalette(plt);
}
m_progess->setStyleSheet("background-color: " + color.name() + ";");
}